pywebexec 2.3.0__py3-none-any.whl → 2.3.1__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
@@ -22,7 +22,7 @@ if platform.system() != 'Windows':
22
22
  import termios
23
23
  else:
24
24
  from waitress import serve
25
- import winpty
25
+ from winpty import PtyProcess, WinptyError
26
26
  import ipaddress
27
27
  from socket import socket, AF_INET, SOCK_STREAM
28
28
  import ssl
@@ -72,6 +72,7 @@ CONFDIR += "/.pywebexec"
72
72
  term_command_id = str(uuid.uuid4())
73
73
  tty_cols = 125
74
74
  tty_rows = 30
75
+ os.environ["PYWEBEXEC"] = "true"
75
76
 
76
77
  # In-memory cache for command statuses
77
78
  status_cache = {}
@@ -364,6 +365,7 @@ def parseargs():
364
365
  parser.add_argument("-k", "--key", type=str, help="Path to https certificate key")
365
366
  parser.add_argument("-g", "--gencert", action="store_true", help="https server self signed cert")
366
367
  parser.add_argument("-T", "--tokenurl", action="store_true", help="generate safe url to access")
368
+ parser.add_argument("-n", "--notty", action="store_true", help="no span commands in tty")
367
369
  parser.add_argument("-C", "--cols", type=int, default=tty_cols, help="terminal columns")
368
370
  parser.add_argument("-R", "--rows", type=int, default=tty_rows, help="terminal rows")
369
371
  parser.add_argument("action", nargs="?", help="daemon action start/stop/restart/status/shareterm/term",
@@ -529,12 +531,21 @@ def run_command(fromip, user, command, params, command_id, rows, cols):
529
531
  })
530
532
  output_file_path = get_output_file_path(command_id)
531
533
  try:
532
- if platform.system() == 'Windows':
534
+ if args.notty:
535
+ os.environ["PYTHONIOENCODING"] = "utf-8"
536
+ os.environ["PYTHONLEGACYWINDOWSSTDIO"] = "utf-8"
537
+ with open(output_file_path, 'wb', buffering=0) as fd:
538
+ p = subprocess.Popen([sys.executable, "-u", command, *params], stdout=fd, stderr=fd, bufsize=1, text=False)
539
+ pid = p.pid
540
+ update_command_status(command_id, {
541
+ 'pid': pid,
542
+ })
543
+ p.wait()
544
+ status = p.returncode
545
+ elif platform.system() == 'Windows':
533
546
  # On Windows, use winpty
534
- cmdline = f"{sys.executable} -u {command} " + " ".join(shlex.quote(p) for p in params)
535
547
  with open(output_file_path, 'wb', buffering=0) as fd:
536
- p = winpty.PTY(cols, rows)
537
- p.spawn(cmdline)
548
+ p = PtyProcess.spawn([sys.executable, "-u", command, *params], dimensions=(rows, cols))
538
549
  pid = p.pid
