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 +20 -10
- pywebexec/version.py +2 -2
- {pywebexec-2.3.0.dist-info → pywebexec-2.3.1.dist-info}/METADATA +1 -1
- {pywebexec-2.3.0.dist-info → pywebexec-2.3.1.dist-info}/RECORD +8 -8
- {pywebexec-2.3.0.dist-info → pywebexec-2.3.1.dist-info}/WHEEL +1 -1
- {pywebexec-2.3.0.dist-info → pywebexec-2.3.1.dist-info}/entry_points.txt +0 -0
- {pywebexec-2.3.0.dist-info → pywebexec-2.3.1.dist-info}/licenses/LICENSE +0 -0
- {pywebexec-2.3.0.dist-info → pywebexec-2.3.1.dist-info}/top_level.txt +0 -0
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
|
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
|
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 =
|
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
|
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,
|
562
|
+
except (EOFError, WinptyError):
|
552
563
|
break
|
553
|
-
status = p.
|
554
|
-
|
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
@@ -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=
|
3
|
+
pywebexec/pywebexec.py,sha256=LD917ZeDVnOSMuLWPkl9JT1baaDvZ_e0Yk7RTs5yBfk,48273
|
4
4
|
pywebexec/swagger.yaml,sha256=I_oLpp7Hqel8SDEEykvpmCT-Gv3ytGlziq9bvQOrtZY,7598
|
5
|
-
pywebexec/version.py,sha256=
|
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.
|
71
|
-
pywebexec-2.3.
|
72
|
-
pywebexec-2.3.
|
73
|
-
pywebexec-2.3.
|
74
|
-
pywebexec-2.3.
|
75
|
-
pywebexec-2.3.
|
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,,
|
File without changes
|
File without changes
|
File without changes
|