cgse-common 0.16.1__tar.gz → 0.16.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. {cgse_common-0.16.1 → cgse_common-0.16.2}/PKG-INFO +1 -1
  2. {cgse_common-0.16.1 → cgse_common-0.16.2}/pyproject.toml +1 -1
  3. {cgse_common-0.16.1 → cgse_common-0.16.2}/src/egse/env.py +9 -1
  4. {cgse_common-0.16.1 → cgse_common-0.16.2}/src/egse/system.py +24 -0
  5. {cgse_common-0.16.1 → cgse_common-0.16.2}/.gitignore +0 -0
  6. {cgse_common-0.16.1 → cgse_common-0.16.2}/README.md +0 -0
  7. {cgse_common-0.16.1 → cgse_common-0.16.2}/justfile +0 -0
  8. {cgse_common-0.16.1 → cgse_common-0.16.2}/noxfile.py +0 -0
  9. {cgse_common-0.16.1 → cgse_common-0.16.2}/service_registry.db +0 -0
  10. {cgse_common-0.16.1 → cgse_common-0.16.2}/src/cgse_common/__init__.py +0 -0
  11. {cgse_common-0.16.1 → cgse_common-0.16.2}/src/cgse_common/cgse.py +0 -0
  12. {cgse_common-0.16.1 → cgse_common-0.16.2}/src/cgse_common/settings.yaml +0 -0
  13. {cgse_common-0.16.1 → cgse_common-0.16.2}/src/egse/bits.py +0 -0
  14. {cgse_common-0.16.1 → cgse_common-0.16.2}/src/egse/calibration.py +0 -0
  15. {cgse_common-0.16.1 → cgse_common-0.16.2}/src/egse/config.py +0 -0
  16. {cgse_common-0.16.1 → cgse_common-0.16.2}/src/egse/counter.py +0 -0
  17. {cgse_common-0.16.1 → cgse_common-0.16.2}/src/egse/decorators.py +0 -0
  18. {cgse_common-0.16.1 → cgse_common-0.16.2}/src/egse/device.py +0 -0
  19. {cgse_common-0.16.1 → cgse_common-0.16.2}/src/egse/dicts.py +0 -0
  20. {cgse_common-0.16.1 → cgse_common-0.16.2}/src/egse/exceptions.py +0 -0
  21. {cgse_common-0.16.1 → cgse_common-0.16.2}/src/egse/heartbeat.py +0 -0
  22. {cgse_common-0.16.1 → cgse_common-0.16.2}/src/egse/hk.py +0 -0
  23. {cgse_common-0.16.1 → cgse_common-0.16.2}/src/egse/log.py +0 -0
  24. {cgse_common-0.16.1 → cgse_common-0.16.2}/src/egse/metrics.py +0 -0
  25. {cgse_common-0.16.1 → cgse_common-0.16.2}/src/egse/observer.py +0 -0
  26. {cgse_common-0.16.1 → cgse_common-0.16.2}/src/egse/obsid.py +0 -0
  27. {cgse_common-0.16.1 → cgse_common-0.16.2}/src/egse/persistence.py +0 -0
  28. {cgse_common-0.16.1 → cgse_common-0.16.2}/src/egse/plugin.py +0 -0
  29. {cgse_common-0.16.1 → cgse_common-0.16.2}/src/egse/plugins/metrics/duckdb.py +0 -0
  30. {cgse_common-0.16.1 → cgse_common-0.16.2}/src/egse/plugins/metrics/influxdb.py +0 -0
  31. {cgse_common-0.16.1 → cgse_common-0.16.2}/src/egse/plugins/metrics/timescaledb.py +0 -0
  32. {cgse_common-0.16.1 → cgse_common-0.16.2}/src/egse/process.py +0 -0
  33. {cgse_common-0.16.1 → cgse_common-0.16.2}/src/egse/py.typed +0 -0
  34. {cgse_common-0.16.1 → cgse_common-0.16.2}/src/egse/randomwalk.py +0 -0
  35. {cgse_common-0.16.1 → cgse_common-0.16.2}/src/egse/ratelimit.py +0 -0
  36. {cgse_common-0.16.1 → cgse_common-0.16.2}/src/egse/reload.py +0 -0
  37. {cgse_common-0.16.1 → cgse_common-0.16.2}/src/egse/resource.py +0 -0
  38. {cgse_common-0.16.1 → cgse_common-0.16.2}/src/egse/response.py +0 -0
  39. {cgse_common-0.16.1 → cgse_common-0.16.2}/src/egse/scpi.py +0 -0
  40. {cgse_common-0.16.1 → cgse_common-0.16.2}/src/egse/settings.py +0 -0
  41. {cgse_common-0.16.1 → cgse_common-0.16.2}/src/egse/settings.yaml +0 -0
  42. {cgse_common-0.16.1 → cgse_common-0.16.2}/src/egse/setup.py +0 -0
  43. {cgse_common-0.16.1 → cgse_common-0.16.2}/src/egse/signal.py +0 -0
  44. {cgse_common-0.16.1 → cgse_common-0.16.2}/src/egse/socketdevice.py +0 -0
  45. {cgse_common-0.16.1 → cgse_common-0.16.2}/src/egse/state.py +0 -0
  46. {cgse_common-0.16.1 → cgse_common-0.16.2}/src/egse/task.py +0 -0
  47. {cgse_common-0.16.1 → cgse_common-0.16.2}/src/egse/version.py +0 -0
  48. {cgse_common-0.16.1 → cgse_common-0.16.2}/src/egse/zmq_ser.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cgse-common
