prim-ctrl 0.8.4__tar.gz → 0.8.5__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.
- {prim_ctrl-0.8.4 → prim_ctrl-0.8.5}/PKG-INFO +1 -1
- {prim_ctrl-0.8.4 → prim_ctrl-0.8.5}/prim_ctrl/__main__.py +27 -12
- {prim_ctrl-0.8.4 → prim_ctrl-0.8.5}/pyproject.toml +1 -1
- {prim_ctrl-0.8.4 → prim_ctrl-0.8.5}/LICENSE +0 -0
- {prim_ctrl-0.8.4 → prim_ctrl-0.8.5}/README.md +0 -0
- {prim_ctrl-0.8.4 → prim_ctrl-0.8.5}/prim_ctrl/__init__.py +0 -0
|
@@ -44,13 +44,19 @@ class LevelFormatter(logging.Formatter):
|
|
|
44
44
|
return self.formatters.get(record.levelno, self.default_formatter).format(record)
|
|
45
45
|
|
|
46
46
|
class Logger(logging.Logger):
|
|
47
|
+
timestamp: bool = False
|
|
48
|
+
|
|
49
|
+
@staticmethod
|
|
50
|
+
def setConfiguration(timestamp: bool):
|
|
51
|
+
Logger.timestamp = timestamp
|
|
52
|
+
|
|
47
53
|
def __init__(self, name, level = logging.NOTSET):
|
|
48
54
|
super().__init__(name, level)
|
|
49
|
-
self.
|
|
55
|
+
self.addHandler(logging.StreamHandler(sys.stderr))
|
|
56
|
+
self.configure()
|
|
50
57
|
|
|
51
|
-
def
|
|
52
|
-
|
|
53
|
-
handler.setFormatter(
|
|
58
|
+
def configure(self):
|
|
59
|
+
formatter = (
|
|
54
60
|
LevelFormatter(
|
|
55
61
|
{
|
|
56
62
|
logging.WARNING: '%(asctime)s %(message)s',
|
|
@@ -58,7 +64,7 @@ class Logger(logging.Logger):
|
|
|
58
64
|
logging.DEBUG: '%(asctime)s %(levelname)s %(message)s',
|
|
59
65
|
},
|
|
60
66
|
'%(asctime)s %(name)s: %(levelname)s: %(message)s')
|
|
61
|
-
if timestamp else
|
|
67
|
+
if Logger.timestamp else
|
|
62
68
|
LevelFormatter(
|
|
63
69
|
{
|
|
64
70
|
logging.WARNING: '%(message)s',
|
|
@@ -67,9 +73,16 @@ class Logger(logging.Logger):
|
|
|
67
73
|
},
|
|
68
74
|
'%(name)s: %(levelname)s: %(message)s')
|
|
69
75
|
)
|
|
70
|
-
self.
|
|
71
|
-
|
|
72
|
-
|
|
76
|
+
for handler in self.handlers:
|
|
77
|
+
handler.setFormatter(formatter)
|
|
78
|
+
|
|
79
|
+
class MainLogger(Logger):
|
|
80
|
+
def __init__(self, name, level = logging.NOTSET):
|
|
81
|
+
super().__init__(name, level)
|
|
82
|
+
self.exitcode = 0
|
|
83
|
+
|
|
84
|
+
def setConfiguration(self, level: int):
|
|
85
|
+
self.setLevel(level)
|
|
73
86
|
|
|
74
87
|
def exception_or_error(self, e: Exception):
|
|
75
88
|
if self.level == logging.NOTSET or self.level == logging.DEBUG:
|
|
@@ -109,7 +122,7 @@ class LazyStr:
|
|
|
109
122
|
self.result = str(self.func)
|
|
110
123
|
return self.result
|
|
111
124
|
|
|
112
|
-
logger =
|
|
125
|
+
logger = MainLogger(Path(sys.argv[0]).name)
|
|
113
126
|
|
|
114
127
|
########
|
|
115
128
|
|
|
@@ -1168,9 +1181,11 @@ class Control:
|
|
|
1168
1181
|
|
|
1169
1182
|
@staticmethod
|
|
1170
1183
|
def prepare(args: argparse.Namespace):
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
logger.
|
|
1184
|
+
Logger.setConfiguration(args.timestamp or args.debug)
|
|
1185
|
+
logging.setLoggerClass(Logger)
|
|
1186
|
+
logger.setConfiguration(
|
|
1187
|
+
logging.DEBUG if args.debug else logging.WARNING if args.silent else logging.INFO) #NOSONAR(S3358)
|
|
1188
|
+
logger.configure()
|
|
1174
1189
|
|
|
1175
1190
|
if args.accept_cellular and args.intent != 'start':
|
|
1176
1191
|
raise ValueError("The --accept-cellular options can be enabled only for the start intent")
|
|
@@ -3,7 +3,7 @@ packages = [{include = "prim_ctrl"}]
|
|
|
3
3
|
|
|
4
4
|
[project]
|
|
5
5
|
name = "prim-ctrl"
|
|
6
|
-
version = "0.8.
|
|
6
|
+
version = "0.8.5"
|
|
7
7
|
description = "Primitive Ctrl - Remote control of your phone's Primitive FTPd Android SFTP server and optionally Tailscale VPN."
|
|
8
8
|
license = "Apache-2.0"
|
|
9
9
|
authors = [
|
|
File without changes
|
|
File without changes
|
|
File without changes
|