prim-ctrl 0.8.4__tar.gz → 0.8.6__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: prim-ctrl
3
- Version: 0.8.4
3
+ Version: 0.8.6
4
4
  Summary: Primitive Ctrl - Remote control of your phone's Primitive FTPd Android SFTP server and optionally Tailscale VPN.
5
5
  License-Expression: Apache-2.0
6
6
  License-File: LICENSE
@@ -112,6 +112,8 @@ Optionally, if you want to edit or even contribute to the source, you also need
112
112
  - Configuration tab
113
113
  - UI
114
114
  - Show notification to start/stop server(s): disable - this is necessary to determine whether Primitive FTPd is running on the phone or not, because the Automate flow determines whether the server is started with checking the existence of it's notification, and if the notification is always shown, that would make it false positive; please use another way, eg. a Quick Settings Tile to start/stop the server manually
115
+ - System
116
+ - Enable Tasker: enable
115
117
 
116
118
  ### Tailscale VPN (optional)
117
119
 
@@ -91,6 +91,8 @@ Optionally, if you want to edit or even contribute to the source, you also need
91
91
  - Configuration tab
92
92
  - UI
93
93
  - Show notification to start/stop server(s): disable - this is necessary to determine whether Primitive FTPd is running on the phone or not, because the Automate flow determines whether the server is started with checking the existence of it's notification, and if the notification is always shown, that would make it false positive; please use another way, eg. a Quick Settings Tile to start/stop the server manually
94
+ - System
95
+ - Enable Tasker: enable
94
96
 
95
97
  ### Tailscale VPN (optional)
96
98
 
@@ -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.exitcode = 0
55
+ self.addHandler(logging.StreamHandler(sys.stderr))
56
+ self.configure()
50
57
 
51
- def prepare(self, timestamp: bool, silent: bool):
52
- handler = logging.StreamHandler(sys.stderr)
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.addHandler(handler)
71
- if self.level == logging.NOTSET:
72
- self.setLevel(logging.WARNING if silent else logging.INFO)
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 = Logger(Path(sys.argv[0]).name)
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
- if args.debug:
1172
- logger.setLevel(logging.DEBUG)
1173
- logger.prepare(args.timestamp or args.debug, args.silent)
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.4"
6
+ version = "0.8.6"
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