From 450371836069d844781ee3f02ae2d44b324359b8 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Wed, 22 May 2019 14:35:33 -0300 Subject: Record argument and duration --- ckandumper | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/ckandumper b/ckandumper index 48967be..928e11a 100755 --- a/ckandumper +++ b/ckandumper @@ -164,7 +164,7 @@ class CkanDumper: def __init__(self, args): self.url = args.url[0] - self.dest = args.dest[0] + self.dest = ''.join(args.dest) self.package_list = '/api/3/action/package_list' self.package_show = '/api/3/action/package_show?' self.group_list = '/api/3/action/group_list' @@ -352,13 +352,29 @@ if __name__ == "__main__": try: start_time = time.time() + # Initialize our dumper ckan = CkanDumper(args) + + # Record date and invocation + logs = ''.join(args.dest) + os.sep + 'logs' + os.sep + ckan.download.ensuredir(logs) + invocation = open(logs + 'ckandumper.args', 'a') + invocation.write(str(datetime.datetime.now()) + '\t' + ' '.join(sys.argv) + '\n') + invocation.close() + + # Download everything we can ckan.dump() - interval = round(time.time() - start_time) + # Calculate runtime + end_time = time.time() + interval = round(end_time - start_time) duration = str(datetime.timedelta(seconds=interval)) + # Record duration print(f'Done. Elapsed time: {duration}') + elapsed = open(logs + 'ckandumper.duration', 'a') + elapsed.write(str(start_time) + '\t' + str(end_time) + '\t' + duration) + elapsed.close() except (FileNotFoundError, KeyboardInterrupt, subprocess.CalledProcessError) as e: print(e) exit(1) -- cgit v1.2.3