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 __future__ import annotations | |
import logging | |
from datetime import datetime | |
from enum import Enum | |
from typing import List | |
from urllib.parse import urlparse | |
from prometheus_client import REGISTRY, CollectorRegistry, Gauge, Info |
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
try: | |
from cheroot.wsgi import Server as WSGIServer, PathInfoDispatcher | |
except ImportError: | |
from cherrypy.wsgiserver import CherryPyWSGIServer as WSGIServer, WSGIPathInfoDispatcher as PathInfoDispatcher | |
from .your_module import app | |
d = PathInfoDispatcher({'/': app}) | |
server = WSGIServer(('0.0.0.0', 5000), d) |
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 | |
declare -A ratios | |
declare -A freespace | |
declare -A units | |
declare -r DRY_RUN="${1}" | |
declare HIDDEN_PARTITION="${2}" | |
declare LVM_PARTITION="${3}" | |
grow_partitions=("${HIDDEN_PARTITION:=/dev/sda2}" "${LVM_PARTITION:=/dev/sda5}") |
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 pwd | |
import os | |
import re | |
import glob | |
import ipaddress | |
import socket | |
import struct | |
import codecs | |
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, Tuple, Generator | |
SEPARATOR = '.' | |
def dict_flatten( | |
d: dict, parent_key: str = "", sep: str = SEPARATOR | |
) -> Generator[Tuple[str, Any], None, None]: | |
for key, value in d.items(): | |
if isinstance(value, dict): | |
yield from dict_flatten(value, parent_key=f"{parent_key}{key}{sep}") |
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 Generator, Any | |
def list_flatten(l: list) -> Generator[Any,None,None]: | |
for item in l: | |
if isinstance(item, list): | |
yield from list_flatten(item) | |
else: | |
yield item | |
if __name__ == '__main__': |
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 argparse | |
import io | |
import itertools | |
import sys | |
from typing import Any, Generator, Tuple, Union | |
import ruamel | |
from pytablewriter import MarkdownTableWriter | |
from ruamel.yaml import YAML |
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 glob | |
import argparse | |
import re | |
import os | |
parser = argparse.ArgumentParser(description='Rename some files.') | |
parser.add_argument('--pattern', type=str, default='') | |
parser.add_argument('--substitution', type=str, default='') | |
args = parser.parse_args() |
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 | |
declare -r TEMP_MOUNT="$(mktemp -d)" | |
declare -r TITLE="Python Ironic Agent" | |
declare -r DESTINATION="${1:-out.iso}" | |
declare -r KERNEL="${2:-kernel}" | |
declare -r INITRAMFS="${3:-initramfs}" | |
echo "TEMP_MOUNT = ${TEMP_MOUNT}" | |
dd if=/dev/zero of=${DESTINATION} bs=1M count=514 |
OlderNewer