Source code for egaia.egaia_log

import os
import egaia_config

logfile = os.path.expanduser(egaia_config.getConfig(section='archive', 
                                key='logfile'))

[docs]def writeLog(line): """Write a line to the log file""" try: with open(logfile, 'a') as log: log.write('\n'+line) return except: return "Error writing to log file!"
[docs]def logRename(original, modified): """Log renames so that we can undo changes later""" writeLog('mv %s %s' % (original, modified))
def _cli(args): """egaia log Print destructive actions such as file renames to the archive log, so they can potentially be undone later. Usage: egaia log --help egaia log --rename ORIGINAL MODIFIED """ if args['--rename']: logRename(args['--rename'], args['MODIFIED'])