# HG changeset patch # User greg # Date 1493820817 14400 # Node ID 58382c8ed01ca47a01f67211bee1724f46cc8d8e # Parent ac9b32bd719cdc0ea9c45414f336c1a3533474ad Uploaded diff -r ac9b32bd719c -r 58382c8ed01c utils.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utils.py Wed May 03 10:13:37 2017 -0400 @@ -0,0 +1,44 @@ +import os +import shutil +import sys + + +def check_execution_errors(rc, stderr, stdout=None): + if rc != 0: + if stdout is None: + stop_err(stderr.read()) + msg = '%s\n%s' % (stdout.read(), stderr.read()) + + +def move_directory_files(source_dir, destination_dir): + source_directory = os.path.abspath(source_dir) + destination_directory = os.path.abspath(destination_dir) + if not os.path.isdir(destination_directory): + os.makedirs(destination_directory) + for dir_entry in os.listdir(source_directory): + source_entry = os.path.join(source_directory, dir_entry) + shutil.move(source_entry, destination_directory) + + +def stop_err(msg): + sys.stderr.write(msg) + sys.exit(1) + + +def write_html_output(output, title, dir): + with open(output, 'w') as fh: + fh.write('
Size | Name |
---|---|
%s | %s |