539
550
  update_command_status(command_id, {
540
551
  'pid': pid,
@@ -543,16 +554,15 @@ def run_command(fromip, user, command, params, command_id, rows, cols):
543
554
  try:
544
555
  if not p.isalive():
545
556
  time.sleep(1)
546
- data = p.read(10485760, blocking=False)
557
+ data = p.read(10485760)
547
558
  fd.write(data.encode())
548
559
  if not p.isalive():
549
560
  break
550
561
  time.sleep(0.1)
551
- except (EOFError, winpty.WinptyError):
562
+ except (EOFError, WinptyError):
552
563
  break
553
- status = p.get_exitstatus()
554
- del p
555
- print("end", status)
564
+ status = p.exitstatus
565
+ p.close()
556
566
  else:
557
567
  # On Unix, use pexpect
558
568
  with open(output_file_path, 'wb') as fd:
pywebexec/version.py CHANGED
@@ -17,5 +17,5 @@ __version__: str
17
17
  __version_tuple__: VERSION_TUPLE
18
18
  version_tuple: VERSION_TUPLE
19
19
 
20
- __version__ = version = '2.3.0'
21
- __version_tuple__ = version_tuple = (2, 3, 0)
20
+ __version__ = version = '2.3.1'
21
+ __version_tuple__ = version_tuple = (2, 3, 1)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pywebexec
3
- Version: 2.3.0
3
+ Version: 2.3.1
4
4
  Summary: Simple Python HTTP Exec Server
5
5
  Home-page: https://github.com/joknarf/pywebexec
6
6
  Author: Franck Jouvanceau
@@ -1,8 +1,8 @@
1
1
  pywebexec/__init__.py,sha256=197fHJy0UDBwTTpGCGortZRr-w2kTaD7MxqdbVmTEi0,61
2
2
  pywebexec/host_ip.py,sha256=Ud_HTflWVQ8789aoQ2RZdT1wGI-ccvrwSWGz_c7T3TI,1241
3
- pywebexec/pywebexec.py,sha256=q2q4NVgWeMmAegM-iK8J9B175snHyHkW45WYPlHYJpQ,47727
3
+ pywebexec/pywebexec.py,sha256=LD917ZeDVnOSMuLWPkl9JT1baaDvZ_e0Yk7RTs5yBfk,48273
4
4
  pywebexec/swagger.yaml,sha256=I_oLpp7Hqel8SDEEykvpmCT-Gv3ytGlziq9bvQOrtZY,7598
5
- pywebexec/version.py,sha256=U--yqU7RFo8hQQm8oopUGYLkafj4phNIVfkf5HFEal8,511
5
+ pywebexec/version.py,sha256=4lLWfgycoQE7rafXKcKQeSzbG6DAo6_kH0qn9J_0diQ,511
6
6
  pywebexec/static/css/form.css,sha256=XC_0ES5yMHYz0S2OHR0RAboQN7fBUmg5ZIq8Qm5rHP0,5806
7
7
  pywebexec/static/css/markdown.css,sha256=br4-iK9wigTs54N2KHtjgZ4KLH0THVSvJo-XZAdMHiE,1970
8
8
  pywebexec/static/css/style.css,sha256=R1VOPNV2ztROKy9Fgf3tvUrtuKagY027tFJ8C866yWU,9991
@@ -67,9 +67,9 @@ pywebexec/templates/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSu
67
67
  pywebexec/templates/index.html,sha256=w18O2plH_yS8bqlPsu5hwFFmCj9H2hWLSV8B6ADcSwU,3900
68
68
  pywebexec/templates/popup.html,sha256=3kpMccKD_OLLhJ4Y9KRw6Ny8wQWjVaRrUfV9y5-bDiQ,1580
69
69
  pywebexec/templates/swagger_ui.html,sha256=MAPr-z96VERAecDvX37V8q2Nxph-O0fNDBul1x2w9SI,1147
70
- pywebexec-2.3.0.dist-info/licenses/LICENSE,sha256=gRJf0JPT_wsZJsUGlWPTS8Vypfl9vQ1qjp6sNbKykuA,1064
71
- pywebexec-2.3.0.dist-info/METADATA,sha256=y1F2WI5mfVSDdt_GznPWBmK07NrToa8qOjSqls1r0kM,13015
72
- pywebexec-2.3.0.dist-info/WHEEL,sha256=1tXe9gY0PYatrMPMDd6jXqjfpz_B-Wqm32CPfRC58XU,91
73
- pywebexec-2.3.0.dist-info/entry_points.txt,sha256=l52GBkPCXRkmlHfEyoVauyfBdg8o-CAtC8qQpOIjJK0,55
74
- pywebexec-2.3.0.dist-info/top_level.txt,sha256=vHoHyzngrfGdm_nM7Xn_5iLmaCrf10XO1EhldgNLEQ8,10
75
- pywebexec-2.3.0.dist-info/RECORD,,
70
+ pywebexec-2.3.1.dist-info/licenses/LICENSE,sha256=gRJf0JPT_wsZJsUGlWPTS8Vypfl9vQ1qjp6sNbKykuA,1064
71
+ pywebexec-2.3.1.dist-info/METADATA,sha256=7CcAZIQPHq5Y_txEFyDwBzSRE1o4TPyJYHgZtSeQvuM,13015
72
+ pywebexec-2.3.1.dist-info/WHEEL,sha256=L0N565qmK-3nM2eBoMNFszYJ_MTx03_tQ0CQu1bHLYo,91
73
+ pywebexec-2.3.1.dist-info/entry_points.txt,sha256=l52GBkPCXRkmlHfEyoVauyfBdg8o-CAtC8qQpOIjJK0,55
74
+ pywebexec-2.3.1.dist-info/top_level.txt,sha256=vHoHyzngrfGdm_nM7Xn_5iLmaCrf10XO1EhldgNLEQ8,10
75
+ pywebexec-2.3.1.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (77.0.3)
2
+ Generator: setuptools (78.0.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5