aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xckandumper20
1 files 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)