3
- Version: 0.16.1
3
+ Version: 0.16.2
4
4
  Summary: Software framework to support hardware testing
5
5
  Author: IvS KU Leuven
6
6
  Maintainer-email: Rik Huygen <rik.huygen@kuleuven.be>, Sara Regibo <sara.regibo@kuleuven.be>
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "cgse-common"
3
- version = "0.16.1"
3
+ version = "0.16.2"
4
4
  description = "Software framework to support hardware testing"
5
5
  authors = [
6
6
  {name = "IvS KU Leuven"}
@@ -384,7 +384,7 @@ def set_log_file_location(location: str | Path | None):
384
384
  _env.set("LOG_FILE_LOCATION", location)
385
385
 
386
386
 
387
- def get_log_file_location(site_id: str = None) -> str:
387
+ def get_log_file_location(site_id: str = None, check_exists: bool = False) -> str:
388
388
  """
389
389
  Returns the full path of the location of the log files. The log file location is read from the environment
390
390
  variable `${PROJECT}_LOG_FILE_LOCATION`. The location shall be independent of any setting that is subject to change.
@@ -392,8 +392,12 @@ def get_log_file_location(site_id: str = None) -> str:
392
392
  If the environment variable is not set, a default log file location is created from the data storage location as
393
393
  follows: `<PROJECT>_DATA_STORAGE_LOCATION/<SITE_ID>/log`.
394
394
 
395
+ There is no check for the existence of the returned location. The caller function shall check if the
396
+ returned value is a directory and if it exists.
397
+
395
398
  Args:
396
399
  site_id: the site identifier
400
+ check_exists: check if the location that will be returned is a directory and exists
397
401
 
398
402
  Returns:
399
403
  The full path of location of the log files as a string.
@@ -417,6 +421,10 @@ def get_log_file_location(site_id: str = None) -> str:
417
421
  data_root = data_root.rstrip("/")
418
422
  log_data_root = f"{data_root}/log"
419
423
 
424
+ if check_exists:
425
+ if not Path(log_data_root).is_dir():
426
+ raise ValueError(f"The location that was constructed doesn't exist: {log_data_root}")
427
+
420
428
  return log_data_root
421
429
 
422
430
 
@@ -48,6 +48,7 @@ from typing import Callable
48
48
  from typing import Iterable
49
49
  from typing import List
50
50
  from typing import Optional
51
+ from typing import TextIO
51
52
  from typing import Tuple
52
53
  from typing import Type
53
54
  from typing import Union
@@ -60,6 +61,7 @@ from rich.tree import Tree
60
61
  from typer.core import TyperCommand
61
62
 
62
63
  import signal
64
+ from egse.env import get_log_file_location
63
65
  from egse.log import logger
64
66
 
65
67
  EPOCH_1958_1970 = 378691200
@@ -2307,6 +2309,28 @@ def caffeinate(pid: int = None):
2307
2309
  subprocess.Popen([shutil.which("caffeinate"), "-i", "-w", str(pid)])
2308
2310
 
2309
2311
 
2312
+ def redirect_output_to_log(output_fn: str, append: bool = False) -> TextIO:
2313
+ """
2314
+ Open file in the log folder where process output will be redirected.
2315
+
2316
+ When no location can be determined, the user's home directory will be used.
2317
+
2318
+ The file is opened in text mode at the given location and the stream (file descriptor) will be returned.
2319
+ """
2320
+
2321
+ try:
2322
+ location = get_log_file_location()
2323
+ output_path = Path(location, output_fn).expanduser()
2324
+ except ValueError:
2325
+ output_path = Path.home() / output_fn
2326
+
2327
+ out = open(output_path, "a" if append else "w")
2328
+
2329
+ logger.info(f"Output will be redirected to {output_path!s}")
2330
+
2331
+ return out
2332
+
2333
+
2310
2334
  ignore_m_warning("egse.system")
2311
2335
 
2312
2336
  if __name__ == "__main__":
File without changes
File without changes
File without changes
File without changes