This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import re | |
from typing import TYPE_CHECKING, cast | |
if TYPE_CHECKING: | |
from scrapli.driver import AsyncNetworkDriver | |
class RPNotActiveError(Exception): | |
pass | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
BOOTSTRAP_SCRIPT_PATH="${HOME}/bootstrap.sh" | |
# set colors | |
if tput setaf 1 &> /dev/null; then | |
tput sgr0 | |
if [[ $(tput colors) -ge 256 ]] 2>/dev/null; then | |
ORANGE="$(tput setaf 172)" | |
else | |
ORANGE="$(tput setaf 4)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
import time | |
import traceback | |
from functools import wraps | |
from typing import Union, Type, Tuple, Optional, Callable, TypeVar | |
T = TypeVar("T") | |
logger = logging.getLogger(__name__) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Any, Union, Optional | |
from lxml import etree | |
__license__ = "MIT" | |
# Feel free to re-use the code snippet for any projects without attribution | |
def dict_to_xml( | |
data: Any, root: Union[None, str, etree._Element] = None, attr_marker: str = "_" | |
) -> etree.Element: | |
"""Converts Python dictionary with YANG data to lxml etree.Element object. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Script which converts Splunk logs to different firewall objects and | |
prints them on the console | |
Copyright (c) 2018 Cisco and/or its affiliates. | |
This software is licensed to you under the terms of the Cisco Sample | |
Code License, Version 1.0 (the "License"). You may obtain a copy of the | |
License at | |
https://developer.cisco.com/docs/licenses | |
All use of the material herein must be in accordance with the terms of | |
the License. All rights not expressly granted by the License are |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This gist shows how to run asyncio loop in a separate thread. | |
It could be useful if you want to mix sync and async code together. | |
Python 3.7+ | |
""" | |
import asyncio | |
from datetime import datetime | |
from threading import Thread | |
from typing import Tuple, List, Iterable |