Need to setup gpg-agent first, on OSX I use keychain (it also does ssh-agent)
$ brew info keychain
keychain: stable 2.8.5
User-friendly front-end to ssh-agent(1)
https://www.funtoo.org/Keychain
/usr/local/Cellar/keychain/2.8.5 (7 files, 108.5KB) *| import contextlib | |
| import hashlib | |
| import logging | |
| from collections import defaultdict | |
| from decimal import Decimal | |
| from django.db.models import DecimalField, ForeignKey | |
| log = logging.getLogger(__name__) |
| def merge_dicts(dict_list): | |
| """Merge all values from dict list into a single dict | |
| >>> d1 = {'a': 1, 'b': 2} | |
| >>> d2 = {'a': 2, 'b': 3} | |
| >>> merge_dicts([d1, d2]) | |
| {'a': [1, 2], 'b': [2, 3]} | |
| """ | |
| kviter = chain.from_iterable(d.iteritems() for d in dict_list) |
| from nautobot.dcim.models import Device | |
| from nautobot.dcim.models import Interface | |
| from nautobot.dcim.choices import InterfaceTypeChoices | |
| from nautobot.ipam.models import VLAN | |
| from nautobot.extras.jobs import Job | |
| class TestJob(Job): | |
| class Meta: | |
| description = "Some job jo!" |
| def select_option_for_select2(driver, id, text=None): | |
| element = driver.find_element(By.XPATH, '//*[@id="{}"]/following-sibling::*[1]'.format(id)) | |
| element.click() | |
| if text: | |
| element = driver.find_element(By.CSS_SELECTOR, "input[type=search]") | |
| element.send_keys(text) | |
| try: | |
| element.send_keys(Keys.ENTER) |
Managment commands are assumed to be unique across all apps in a Django project. This can lead to long or obscure command names in attempt to namespace those commands.
Subcommander acts as a proxy command giving the real commands a namespace. The subcommander module can be named after the app name or some derivation. The structure looks as follows:
myapp/
management/
commands/| import sys | |
| import string | |
| from trigger.cmds import Commando | |
| from twisted.python import log | |
| log.startLogging(sys.stdout, setStdout=False) | |
| devices = ["pe1.demo.localdomain", "pe2.demo.localdomain"] | |
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| # Copyright (c) Twisted Matrix Laboratories. | |
| # See LICENSE for details. | |
| import base64, os, fcntl, tty, struct | |
| from twisted.enterprise import adbapi |
| #!/bin/sh | |
| # Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the | |
| # CREATE block and create them in separate commands _after_ all the INSERTs. | |
| # Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk. | |
| # The mysqldump file is traversed only once. | |
| # Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite | |
| # Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite |