pywebexec 1.6.10__py3-none-any.whl → 1.6.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.
- pywebexec/pywebexec.py +19 -8
- pywebexec/version.py +2 -2
- {pywebexec-1.6.10.dist-info → pywebexec-1.6.12.dist-info}/METADATA +2 -1
- {pywebexec-1.6.10.dist-info → pywebexec-1.6.12.dist-info}/RECORD +8 -8
- {pywebexec-1.6.10.dist-info → pywebexec-1.6.12.dist-info}/LICENSE +0 -0
- {pywebexec-1.6.10.dist-info → pywebexec-1.6.12.dist-info}/WHEEL +0 -0
- {pywebexec-1.6.10.dist-info → pywebexec-1.6.12.dist-info}/entry_points.txt +0 -0
- {pywebexec-1.6.10.dist-info → pywebexec-1.6.12.dist-info}/top_level.txt +0 -0
pywebexec/pywebexec.py
CHANGED
@@ -25,7 +25,7 @@ import termios
|
|
25
25
|
import struct
|
26
26
|
import subprocess
|
27
27
|
import logging
|
28
|
-
|
28
|
+
import pyte
|
29
29
|
|
30
30
|
if os.environ.get('PYWEBEXEC_LDAP_SERVER'):
|
31
31
|
from ldap3 import Server, Connection, ALL, SIMPLE, SUBTREE, Tls
|
@@ -181,8 +181,14 @@ class PyWebExec(Application):
|
|
181
181
|
def load(self):
|
182
182
|
return self.application
|
183
183
|
|
184
|
-
|
185
|
-
|
184
|
+
def get_visible_output(line):
|
185
|
+
screen = pyte.Screen(len(line)+1, 2)
|
186
|
+
stream = pyte.Stream(screen)
|
187
|
+
stream.feed(line)
|
188
|
+
visible_line = screen.display[0]
|
189
|
+
return visible_line
|
190
|
+
#38;2;66;59;165m
|
191
|
+
ANSI_ESCAPE = re.compile(br'(?:\x1B[@-Z\\-_]|\x1B([(]B|>)|(?:\x1B\[|\x9B)[0-?]*[ -/]*[@-~]|\x1B\[([0-9]{1,2};){0,4}[0-9]{1,3}[m|K]|\x1B\[[0-9;]*[mGKHF]|[\x00-\x1F\x7F])')
|
186
192
|
|
187
193
|
def strip_ansi_control_chars(text):
|
188
194
|
"""Remove ANSI and control characters from the text."""
|
@@ -192,7 +198,7 @@ def strip_ansi_control_chars(text):
|
|
192
198
|
def decode_line(line: bytes) -> str:
|
193
199
|
"""try decode line exception on binary"""
|
194
200
|
try:
|
195
|
-
return
|
201
|
+
return get_visible_output(line.decode()).strip(" ")
|
196
202
|
except UnicodeDecodeError:
|
197
203
|
return ""
|
198
204
|
|
@@ -216,6 +222,8 @@ def last_line(fd, maxsize=500):
|
|
216
222
|
break
|
217
223
|
last_pos = fd.tell()
|
218
224
|
line = decode_line(fd.readline())
|
225
|
+
if size == maxsize:
|
226
|
+
return ""
|
219
227
|
return line.strip()
|
220
228
|
|
221
229
|
|
@@ -330,11 +338,13 @@ def print_urls(command_id=None):
|
|
330
338
|
if token:
|
331
339
|
url_params = f"?token={token}"
|
332
340
|
if command_id:
|
333
|
-
print(f"{protocol}://{hostname}:{args.port}/dopopup/{command_id}{url_params}", flush=True)
|
334
|
-
print(f"{protocol}://{ip}:{args.port}/dopopup/{command_id}{url_params}", flush=True)
|
341
|
+
print(f"web popup: {protocol}://{hostname}:{args.port}/dopopup/{command_id}{url_params}", flush=True)
|
342
|
+
print(f"web popup: {protocol}://{ip}:{args.port}/dopopup/{command_id}{url_params}", flush=True)
|
343
|
+
print(f"raw output: {protocol}://{hostname}:{args.port}/command_output_raw/{command_id}{url_params}", flush=True)
|
344
|
+
print(f"raw output: {protocol}://{ip}:{args.port}/command_output_raw/{command_id}{url_params}", flush=True)
|
335
345
|
else:
|
336
|
-
print(f"{protocol}://{hostname}:{args.port}{url_params}", flush=True)
|
337
|
-
print(f"{protocol}://{ip}:{args.port}{url_params}", flush=True)
|
346
|
+
print(f"web commands: {protocol}://{hostname}:{args.port}{url_params}", flush=True)
|
347
|
+
print(f"web commands: {protocol}://{ip}:{args.port}{url_params}", flush=True)
|
338
348
|
|
339
349
|
|
340
350
|
def is_port_in_use(address, port):
|
@@ -813,6 +823,7 @@ def get_command_output_raw(command_id):
|
|
813
823
|
yield chunk
|
814
824
|
status = read_command_status(command_id)
|
815
825
|
if not status or status['status'] != 'running':
|
826
|
+
yield f"\nEnd of command {command_id} {status.get('status', '')} exit: {status.get('exit_code')}\n"
|
816
827
|
break
|
817
828
|
except GeneratorExit:
|
818
829
|
return
|
pywebexec/version.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: pywebexec
|
3
|
-
Version: 1.6.
|
3
|
+
Version: 1.6.12
|
4
4
|
Summary: Simple Python HTTP Exec Server
|
5
5
|
Home-page: https://github.com/joknarf/pywebexec
|
6
6
|
Author: Franck Jouvanceau
|
@@ -59,6 +59,7 @@ Requires-Dist: Flask-HTTPAuth>=4.8.0
|
|
59
59
|
Requires-Dist: pexpect>=4.9.0
|
60
60
|
Requires-Dist: gunicorn>=21.2.0
|
61
61
|
Requires-Dist: ldap3>=2.9.1
|
62
|
+
Requires-Dist: pyte>=0.8.1
|
62
63
|
|
63
64
|
[](https://pypi.org/project/pywebexec/)
|
64
65
|

|
@@ -1,6 +1,6 @@
|
|
1
1
|
pywebexec/__init__.py,sha256=4spIsVaF8RJt8S58AG_wWoORRNkws9Iwqprj27C3ljM,99
|
2
|
-
pywebexec/pywebexec.py,sha256=
|
3
|
-
pywebexec/version.py,sha256=
|
2
|
+
pywebexec/pywebexec.py,sha256=QUz8TzAfi8Oed3Nqsi0CLH0QA2arh-fpB9p5ASyo5DY,32934
|
3
|
+
pywebexec/version.py,sha256=dUu2OxelDtAMXjHtstu0l-dD_T_j4hfz4LAPXSgLBBc,413
|
4
4
|
pywebexec/static/css/Consolas NF.ttf,sha256=DJEOzF0eqZ-kxu3Gs_VE8X0NJqiobBzmxWDGpdgGRxI,1313900
|
5
5
|
pywebexec/static/css/style.css,sha256=MJHUBpjWL4sLxM7a7DxypmPKaFJQbmA_ESNXsbLviNI,8201
|
6
6
|
pywebexec/static/css/xterm.css,sha256=uo5phWaUiJgcz0DAzv46uoByLLbJLeetYosL1xf68rY,5559
|
@@ -33,9 +33,9 @@ pywebexec/static/js/xterm/xterm.js.map,sha256=Y7O2Pb-fIS7Z8AC1D5s04_aiW_Jf1f4mCf
|
|
33
33
|
pywebexec/templates/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
34
34
|
pywebexec/templates/index.html,sha256=5h8kLyzAhbvUDU9sEwrGIvD6FxAMcDZLXlN-ldlO8KU,2880
|
35
35
|
pywebexec/templates/popup.html,sha256=3ZqQcE9mYs-RXv0Lfb24zntOlvR137ZYI9mtCZNVAo0,1407
|
36
|
-
pywebexec-1.6.
|
37
|
-
pywebexec-1.6.
|
38
|
-
pywebexec-1.6.
|
39
|
-
pywebexec-1.6.
|
40
|
-
pywebexec-1.6.
|
41
|
-
pywebexec-1.6.
|
36
|
+
pywebexec-1.6.12.dist-info/LICENSE,sha256=gRJf0JPT_wsZJsUGlWPTS8Vypfl9vQ1qjp6sNbKykuA,1064
|
37
|
+
pywebexec-1.6.12.dist-info/METADATA,sha256=eEWP4ACcL7fYNW6RuMNaGbvZL5g85ESH35YdtzKSrL4,8001
|
38
|
+
pywebexec-1.6.12.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
39
|
+
pywebexec-1.6.12.dist-info/entry_points.txt,sha256=l52GBkPCXRkmlHfEyoVauyfBdg8o-CAtC8qQpOIjJK0,55
|
40
|
+
pywebexec-1.6.12.dist-info/top_level.txt,sha256=vHoHyzngrfGdm_nM7Xn_5iLmaCrf10XO1EhldgNLEQ8,10
|
41
|
+
pywebexec-1.6.12.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|