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 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
- ANSI_ESCAPE = re.compile(br'(?:\x1B[@-Z\\-_]|\x1B([(]B|>)|(?:\x1B\[|\x9B)[0-?]*[ -/]*[@-~]|\x1B\[[0-9]{1,2};[0-9]{1,2}[m|K]|\x1B\[[0-9;]*[mGKHF]|[\x00-\x1F\x7F])')
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 strip_ansi_control_chars(line).decode().strip(" ")
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
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '1.6.10'
16
- __version_tuple__ = version_tuple = (1, 6, 10)
15
+ __version__ = version = '1.6.12'
16
+ __version_tuple__ = version_tuple = (1, 6, 12)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: pywebexec
3
- Version: 1.6.10
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
  [![Pypi version](https://img.shields.io/pypi/v/pywebexec.svg)](https://pypi.org/project/pywebexec/)
64
65
  ![example](https://github.com/joknarf/pywebexec/actions/workflows/python-publish.yml/badge.svg)
@@ -1,6 +1,6 @@
1
1
  pywebexec/__init__.py,sha256=4spIsVaF8RJt8S58AG_wWoORRNkws9Iwqprj27C3ljM,99
2
- pywebexec/pywebexec.py,sha256=3T3qSfM9wDLkjlQwj33gJ0KN9J3EwQC0UnFohHOV3M4,32161
3
- pywebexec/version.py,sha256=Lku74dRhc9EC3uT_BFGpwGtdeZT0GPBqsGw5eMXm9qw,413
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.10.dist-info/LICENSE,sha256=gRJf0JPT_wsZJsUGlWPTS8Vypfl9vQ1qjp6sNbKykuA,1064
37
- pywebexec-1.6.10.dist-info/METADATA,sha256=hM3te7ICelnKxOqnHCTYL9iCeY7gAhZcERYv2aiYiWA,7974
38
- pywebexec-1.6.10.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
39
- pywebexec-1.6.10.dist-info/entry_points.txt,sha256=l52GBkPCXRkmlHfEyoVauyfBdg8o-CAtC8qQpOIjJK0,55
40
- pywebexec-1.6.10.dist-info/top_level.txt,sha256=vHoHyzngrfGdm_nM7Xn_5iLmaCrf10XO1EhldgNLEQ8,10
41
- pywebexec-1.6.10.dist-info/RECORD,,
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,,