Skip to content

Instantly share code, notes, and snippets.

def csvbackup(REGEX, FOLDER):
""" Find any file with the REGEX pattern in the PWD
and send it to assigned FOLDER.
"""
try:
current = os.getcwd()
files = glob.iglob(os.path.join(current, REGEX))
DST_FLD = current + '/' + FOLDER
for bkup in files:
if os.path.isfile(bkup):
@h4ndzdatm0ld
h4ndzdatm0ld / norninr-1-example
Last active September 23, 2020 22:50
Nornir Walkthrough 1
def get_vrfcli(task, servicename):
''' Retrieve VRF from IOSXR
'''
vrf = task.run(netmiko_send_command, command_string=f"sh vrf {servicename} detail")
print_result(vrf)
def get_vprncli(task, servicename):
''' Retrieve VPRN from Nokia
'''
vprn = task.run(netmiko_send_command, command_string=f"show service id {servicename} base")
@h4ndzdatm0ld
h4ndzdatm0ld / simple_excel
Created February 14, 2021 06:05
Load a workbook as a dictionary
def simple_excel(workbook, sheetname, keep_vba=False, data_only=True):
wb_obj = load_workbook(
filename=workbook, keep_vba=keep_vba, data_only=data_only, read_only=True
)
wsheet = wb_obj[sheetname]
data_key = []
for value in wsheet.iter_rows(values_only=True):
@h4ndzdatm0ld
h4ndzdatm0ld / Dockerfile-base
Last active June 6, 2021 17:38
Common template as a base start for Dockerfile
#############
# Dependencies
# This base stage just installs the dependencies required for production
# without any development deps.
ARG PYTHON_VER=3.8
FROM python:${PYTHON_VER} AS base
WORKDIR /usr/src/app