python4cpm 1.1.7__py3-none-any.whl → 1.1.8__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.
- python4cpm/accounts.py +5 -5
- python4cpm/exithandler.py +27 -0
- python4cpm/{logger.py → loggerhandler.py} +7 -1
- python4cpm/python4cpm.py +6 -15
- python4cpm/{secret.py → secrets.py} +11 -3
- {python4cpm-1.1.7.dist-info → python4cpm-1.1.8.dist-info}/METADATA +1 -1
- python4cpm-1.1.8.dist-info/RECORD +16 -0
- python4cpm-1.1.7.dist-info/RECORD +0 -15
- {python4cpm-1.1.7.dist-info → python4cpm-1.1.8.dist-info}/WHEEL +0 -0
- {python4cpm-1.1.7.dist-info → python4cpm-1.1.8.dist-info}/licenses/LICENSE +0 -0
- {python4cpm-1.1.7.dist-info → python4cpm-1.1.8.dist-info}/top_level.txt +0 -0
python4cpm/accounts.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from python4cpm.envhandler import EnvHandler, Props
|
|
2
|
-
from python4cpm.
|
|
2
|
+
from python4cpm.secrets import Password, NewPassword
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
class BaseAccount(EnvHandler):
|
|
@@ -11,7 +11,7 @@ class BaseAccount(EnvHandler):
|
|
|
11
11
|
password: str | None
|
|
12
12
|
) -> None:
|
|
13
13
|
self._username = username
|
|
14
|
-
self._password =
|
|
14
|
+
self._password = Password.from_env_var(password)
|
|
15
15
|
|
|
16
16
|
@classmethod
|
|
17
17
|
def get(cls) -> object | None:
|
|
@@ -25,7 +25,7 @@ class BaseAccount(EnvHandler):
|
|
|
25
25
|
return self._username
|
|
26
26
|
|
|
27
27
|
@property
|
|
28
|
-
def password(self) ->
|
|
28
|
+
def password(self) -> Password:
|
|
29
29
|
return self._password
|
|
30
30
|
|
|
31
31
|
|
|
@@ -62,7 +62,7 @@ class TargetAccount(BaseAccount):
|
|
|
62
62
|
self._object_name = object_name
|
|
63
63
|
self._address = address
|
|
64
64
|
self._port = port
|
|
65
|
-
self._new_password =
|
|
65
|
+
self._new_password = NewPassword.from_env_var(new_password)
|
|
66
66
|
|
|
67
67
|
@property
|
|
68
68
|
def policy_id(self) -> str | None:
|
|
@@ -85,7 +85,7 @@ class TargetAccount(BaseAccount):
|
|
|
85
85
|
return self._port
|
|
86
86
|
|
|
87
87
|
@property
|
|
88
|
-
def new_password(self) ->
|
|
88
|
+
def new_password(self) -> NewPassword:
|
|
89
89
|
return self._new_password
|
|
90
90
|
|
|
91
91
|
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
from python4cpm.loggerhandler import LoggerHandler
|
|
2
|
+
import atexit
|
|
3
|
+
import sys
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class ExitHandler:
|
|
7
|
+
_ERROR_MESSAGE = "No close signal called"
|
|
8
|
+
_closed = False
|
|
9
|
+
|
|
10
|
+
@classmethod
|
|
11
|
+
def reset(cls) -> None:
|
|
12
|
+
cls._closed = False
|
|
13
|
+
|
|
14
|
+
@classmethod
|
|
15
|
+
def set_closed(cls) -> None:
|
|
16
|
+
cls._closed = True
|
|
17
|
+
|
|
18
|
+
@classmethod
|
|
19
|
+
def on_exit(cls) -> None:
|
|
20
|
+
if cls._closed is False:
|
|
21
|
+
for logger in LoggerHandler.get_all_loggers():
|
|
22
|
+
logger.error(cls._ERROR_MESSAGE)
|
|
23
|
+
sys.stderr.write(cls._ERROR_MESSAGE)
|
|
24
|
+
sys.stderr.flush()
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
atexit.register(ExitHandler.on_exit)
|
|
@@ -3,7 +3,7 @@ import logging
|
|
|
3
3
|
from logging.handlers import RotatingFileHandler
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
class
|
|
6
|
+
class LoggerHandler:
|
|
7
7
|
_LOGS_DIR = os.path.join("Logs", "ThirdParty")
|
|
8
8
|
_LOGGING_LEVELS = {
|
|
9
9
|
"critical": logging.CRITICAL,
|
|
@@ -13,6 +13,7 @@ class Logger:
|
|
|
13
13
|
"debug": logging.DEBUG
|
|
14
14
|
}
|
|
15
15
|
_DEFAULT_LEVEL = "error"
|
|
16
|
+
_all_loggers = []
|
|
16
17
|
|
|
17
18
|
@classmethod
|
|
18
19
|
def get_logger(
|
|
@@ -42,4 +43,9 @@ class Logger:
|
|
|
42
43
|
formatter = logging.Formatter(fmt=fmt, datefmt=datefmt)
|
|
43
44
|
handler.setFormatter(formatter)
|
|
44
45
|
logger.addHandler(handler)
|
|
46
|
+
cls._all_loggers.append(logger)
|
|
45
47
|
return logger
|
|
48
|
+
|
|
49
|
+
@classmethod
|
|
50
|
+
def get_all_loggers(cls):
|
|
51
|
+
return cls._all_loggers
|
python4cpm/python4cpm.py
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import sys
|
|
2
|
-
import atexit
|
|
3
2
|
import logging
|
|
4
|
-
from python4cpm.
|
|
3
|
+
from python4cpm.secrets import Secret
|
|
5
4
|
from python4cpm.args import Args
|
|
6
|
-
from python4cpm.
|
|
5
|
+
from python4cpm.loggerhandler import LoggerHandler
|
|
7
6
|
from python4cpm.accounts import TargetAccount, LogonAccount, ReconcileAccount
|
|
7
|
+
from python4cpm.exithandler import ExitHandler
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
class Python4CPM:
|
|
@@ -36,8 +36,6 @@ class Python4CPM:
|
|
|
36
36
|
self._log_obj(self._target_account)
|
|
37
37
|
self._log_obj(self._logon_account)
|
|
38
38
|
self._log_obj(self._reconcile_account)
|
|
39
|
-
self._closed = False
|
|
40
|
-
atexit.register(self._on_exit)
|
|
41
39
|
|
|
42
40
|
@property
|
|
43
41
|
def args(self) -> Args:
|
|
@@ -66,7 +64,7 @@ class Python4CPM:
|
|
|
66
64
|
self._target_account.object_name
|
|
67
65
|
)
|
|
68
66
|
name = "-".join(name_parts)
|
|
69
|
-
return
|
|
67
|
+
return LoggerHandler.get_logger(name, self._args.logging_level)
|
|
70
68
|
|
|
71
69
|
def _verify_action(self) -> None:
|
|
72
70
|
if self._args.action not in self._VALID_ACTIONS:
|
|
@@ -91,17 +89,10 @@ class Python4CPM:
|
|
|
91
89
|
else:
|
|
92
90
|
code = self._FAILED_UNRECOVERABLE_CODE
|
|
93
91
|
self._logger.error(f"Closing with code {code}")
|
|
94
|
-
|
|
92
|
+
ExitHandler.set_closed()
|
|
95
93
|
sys.exit(code)
|
|
96
94
|
|
|
97
95
|
def close_success(self) -> None:
|
|
98
96
|
self._logger.debug(f"Closing with code {self._SUCCESS_CODE}")
|
|
99
|
-
|
|
97
|
+
ExitHandler.set_closed()
|
|
100
98
|
sys.exit(self._SUCCESS_CODE)
|
|
101
|
-
|
|
102
|
-
def _on_exit(self):
|
|
103
|
-
if self._closed is False:
|
|
104
|
-
message = "No close signal called"
|
|
105
|
-
self._logger.error(message)
|
|
106
|
-
sys.stderr.write(message)
|
|
107
|
-
sys.stderr.flush()
|
|
@@ -3,7 +3,7 @@ from python4cpm.crypto import Crypto
|
|
|
3
3
|
|
|
4
4
|
class Secret:
|
|
5
5
|
def __init__(self, secret: str) -> None:
|
|
6
|
-
self.
|
|
6
|
+
self._value = secret
|
|
7
7
|
|
|
8
8
|
@classmethod
|
|
9
9
|
def from_env_var(cls, secret: str | None) -> object | None:
|
|
@@ -18,5 +18,13 @@ class Secret:
|
|
|
18
18
|
|
|
19
19
|
def get(self) -> str:
|
|
20
20
|
if Crypto.ENABLED:
|
|
21
|
-
return Crypto.decrypt(self.
|
|
22
|
-
return self.
|
|
21
|
+
return Crypto.decrypt(self._value)
|
|
22
|
+
return self._value
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class Password(Secret):
|
|
26
|
+
pass
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class NewPassword(Secret):
|
|
30
|
+
pass
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
python4cpm/__init__.py,sha256=GQvsXZY2escF3zucv3d68s2ydqHSIYi5tnNDCkhTjcM,302
|
|
2
|
+
python4cpm/accounts.py,sha256=MSRcHotQ_ITGCy02nNVkZyfxbBP31OIcH9PbRS9aUbo,2231
|
|
3
|
+
python4cpm/args.py,sha256=PQDDlMakP-YsDLd3HdwIZtxVpIM4m4aHl2GuRj9kHpI,504
|
|
4
|
+
python4cpm/crypto.py,sha256=FufZdKcm36-HYnSYrBGdADPVk2YmRPl0WDVZ29FfUU0,2337
|
|
5
|
+
python4cpm/devhelper.py,sha256=iv5zHSMyMNMdksGkkTh_8c_ObocJfQormQ4S3nZzo0Y,2609
|
|
6
|
+
python4cpm/envhandler.py,sha256=mNDOaYVemmxKREXyOf7IuQdFDXrvZ7f_7sNaqWV7TsI,678
|
|
7
|
+
python4cpm/exithandler.py,sha256=en_Xy8cnRk5w6xOuQgkxipLSyRWrB3AEZfhoc9T1Cvg,623
|
|
8
|
+
python4cpm/loggerhandler.py,sha256=OrFayXn2VENO2bm0hNmlrBH_Bc_ew8WYxSICuFPr91g,1610
|
|
9
|
+
python4cpm/python4cpm.py,sha256=FD9HMWwN_MIhHTVvN4aj-q7Yr0nmpav3UMSNgRDjvK4,3228
|
|
10
|
+
python4cpm/python4cpmhandler.py,sha256=SXKsnFAwUp8cHEhv2TygpNpptUkN3bVQZt1i-3TWql4,935
|
|
11
|
+
python4cpm/secrets.py,sha256=ijY2t4gSuVZyfDSiGNSqjjNjIhSL4K4yhKrPF-DrGOs,606
|
|
12
|
+
python4cpm-1.1.8.dist-info/licenses/LICENSE,sha256=vF2wZA3GchZjH5lUmhonEwd4snuBc6o0ytpZNxVFyCw,1077
|
|
13
|
+
python4cpm-1.1.8.dist-info/METADATA,sha256=OCVXh-I7uT4aBuigzfq_nuv-jKPELgi6g6n8bFLaKXY,11193
|
|
14
|
+
python4cpm-1.1.8.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
15
|
+
python4cpm-1.1.8.dist-info/top_level.txt,sha256=EhbshwpANmL0wYXaET8_6V9ZENtSwIyAd-kM3jGhUlE,11
|
|
16
|
+
python4cpm-1.1.8.dist-info/RECORD,,
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
python4cpm/__init__.py,sha256=GQvsXZY2escF3zucv3d68s2ydqHSIYi5tnNDCkhTjcM,302
|
|
2
|
-
python4cpm/accounts.py,sha256=tzLr6kFeHD6jDF-dZXjp2FeoABFsWn2hp4bO5uYN2Zg,2201
|
|
3
|
-
python4cpm/args.py,sha256=PQDDlMakP-YsDLd3HdwIZtxVpIM4m4aHl2GuRj9kHpI,504
|
|
4
|
-
python4cpm/crypto.py,sha256=FufZdKcm36-HYnSYrBGdADPVk2YmRPl0WDVZ29FfUU0,2337
|
|
5
|
-
python4cpm/devhelper.py,sha256=iv5zHSMyMNMdksGkkTh_8c_ObocJfQormQ4S3nZzo0Y,2609
|
|
6
|
-
python4cpm/envhandler.py,sha256=mNDOaYVemmxKREXyOf7IuQdFDXrvZ7f_7sNaqWV7TsI,678
|
|
7
|
-
python4cpm/logger.py,sha256=66lkgsGsSyXJLeMfn8zq6DinTPJWRfFyMBiUYySM2Ec,1461
|
|
8
|
-
python4cpm/python4cpm.py,sha256=hkVKd_pEiCA7VPPSUgGFxJ_9sWb3p4GB-EJ034HLxfA,3446
|
|
9
|
-
python4cpm/python4cpmhandler.py,sha256=SXKsnFAwUp8cHEhv2TygpNpptUkN3bVQZt1i-3TWql4,935
|
|
10
|
-
python4cpm/secret.py,sha256=H3TUjhVN9uPPtr3BUaENEPG1odc3SJXj-u7wD-bCz58,536
|
|
11
|
-
python4cpm-1.1.7.dist-info/licenses/LICENSE,sha256=vF2wZA3GchZjH5lUmhonEwd4snuBc6o0ytpZNxVFyCw,1077
|
|
12
|
-
python4cpm-1.1.7.dist-info/METADATA,sha256=Kh0gEBT3OepZHxMrTGjQY9llpEprDnLAHBPP7_V4bFI,11193
|
|
13
|
-
python4cpm-1.1.7.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
14
|
-
python4cpm-1.1.7.dist-info/top_level.txt,sha256=EhbshwpANmL0wYXaET8_6V9ZENtSwIyAd-kM3jGhUlE,11
|
|
15
|
-
python4cpm-1.1.7.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|