This repository was archived by the owner on Sep 11, 2025. It is now read-only.
forked from marcin-osowski/igc_lib
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRunMetadata.py
More file actions
52 lines (44 loc) · 1.92 KB
/
Copy pathRunMetadata.py
File metadata and controls
52 lines (44 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from datetime import datetime, date, time, timedelta
import pytz
import json
from flask.json import JSONEncoder
class RunMetadata(object):
#def init(self, target_date, script_start_time, script_end_time, flights_count, thermals_count):
# # Get current time in the right time-zone
# tz = pytz.timezone('Europe/Paris')
# self.targetDate = str(target_date)
# if script_start_time is None:
# script_start_time = datetime.now(tz)
# self.script_start_time = script_start_time
# self.startDate = str(script_start_time)
# self.endDate = str(script_end_time)
# if not script_end_time is None:
# self.duration = str(script_end_time - script_start_time)
# self.flightsCount = int(flights_count)
# self.thermalsCount = int(thermals_count)
# self.boundingBoxUpperLeft = []
# self.boundingBoxLowerRight = []
# self.processedFlightsCount = 0
def __init__(self, target_date):
# Get current time in the right time-zone
tz = pytz.timezone('Europe/Paris')
self.targetDate = str(target_date)
self.script_start_time = datetime.now(tz)
self.startDate = str(self.script_start_time)
self.endDate = None
self.script_end_time = None
self.flightsCount = 0
self.processedFlightsCount = 0
self.thermalsCount = 0
def setEndTime(self, script_end_time):
if self.endDate is None:
self.endDate = str(script_end_time)
self.duration = str(script_end_time - self.script_start_time)
def toJSON(self):
self.script_start_time = str(self.script_start_time)
self.script_end_time = str(self.endDate)
return json.dumps(self, default=lambda o: o.__dict__, sort_keys=True)
def to_json(self):
self.script_start_time = str(self.script_start_time)
self.script_end_time = str(self.endDate)
return self.__dict__