pywebexec 1.3.5__py3-none-any.whl → 1.3.7__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-1.3.5.dist-info → pywebexec-1.3.7.dist-info}/METADATA +1 -1
- {pywebexec-1.3.5.dist-info → pywebexec-1.3.7.dist-info}/RECORD +8 -8
- {pywebexec-1.3.5.dist-info → pywebexec-1.3.7.dist-info}/LICENSE +0 -0
- {pywebexec-1.3.5.dist-info → pywebexec-1.3.7.dist-info}/WHEEL +0 -0
- {pywebexec-1.3.5.dist-info → pywebexec-1.3.7.dist-info}/entry_points.txt +0 -0
- {pywebexec-1.3.5.dist-info → pywebexec-1.3.7.dist-info}/top_level.txt +0 -0
pywebexec/pywebexec.py
CHANGED
@@ -222,7 +222,7 @@ def start_gunicorn(daemonized=False, baselog=None):
|
|
222
222
|
sys.exit(1)
|
223
223
|
else:
|
224
224
|
errorlog = "-"
|
225
|
-
accesslog = "-"
|
225
|
+
accesslog = None #"-"
|
226
226
|
pidfile = None
|
227
227
|
options = {
|
228
228
|
'bind': '%s:%s' % (args.listen, args.port),
|
@@ -439,6 +439,8 @@ def script(filename):
|
|
439
439
|
return pty.spawn(shell, read)
|
440
440
|
|
441
441
|
|
442
|
+
import fcntl
|
443
|
+
|
442
444
|
def run_command(command, params, command_id, user):
|
443
445
|
start_time = datetime.now().isoformat()
|
444
446
|
update_command_status(command_id, 'running', command=command, params=params, start_time=start_time, user=user)
|
@@ -447,28 +449,33 @@ def run_command(command, params, command_id, user):
|
|
447
449
|
with open(output_file_path, 'wb') as output_file:
|
448
450
|
def read(fd):
|
449
451
|
data = os.read(fd, 1024)
|
452
|
+
if not data: # Check for EOF
|
453
|
+
raise OSError("EOF reached")
|
450
454
|
output_file.write(data)
|
451
455
|
output_file.flush()
|
452
456
|
return data
|
453
457
|
|
454
458
|
def spawn_pty():
|
455
459
|
pid, fd = pty.fork()
|
456
|
-
if pid == 0:
|
460
|
+
if pid == 0: # Child process
|
457
461
|
try:
|
458
462
|
os.setsid()
|
459
463
|
except:
|
460
464
|
pass
|
461
465
|
os.execvp(command, [command] + params)
|
462
|
-
else:
|
466
|
+
else: # Parent process
|
463
467
|
update_command_status(command_id, 'running', pid=pid, user=user)
|
468
|
+
fcntl.fcntl(fd, fcntl.F_SETFL, os.O_NONBLOCK) # Set the file descriptor to non-blocking mode
|
464
469
|
while True:
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
470
|
+
r, _, _ = select.select([fd], [], [], 1.0) # Use select to monitor the file descriptor
|
471
|
+
if fd in r:
|
472
|
+
try:
|
473
|
+
read(fd)
|
474
|
+
except OSError:
|
475
|
+
break
|
469
476
|
(pid, status) = os.waitpid(pid, 0)
|
470
|
-
print(status)
|
471
477
|
return status
|
478
|
+
|
472
479
|
status = spawn_pty()
|
473
480
|
end_time = datetime.now().isoformat()
|
474
481
|
# Update the status based on the result
|
@@ -495,9 +502,12 @@ def stop_command(command_id):
|
|
495
502
|
pid = status['pid']
|
496
503
|
end_time = datetime.now().isoformat()
|
497
504
|
try:
|
505
|
+
update_command_status(command_id, 'aborted', end_time=end_time, exit_code=-15)
|
498
506
|
os.killpg(os.getpgid(pid), 15) # Send SIGTERM to the process group
|
499
|
-
|
500
|
-
|
507
|
+
try:
|
508
|
+
os.waitpid(pid, 0) # Wait for the process to terminate
|
509
|
+
except ChildProcessError:
|
510
|
+
pass # Ignore if the process has already been reaped
|
501
511
|
return jsonify({'message': 'Command aborted'})
|
502
512
|
except Exception as e:
|
503
513
|
status_data = read_command_status(command_id) or {}
|
pywebexec/version.py
CHANGED
@@ -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=ks64NNrtgs1ivwiUVDD1At69_hDlaU6mT7YZ1ndHtCE,26832
|
3
|
+
pywebexec/version.py,sha256=wi-wdjHlnbEGXkbINL3u9-DfMuMikQsUE4upTqz0SJE,411
|
4
4
|
pywebexec/static/css/Consolas NF.ttf,sha256=DJEOzF0eqZ-kxu3Gs_VE8X0NJqiobBzmxWDGpdgGRxI,1313900
|
5
5
|
pywebexec/static/css/style.css,sha256=iLX6k1hoWLinZWyqtbH50U-0hND2M-5_Zr1U1UC_gos,5578
|
6
6
|
pywebexec/static/css/xterm.css,sha256=gy8_LGA7Q61DUf8ElwFQzHqHMBQnbbEmpgZcbdgeSHI,5383
|
@@ -20,9 +20,9 @@ pywebexec/static/js/xterm/xterm-addon-fit.js,sha256=Pprm9pZe4SadVXS5Bc8b9VnC9Ex4
|
|
20
20
|
pywebexec/static/js/xterm/xterm.js,sha256=Bzka76jZwEhVt_LlS0e0qMw7ryGa1p5qfxFyeohphBo,283371
|
21
21
|
pywebexec/templates/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
22
22
|
pywebexec/templates/index.html,sha256=DYtT555wSNhnFtzzHhPMWJireynCJNnAuTytpoORQeE,2321
|
23
|
-
pywebexec-1.3.
|
24
|
-
pywebexec-1.3.
|
25
|
-
pywebexec-1.3.
|
26
|
-
pywebexec-1.3.
|
27
|
-
pywebexec-1.3.
|
28
|
-
pywebexec-1.3.
|
23
|
+
pywebexec-1.3.7.dist-info/LICENSE,sha256=gRJf0JPT_wsZJsUGlWPTS8Vypfl9vQ1qjp6sNbKykuA,1064
|
24
|
+
pywebexec-1.3.7.dist-info/METADATA,sha256=zJ1dlHWVBDz4QgRQmpcJ3K-7j61TIIOufhJTSqcArW4,7397
|
25
|
+
pywebexec-1.3.7.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
26
|
+
pywebexec-1.3.7.dist-info/entry_points.txt,sha256=l52GBkPCXRkmlHfEyoVauyfBdg8o-CAtC8qQpOIjJK0,55
|
27
|
+
pywebexec-1.3.7.dist-info/top_level.txt,sha256=vHoHyzngrfGdm_nM7Xn_5iLmaCrf10XO1EhldgNLEQ8,10
|
28
|
+
pywebexec-1.3.7.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|