zscams 2.0.11__py3-none-any.whl → 2.0.12__py3-none-any.whl

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.
@@ -3,8 +3,9 @@ Configuration loader module
3
3
  """
4
4
 
5
5
  import os
6
+ import sys
6
7
  from pathlib import Path
7
- from typing import Optional, Type, TypedDict, cast
8
+ from typing import Optional, Type, TypeVar, TypedDict, cast
8
9
  import yaml
9
10
 
10
11
  import zscams
@@ -13,6 +14,8 @@ from zscams.agent.src.support.yaml import YamlIndentedListsDumper, resolve_place
13
14
  ROOT_PATH = Path(zscams.__file__).resolve().parent.joinpath("agent")
14
15
  CONFIG_PATH = os.path.join(ROOT_PATH.absolute(), "config.yaml")
15
16
 
17
+ GetReturnT = TypeVar("T")
18
+
16
19
 
17
20
  class MissingConfiguration(BaseException):
18
21
  """Error when the requisted key is not found"""
@@ -33,8 +36,14 @@ class Configuration:
33
36
  return cls.__instance
34
37
 
35
38
  def __load_config(self):
36
- with open(CONFIG_PATH, "r", encoding="utf-8") as f:
37
- self.__config = yaml.safe_load(f)
39
+ try:
40
+ with open(CONFIG_PATH, "r", encoding="utf-8") as f:
41
+ self.__config = yaml.safe_load(f)
42
+ except FileNotFoundError:
43
+ print(
44
+ f"Can't find configurations file. Make sure you have it by running `cp '{ROOT_PATH.joinpath('configuration/config.j2')}' '{CONFIG_PATH}'`",
45
+ )
46
+ sys.exit(1)
38
47
 
39
48
  def override_config(self, new_config: dict):
40
49
  """
@@ -56,13 +65,13 @@ class Configuration:
56
65
  def to_dict(self):
57
66
  return self.__config
58
67
 
59
- def get[T](
68
+ def get(
60
69
  self,
61
70
  key: str,
62
- default: Optional[T] = None,
71
+ default: Optional[GetReturnT] = None,
63
72
  must_resolve=False,
64
- valtyp: Type[T] = str,
65
- ) -> T:
73
+ valtyp: Type[GetReturnT] = str,
74
+ ) -> GetReturnT:
66
75
  """
67
76
  Returns the configuration value.
68
77
 
@@ -90,7 +99,7 @@ class Configuration:
90
99
  val = None
91
100
  break
92
101
 
93
- return cast(T, val)
102
+ return cast(GetReturnT, val)
94
103
 
95
104
  def has(self, key: str):
96
105
  try:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: zscams
3
- Version: 2.0.11
3
+ Version: 2.0.12
4
4
  Summary: Async TLS tunnel client with SNI routing, auto-reconnect, and health checks
5
5
  Author: OCD - Cairo Software Team
6
6
  Maintainer: OCD - Cairo Software Team
@@ -25,7 +25,7 @@ zscams/agent/src/services/ssh_forwarder.py,sha256=vl3afyWxvYu114o5PTQpg3aok9oaLd
25
25
  zscams/agent/src/services/system_monitor.py,sha256=caGexjOD0eH7GVDdQQIBdTlMpYema_YIUEo3F-fG1vM,7526
26
26
  zscams/agent/src/support/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
27
  zscams/agent/src/support/cli.py,sha256=QexHTsEFSRy3AY-29m0Q-0msL4fxooRUJdIN0vAT_WI,3641
28
- zscams/agent/src/support/configuration.py,sha256=cczrJhxnA5GCc7gNcQorJNcUUr0v7HXagYJsHGps8T4,3413
28
+ zscams/agent/src/support/configuration.py,sha256=3jGtXdGBPE2zKfMb2T85837YJOHTALhP_r8W__ej7qs,3761
29
29
  zscams/agent/src/support/filesystem.py,sha256=e2p2xWxitLkTclyVgmDC-2DGROBwowves7dlm0S47Hw,1719
30
30
  zscams/agent/src/support/logger.py,sha256=cKmCqy2dSOJk7kivs9QPyop7bLa71619ODNylS27z6M,2345
31
31
  zscams/agent/src/support/mac.py,sha256=XVKc5YAYLu4a-5VrMhcwgkMNnP2u6itK3cx-Oxnx4IA,453
@@ -35,7 +35,7 @@ zscams/agent/src/support/os.py,sha256=EhDy5mMyZsDFK_eL_qot5l2e94r3RODVLh2eX2BvON
35
35
  zscams/agent/src/support/ssh.py,sha256=5qJpKIIiidG1r9AMeAIfb4c4eGOV4MExSVmQUgAuVzs,747
36
36
  zscams/agent/src/support/yaml.py,sha256=7NXPqj-v_RUif3fLfErNwSUJ-Y-so0GCFZ5aIiU96GQ,1192
37
37
  zscams/deps.py,sha256=9xbpgq77oTch-Nv_99QQtkyO3a96JxqFjUH_2d5zt4Q,3575
38
- zscams-2.0.11.dist-info/METADATA,sha256=9-9YkmfWWcJbGchpa1GLDls22P9k86E0gCoRyBV2Fy8,6806
39
- zscams-2.0.11.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
40
- zscams-2.0.11.dist-info/entry_points.txt,sha256=IXiMYjEq4q0tUiD9O7eCWhqKBuOssXrMW42siTBAgG8,47
41
- zscams-2.0.11.dist-info/RECORD,,
38
+ zscams-2.0.12.dist-info/METADATA,sha256=ChVB7wedYEAGnl3H8u2Qzor8OxKStTpov5oVeWuyFZY,6806
39
+ zscams-2.0.12.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
40
+ zscams-2.0.12.dist-info/entry_points.txt,sha256=IXiMYjEq4q0tUiD9O7eCWhqKBuOssXrMW42siTBAgG8,47
41
+ zscams-2.0.12.dist-info/RECORD,,