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
def prompt(question, answers): | |
""" | |
Prompt the user with a question and only accept defined answers. | |
Input: | |
question (str): Question string | |
answers (list): A list containing accpeted response value | |
Output: | |
answer (str|int): Provided answer | |
""" |
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
def prompt_yn(question): | |
""" | |
Prompt the user with a yes or no question. | |
Input: | |
question (str): Question string | |
Output: | |
answer (bool): Answer True/False | |
""" | |
while True: |
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 re | |
def to_units(value, unit): | |
""" | |
Convert a size string from unit x to unit y. | |
Input: | |
value (str): Size string | |
unit (str): Unit to convert to | |
Output: |
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 re | |
def to_bytes(value): | |
""" | |
Convert a size string with an exponent into bytes. | |
Input: | |
value (str): Size string | |
Output: | |
bytes (int): Size in bytes |
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 execute import execute, Retcode | |
import re | |
def get_zpool_drives(zpool): | |
""" | |
Returns all drives in the zpool. | |
Inputs: | |
zpool (str): Zpool name | |
Outputs: |
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
#!/bin/bash | |
# | |
# ipcheck.sh | |
# | |
# Check public IP and notify by email if it has changed. | |
# | |
EMAIL="test@test.com" | |
LOG="/root/.myip" |
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
def parse_table(f, idx=0, delim=None, head=None): | |
""" | |
Parse a table. | |
Inputs: | |
f (str): Path to file | |
idx (int): Index column | |
delim (str): Table delimiter | |
head (list): Optionally defined table header | |
Outputs: |
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
def pprint_table(table): | |
""" | |
Pretty print table. | |
Inputs: | |
table (list): table | |
Outputs: | |
None | |
""" | |
padding = [] |
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 collections import defaultdict | |
def tree(): | |
return defaultdict(tree) |
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
#!/bin/bash | |
# | |
# carbon-cache | |
# | |
# Graphite's carbon-cache daemon init script. | |
# | |
# William Kettler <william.p.kettler@gmail.com> | |
# | |
# Source init-functions |
OlderNewer