Revision e1282053
Added by David Sorber over 7 years ago
| software/hbkcd/hbkcd/utils.py | ||
|---|---|---|
|
|
||
|
def pp_filesize(file_size):
|
||
|
""" Pretty print file size using base 2 units and including a label.
|
||
|
"""
|
||
|
|
||
|
if file_size >= 2**40:
|
||
|
# TB
|
||
|
scaled = file_size / (2**40 * 1.0)
|
||
|
unit = 'TB'
|
||
|
elif file_size >= 2**30:
|
||
|
# GB
|
||
|
scaled = file_size / (2**30 * 1.0)
|
||
|
unit = 'GB'
|
||
|
elif file_size >= 2**20:
|
||
|
# MB
|
||
|
scaled = file_size / (2**20 * 1.0)
|
||
|
unit = 'MB'
|
||
|
elif file_size >= 2**10:
|
||
|
# KB
|
||
|
scaled = file_size / (2**10 * 1.0)
|
||
|
unit = 'KB'
|
||
|
else:
|
||
|
# Bytes
|
||
|
scaled = file_size
|
||
|
unit = 'b'
|
||
|
|
||
|
return '{:.2f} {:s}'.format(scaled, unit)
|
||
| software/hbkcd/scripts/hbkcd_status.sh | ||
|---|---|---|
|
#!/bin/bash
|
||
|
BOLD='\033[1m'
|
||
|
ENDC='\033[0m'
|
||
|
BOLD_RED='\033[1;31m'
|
||
|
|
||
|
ADDRESS="brutus"
|
||
|
PORT="8081"
|
||
|
|
||
|
# Make sure curl ad jq are installed
|
||
|
command -v curl >/dev/null 2>&1 || { echo >&2 "Please install curl to use this script. Aborting."; exit 1; }
|
||
|
command -v jq >/dev/null 2>&1 || { echo >&2 "Please install jq to use this script. Aborting."; exit 1; }
|
||
|
|
||
|
DATA=`curl -s -X GET http://$ADDRESS:$PORT/queue`
|
||
|
|
||
|
STATUS=`echo $DATA | jq .queue[0].status`
|
||
|
STATUS="${STATUS%\"}" # This magic removes surrounding quotes
|
||
|
STATUS="${STATUS#\"}"
|
||
|
|
||
|
INPUT=`echo $DATA | jq .queue[0].path`
|
||
|
INPUT="${INPUT%\"}"
|
||
|
INPUT="${INPUT#\"}"
|
||
|
|
||
|
OUTPUT=`echo $DATA | jq .queue[0].output_file`
|
||
|
OUTPUT="${OUTPUT%\"}"
|
||
|
OUTPUT="${OUTPUT#\"}"
|
||
|
|
||
|
TIME_ADDED=`echo $DATA | jq .queue[0].time_added`
|
||
|
TIME_ADDED="${TIME_ADDED%\"}"
|
||
|
TIME_ADDED="${TIME_ADDED#\"}"
|
||
|
|
||
|
ENCODE_STARTED=`echo $DATA | jq .queue[0].encode_started`
|
||
|
ENCODE_STARTED="${ENCODE_STARTED%\"}"
|
||
|
ENCODE_STARTED="${ENCODE_STARTED#\"}"
|
||
|
|
||
|
printf "\n"
|
||
|
if [[ "$STATUS" = "null" ]]; then
|
||
|
printf "${BOLD_RED}NO ENCODE IN PROGRESS${ENDC}\n"
|
||
|
else
|
||
|
# NOTE: printf complained about the contents of the strings for some reason
|
||
|
echo -e "${BOLD}Status:${ENDC} ${STATUS}"
|
||
|
echo -e "${BOLD}Input:${ENDC} $INPUT"
|
||
|
echo -e "${BOLD}Output:${ENDC} $OUTPUT"
|
||
|
echo -e "${BOLD}Added:${ENDC} $TIME_ADDED"
|
||
|
echo -e "${BOLD}Started:${ENDC} $ENCODE_STARTED"
|
||
|
fi
|
||
|
printf "\n"
|
||
Adding new files that I forgot to add before.