"""Old stuff Prefer io.py now. """ import logging import os import time from .io import (cd, touch, mkdirs, syscall as system) LOG = logging.getLogger() def run(script_fn): cwd, basename = os.path.split(script_fn) with cd(cwd): system('/bin/bash {}'.format(basename)) def rmdirs(path): if os.path.isdir(path): if len(path) < 20 and 'home' in path: LOG.error('Refusing to rm {!r} since it might be your homedir.'.format(path)) return cmd = 'rm -rf {}'.format(path) system(cmd) def logger_record(func): def wrapper(*args, **kwargs): LOG.info("====>Begin executing function: {}".format(func.__name__)) if args: LOG.info("====>args={}".format(args)) if kwargs: LOG.info("====>kwargs={}".format(kwargs)) # function execution t_start = time.time() func(*args, **kwargs) t_end = time.time() LOG.info("====>End executing function: {}, time cost: {} second." .format(func.__name__, (t_end-t_start))) return wrapper