Commit f948c7ffaf81ebb0b58fe96b6947d67c910c6a80
1 parent
9eabdec5
Exists in
dev
MAJ novembre pour la 1.2
Showing
3 changed files
with
14 additions
and
13 deletions
Show diff stats
src/utils/celme/dates.py
... | ... | @@ -2,6 +2,7 @@ import datetime |
2 | 2 | import math |
3 | 3 | import doctest |
4 | 4 | import typing |
5 | +from typing import Union | |
5 | 6 | try: |
6 | 7 | from .durations import Duration |
7 | 8 | except: |
... | ... | @@ -73,7 +74,7 @@ class Date: |
73 | 74 | # === internal methods |
74 | 75 | # ======================================================== |
75 | 76 | |
76 | - def _init(self,date="") -> None: | |
77 | + def _init(self,date: Union[str, float] = "") -> None: | |
77 | 78 | """ Initialize internal attributes. |
78 | 79 | |
79 | 80 | :param date: date is a date in any supported format (cf. help(Date)) |
... | ... | @@ -1053,7 +1054,7 @@ class Date: |
1053 | 1054 | """ |
1054 | 1055 | return self + duration |
1055 | 1056 | |
1056 | - def __sub__(self, object_or_duration): | |
1057 | + def __sub__(self, object_or_duration: Union["Date", float]) -> "Date": | |
1057 | 1058 | """ Subtract a duration to a date (returns an object date) or Compute the duration between two date objects. |
1058 | 1059 | |
1059 | 1060 | Inputs: | ... | ... |
src/utils/report/doc/user_guide_module_report.odt
No preview for this file type
src/utils/report/status_json.py
... | ... | @@ -8,7 +8,7 @@ py_path = os.sys.path |
8 | 8 | py_pwd = os.getcwd() |
9 | 9 | if (py_pwd not in py_path): |
10 | 10 | (os.sys.path).append(py_pwd) |
11 | -py_pwd = os.getcwd() + "/.." | |
11 | +py_pwd = os.getcwd() + "/../.." | |
12 | 12 | if (py_pwd not in py_path): |
13 | 13 | (os.sys.path).append(py_pwd) |
14 | 14 | |
... | ... | @@ -31,7 +31,7 @@ Example a a very wimple Json file report contents: |
31 | 31 | "entities": [ |
32 | 32 | { |
33 | 33 | "entity_name": "PLC_STATUS", |
34 | - "from": "Raspberry", | |
34 | + "origin": "Raspberry", | |
35 | 35 | "version_firmware": "20180924A", |
36 | 36 | "site": "MyObservatory", |
37 | 37 | "date": "2018-09-25T22:24:16.387", |
... | ... | @@ -244,10 +244,10 @@ https://github.com/hjson/hjson-py |
244 | 244 | #self._status['statuses'].append(status_header) |
245 | 245 | self._status = status_header |
246 | 246 | |
247 | - def _status_new_entity(self, entity_name, thefrom, version_firmware, site, date=""): | |
247 | + def _status_new_entity(self, entity_name, theorigin, version_firmware, site, date=""): | |
248 | 248 | if date=="": |
249 | 249 | date = (celme.Date("now")).iso() |
250 | - entity= {'entity_name':entity_name, 'from':thefrom, 'version_firmware':version_firmware, 'site':site, 'date':date, 'devices':[]} | |
250 | + entity= {'entity_name':entity_name, 'origin':theorigin, 'version_firmware':version_firmware, 'site':site, 'date':date, 'devices':[]} | |
251 | 251 | #self._status['statuses'][0]['entities'].append(entity); |
252 | 252 | self._status['entities'].append(entity); |
253 | 253 | |
... | ... | @@ -260,7 +260,7 @@ https://github.com/hjson/hjson-py |
260 | 260 | #self._status['statuses'][0]['entities'][indicee]['devices'].append(device) |
261 | 261 | self._status['entities'][indicee]['devices'].append(device) |
262 | 262 | |
263 | - def _status_entity_device_new_value(self, entity_name, device_name, serial_number, name, thetype, value, unit="", monitoring_name="", comment=""): | |
263 | + def _status_entity_device_new_value(self, entity_name, device_name, serial_number, name, data_type, value, unit="", monitoring_name="", comment=""): | |
264 | 264 | entities = self._get_entity_names() |
265 | 265 | indicee = self._get_indice_from_entities(entities,entity_name) |
266 | 266 | if indicee == -1: |
... | ... | @@ -270,7 +270,7 @@ https://github.com/hjson/hjson-py |
270 | 270 | indiced = self._get_indice_from_devices(devices, device_name, serial_number) |
271 | 271 | if indiced == -1: |
272 | 272 | return "" |
273 | - dico = {'name':name, 'type':thetype, 'value':value, 'unit':unit, 'monitoring_name':monitoring_name, 'comment':comment} | |
273 | + dico = {'name':name, 'data_type':data_type, 'value':value, 'unit':unit, 'monitoring_name':monitoring_name, 'comment':comment} | |
274 | 274 | #self._status['statuses'][0]['entities'][indicee]['devices'][indiced]['device_values'].append(dico) |
275 | 275 | self._status['entities'][indicee]['devices'][indiced]['device_values'].append(dico) |
276 | 276 | |
... | ... | @@ -297,7 +297,7 @@ https://github.com/hjson/hjson-py |
297 | 297 | self._init() |
298 | 298 | self._status_new(name_creator, version_creator) |
299 | 299 | |
300 | - def append_entity(self, entity_name, thefrom, version_firmware, site, date=""): | |
300 | + def append_entity(self, entity_name, theorigin, version_firmware, site, date=""): | |
301 | 301 | """ Append a new entity to a creator |
302 | 302 | |
303 | 303 | Inputs: |
... | ... | @@ -314,7 +314,7 @@ https://github.com/hjson/hjson-py |
314 | 314 | --------------- |
315 | 315 | Methods append_device, get_entities |
316 | 316 | """ |
317 | - self._status_new_entity(entity_name, thefrom, version_firmware, site, date) | |
317 | + self._status_new_entity(entity_name, theorigin, version_firmware, site, date) | |
318 | 318 | self._entity_name = entity_name |
319 | 319 | |
320 | 320 | def append_device(self, device_name, device_type, serial_number, error_code): |
... | ... | @@ -340,7 +340,7 @@ https://github.com/hjson/hjson-py |
340 | 340 | self._device_name = device_name |
341 | 341 | self._serial_number = serial_number |
342 | 342 | |
343 | - def append_value(self, name, thetype, value, unit="", monitoring_name="", comment=""): | |
343 | + def append_value(self, name, data_type, value, unit="", monitoring_name="", comment=""): | |
344 | 344 | """ Append a new value to a device |
345 | 345 | |
346 | 346 | Inputs: |
... | ... | @@ -362,7 +362,7 @@ https://github.com/hjson/hjson-py |
362 | 362 | entity_name = self._entity_name |
363 | 363 | device_name = self._device_name |
364 | 364 | serial_number = self._serial_number |
365 | - self._status_entity_device_new_value(entity_name, device_name, serial_number, name, thetype, value, unit, monitoring_name, comment) | |
365 | + self._status_entity_device_new_value(entity_name, device_name, serial_number, name, data_type, value, unit, monitoring_name, comment) | |
366 | 366 | |
367 | 367 | def load_json(self, full_filename): |
368 | 368 | """ Load a Json file as an object |
... | ... | @@ -667,6 +667,6 @@ if __name__ == "__main__": |
667 | 667 | res = rep.get_devices() |
668 | 668 | print(" devices = {}".format(res)) |
669 | 669 | print(" List of all UFKIs:") |
670 | - ufiks = rep.get_values("","",False) | |
670 | + ufiks = rep.get_values("","",True) | |
671 | 671 | for ufik in ufiks: |
672 | 672 | print(" UFKI = {}".format(ufik)) | ... | ... |