panopticon-cli 1.1.2__tar.gz → 1.1.3__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.
- {panopticon_cli-1.1.2/panopticon_cli.egg-info → panopticon_cli-1.1.3}/PKG-INFO +1 -1
- {panopticon_cli-1.1.2 → panopticon_cli-1.1.3}/panopticon/cli.py +38 -6
- {panopticon_cli-1.1.2 → panopticon_cli-1.1.3/panopticon_cli.egg-info}/PKG-INFO +1 -1
- {panopticon_cli-1.1.2 → panopticon_cli-1.1.3}/pyproject.toml +1 -1
- {panopticon_cli-1.1.2 → panopticon_cli-1.1.3}/LICENSE +0 -0
- {panopticon_cli-1.1.2 → panopticon_cli-1.1.3}/README.md +0 -0
- {panopticon_cli-1.1.2 → panopticon_cli-1.1.3}/panopticon/__init__.py +0 -0
- {panopticon_cli-1.1.2 → panopticon_cli-1.1.3}/panopticon/memory.py +0 -0
- {panopticon_cli-1.1.2 → panopticon_cli-1.1.3}/panopticon/observer.py +0 -0
- {panopticon_cli-1.1.2 → panopticon_cli-1.1.3}/panopticon/policies.py +0 -0
- {panopticon_cli-1.1.2 → panopticon_cli-1.1.3}/panopticon/sentinel.py +0 -0
- {panopticon_cli-1.1.2 → panopticon_cli-1.1.3}/panopticon_cli.egg-info/SOURCES.txt +0 -0
- {panopticon_cli-1.1.2 → panopticon_cli-1.1.3}/panopticon_cli.egg-info/dependency_links.txt +0 -0
- {panopticon_cli-1.1.2 → panopticon_cli-1.1.3}/panopticon_cli.egg-info/entry_points.txt +0 -0
- {panopticon_cli-1.1.2 → panopticon_cli-1.1.3}/panopticon_cli.egg-info/requires.txt +0 -0
- {panopticon_cli-1.1.2 → panopticon_cli-1.1.3}/panopticon_cli.egg-info/top_level.txt +0 -0
- {panopticon_cli-1.1.2 → panopticon_cli-1.1.3}/setup.cfg +0 -0
- {panopticon_cli-1.1.2 → panopticon_cli-1.1.3}/tests/test_cli.py +0 -0
- {panopticon_cli-1.1.2 → panopticon_cli-1.1.3}/tests/test_memory.py +0 -0
- {panopticon_cli-1.1.2 → panopticon_cli-1.1.3}/tests/test_observer.py +0 -0
- {panopticon_cli-1.1.2 → panopticon_cli-1.1.3}/tests/test_policies.py +0 -0
- {panopticon_cli-1.1.2 → panopticon_cli-1.1.3}/tests/test_sentinel.py +0 -0
|
@@ -36,7 +36,7 @@ class CLIWrapper:
|
|
|
36
36
|
self.running = False
|
|
37
37
|
self.lock = threading.Lock()
|
|
38
38
|
self.threads = []
|
|
39
|
-
self.
|
|
39
|
+
self._stop_event = threading.Event()
|
|
40
40
|
|
|
41
41
|
def run(self):
|
|
42
42
|
self.running = True
|
|
@@ -61,15 +61,15 @@ class CLIWrapper:
|
|
|
61
61
|
env=env,
|
|
62
62
|
)
|
|
63
63
|
|
|
64
|
-
t_out = threading.Thread(target=self._read_stdout
|
|
64
|
+
t_out = threading.Thread(target=self._read_stdout)
|
|
65
65
|
t_out.start()
|
|
66
66
|
self.threads.append(t_out)
|
|
67
67
|
|
|
68
|
-
t_eval = threading.Thread(target=self._eval_loop
|
|
68
|
+
t_eval = threading.Thread(target=self._eval_loop)
|
|
69
69
|
t_eval.start()
|
|
70
70
|
self.threads.append(t_eval)
|
|
71
71
|
|
|
72
|
-
t_in = threading.Thread(target=self._read_stdin
|
|
72
|
+
t_in = threading.Thread(target=self._read_stdin)
|
|
73
73
|
t_in.start()
|
|
74
74
|
self.threads.append(t_in)
|
|
75
75
|
|
|
@@ -87,6 +87,7 @@ class CLIWrapper:
|
|
|
87
87
|
def _cleanup(self):
|
|
88
88
|
"""Cleanly shutdown all threads and resources."""
|
|
89
89
|
self.running = False
|
|
90
|
+
self._stop_event.set()
|
|
90
91
|
|
|
91
92
|
# Close subprocess pipes FIRST before thread cleanup
|
|
92
93
|
if self.process:
|
|
@@ -117,6 +118,24 @@ class CLIWrapper:
|
|
|
117
118
|
if thread.is_alive():
|
|
118
119
|
thread.join(timeout=1)
|
|
119
120
|
|
|
121
|
+
def _stdin_ready(self) -> bool:
|
|
122
|
+
stdin_obj = sys.stdin
|
|
123
|
+
if sys.platform == "win32":
|
|
124
|
+
try:
|
|
125
|
+
import msvcrt
|
|
126
|
+
except ImportError:
|
|
127
|
+
pass
|
|
128
|
+
else:
|
|
129
|
+
if stdin_obj.isatty():
|
|
130
|
+
return msvcrt.kbhit()
|
|
131
|
+
|
|
132
|
+
try:
|
|
133
|
+
import select
|
|
134
|
+
|
|
135
|
+
return bool(select.select([stdin_obj], [], [], 0.1)[0])
|
|
136
|
+
except Exception:
|
|
137
|
+
return False
|
|
138
|
+
|
|
120
139
|
def _read_stdout(self):
|
|
121
140
|
# Flaw 2 Fix: Safely decode multi-byte UTF-8 emojis incrementally
|
|
122
141
|
decoder = codecs.getincrementaldecoder("utf-8")(errors="replace")
|
|
@@ -151,10 +170,23 @@ class CLIWrapper:
|
|
|
151
170
|
pass
|
|
152
171
|
|
|
153
172
|
def _read_stdin(self):
|
|
173
|
+
stdin_buffer = getattr(sys.stdin, "buffer", None)
|
|
174
|
+
if stdin_buffer is None:
|
|
175
|
+
return
|
|
176
|
+
|
|
154
177
|
try:
|
|
155
|
-
while
|
|
178
|
+
while (
|
|
179
|
+
self.running
|
|
180
|
+
and self.process
|
|
181
|
+
and self.process.poll() is None
|
|
182
|
+
and not self._stop_event.is_set()
|
|
183
|
+
):
|
|
184
|
+
if not self._stdin_ready():
|
|
185
|
+
time.sleep(0.1)
|
|
186
|
+
continue
|
|
187
|
+
|
|
156
188
|
try:
|
|
157
|
-
data =
|
|
189
|
+
data = stdin_buffer.read1(1024)
|
|
158
190
|
if not data:
|
|
159
191
|
break
|
|
160
192
|
if self.process.stdin and not self.process.stdin.closed:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|