@@ -81,13 +81,13 @@ def run_task(self, job_uid=None, user=None, ondemand=True): # noqa
81
81
LOG .debug ('Saved task: {0}' .format (format_name ))
82
82
83
83
if ondemand :
84
- # run_task_remote(run_uid)
85
- # db.close_old_connections()
86
- run_task_async_ondemand .send (run_uid )
84
+ run_task_remote (run_uid )
85
+ db .close_old_connections ()
86
+ # run_task_async_ondemand.send(run_uid)
87
87
else :
88
- # run_task_remote(run_uid)
89
- # db.close_old_connections()
90
- run_task_async_scheduled .send (run_uid )
88
+ run_task_remote (run_uid )
89
+ db .close_old_connections ()
90
+ # run_task_async_scheduled.send(run_uid)
91
91
return run
92
92
93
93
@dramatiq .actor (max_retries = 0 ,queue_name = 'default' ,time_limit = 1000 * 60 * 60 * 6 )
@@ -283,6 +283,13 @@ def add_metadata(z,theme):
283
283
if geojson :
284
284
try :
285
285
response_back = geojson .fetch ('GeoJSON' ,is_hdx_export = True )
286
+ try :
287
+ for r in response_back :
288
+ size_path = join (download_dir ,f"{ r ['download_url' ].split ('/' )[- 1 ]} _size.txt" )
289
+ with open (size_path , 'w' ) as f :
290
+ f .write (str (r ['zip_file_size_bytes' ][0 ]))
291
+ except :
292
+ LOG .error ("Can not write filesize to text" )
286
293
finish_task ('geojson' ,response_back = response_back )
287
294
except Exception as ex :
288
295
raise ex
@@ -305,6 +312,13 @@ def add_metadata(z,theme):
305
312
if shp :
306
313
try :
307
314
response_back = shp .fetch ('shp' ,is_hdx_export = True )
315
+ try :
316
+ for r in response_back :
317
+ size_path = join (download_dir ,f"{ r ['download_url' ].split ('/' )[- 1 ]} _size.txt" )
318
+ with open (size_path , 'w' ) as f :
319
+ f .write (str (r ['zip_file_size_bytes' ][0 ]))
320
+ except :
321
+ LOG .error ("Can not write filesize to text" )
308
322
finish_task ('shp' ,response_back = response_back )
309
323
except Exception as ex :
310
324
raise ex
@@ -383,7 +397,15 @@ def add_metadata(z,theme):
383
397
if geojson :
384
398
try :
385
399
response_back = geojson .fetch ('GeoJSON' )
400
+ try :
401
+ for r in response_back :
402
+ size_path = join (download_dir ,f"{ r ['download_url' ].split ('/' )[- 1 ]} _size.txt" )
403
+ with open (size_path , 'w' ) as f :
404
+ f .write (str (r ['zip_file_size_bytes' ][0 ]))
405
+ except :
406
+ LOG .error ("Can not write filesize to text" )
386
407
finish_task ('geojson' ,response_back = response_back )
408
+
387
409
except Exception as ex :
388
410
raise ex
389
411
@@ -396,6 +418,13 @@ def add_metadata(z,theme):
396
418
if shp :
397
419
try :
398
420
response_back = shp .fetch ('shp' )
421
+ try :
422
+ for r in response_back :
423
+ size_path = join (download_dir ,f"{ r ['download_url' ].split ('/' )[- 1 ]} _size.txt" )
424
+ with open (size_path , 'w' ) as f :
425
+ f .write (str (r ['zip_file_size_bytes' ][0 ]))
426
+ except :
427
+ LOG .error ("Can not write filesize to text" )
399
428
finish_task ('shp' ,response_back = response_back )
400
429
except Exception as ex :
401
430
raise ex
0 commit comments