Changed: Transfer to EARLINET DB for measurements from lidar configuration with Automatic Upload set to True

Sun, 03 Dec 2023 16:39:00 +0100

author
Claudio Dema <claudio.dema@imaa.cnr.it>
date
Sun, 03 Dec 2023 16:39:00 +0100
changeset 73
a7685a98dfcd
parent 72
3de925f654ad
child 74
f444f0bfe7c2

Changed: Transfer to EARLINET DB for measurements from lidar configuration with Automatic Upload set to True

scc_access/scc_access.py file | annotate | diff | comparison | revisions
--- a/scc_access/scc_access.py	Wed Nov 08 12:01:02 2023 +0100
+++ b/scc_access/scc_access.py	Sun Dec 03 16:39:00 2023 +0100
@@ -694,7 +694,8 @@
         logger.info("Deleted measurement {0}".format(measurement_id))
         return True
 
-    def available_measurements(self, start_gte=None, stop_lte=None, is_being_processed=None, is_queued=None):
+    def available_measurements(self, start_gte=None, stop_lte=None, is_being_processed=None, is_queued=None,
+                               creation_gte=None, creation_lte=None, automatic_upload=None):
         """ Get a list of available measurement on the SCC.
 
         The methods is currently not used, could be merged with list_measurements.
@@ -709,7 +710,12 @@
             params['is_being_processed'] = is_being_processed
         if is_queued is not None:
             params['is_queued'] = is_queued
-
+        if creation_gte is not None:
+            params['creation_date__gte'] = creation_gte
+        if creation_lte is not None:
+            params['creation_date__lte'] = creation_lte
+        if automatic_upload is not None:
+            params['system__automatic_upload'] = automatic_upload
 
         response = self.session.get(self.api_measurements_url, params=params)
         response_dict = response.json()
@@ -1096,7 +1102,7 @@
 
 
 def automatic_upload(settings):
-    date_time_start = datetime.datetime.now() - datetime.timedelta(hours=8)
+    date_time_start = datetime.datetime.utcnow() - datetime.timedelta(hours=8)
     date_time_start = date_time_start.replace(minute=0, second=0)
     start_parameter = date_time_start.strftime("%Y-%m-%dT%H:%M:%S")
     date_time_stop = date_time_start + datetime.timedelta(hours=6)
@@ -1110,7 +1116,8 @@
     with SCC(settings['basic_credentials'], settings['output_dir'], settings['base_url'], settings['sccdb_host'], settings['sccdb_credentials'], settings['sccdb']) as scc:
         scc.login(settings['website_credentials'])
 
-        measurements = scc.available_measurements(start_gte=start_parameter, stop_lte=stop_parameter, is_queued=False, is_being_processed=False)
+        measurements = scc.available_measurements(creation_gte=start_parameter, creation_lte=stop_parameter,
+                                                  is_queued=False, is_being_processed=False, automatic_upload=True)
         is_automatic_upload = True
         if measurements is not None:
             for meas in measurements:

mercurial