pywebexec 1.7.19__py3-none-any.whl → 1.8.0__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 +22 -22
- pywebexec/version.py +2 -2
- {pywebexec-1.7.19.dist-info → pywebexec-1.8.0.dist-info}/METADATA +1 -1
- {pywebexec-1.7.19.dist-info → pywebexec-1.8.0.dist-info}/RECORD +8 -8
- {pywebexec-1.7.19.dist-info → pywebexec-1.8.0.dist-info}/LICENSE +0 -0
- {pywebexec-1.7.19.dist-info → pywebexec-1.8.0.dist-info}/WHEEL +0 -0
- {pywebexec-1.7.19.dist-info → pywebexec-1.8.0.dist-info}/entry_points.txt +0 -0
- {pywebexec-1.7.19.dist-info → pywebexec-1.8.0.dist-info}/top_level.txt +0 -0
pywebexec/pywebexec.py
CHANGED
@@ -404,13 +404,15 @@ def get_output_file_path(command_id):
|
|
404
404
|
|
405
405
|
def update_command_status(command_id, updates):
|
406
406
|
status_file_path = get_status_file_path(command_id)
|
407
|
-
status = read_command_status(command_id)
|
408
|
-
status = status.copy()
|
407
|
+
status = read_command_status(command_id)
|
409
408
|
status.update(updates)
|
409
|
+
status = status.copy()
|
410
410
|
if status.get('status') != 'running':
|
411
411
|
output_file_path = get_output_file_path(command_id)
|
412
412
|
if os.path.exists(output_file_path):
|
413
413
|
status['last_output_line'] = get_last_line(output_file_path, status.get('cols'), status.get('rows'))
|
414
|
+
if 'last_read' in status:
|
415
|
+
del status['last_read']
|
414
416
|
with open(status_file_path, 'w') as f:
|
415
417
|
json.dump(status, f)
|
416
418
|
os.sync()
|
@@ -419,24 +421,25 @@ def update_command_status(command_id, updates):
|
|
419
421
|
|
420
422
|
def read_command_status(command_id):
|
421
423
|
# Return cached status if available
|
422
|
-
|
423
|
-
if command_id in status_cache:
|
424
|
-
|
424
|
+
global status_cache
|
425
|
+
if not command_id in status_cache:
|
426
|
+
status_cache[command_id] = {}
|
427
|
+
status_data = status_cache[command_id]
|
425
428
|
status = status_data.get('status')
|
426
429
|
if status and status != "running":
|
427
430
|
return status_data
|
428
|
-
if
|
431
|
+
if status_data.get('last_read',0)>datetime.now().timestamp()-0.5:
|
429
432
|
return status_data
|
430
433
|
status_file_path = get_status_file_path(command_id)
|
431
434
|
if not os.path.exists(status_file_path):
|
432
|
-
return
|
435
|
+
return status_data
|
433
436
|
with open(status_file_path, 'r') as f:
|
434
437
|
try:
|
435
438
|
status_data.update(json.load(f))
|
436
439
|
except json.JSONDecodeError:
|
437
|
-
return
|
440
|
+
return status_data
|
438
441
|
status_data['last_read'] = datetime.now().timestamp()
|
439
|
-
status_cache[command_id] = status_data
|
442
|
+
#status_cache[command_id] = status_data
|
440
443
|
return status_data
|
441
444
|
|
442
445
|
def sigwinch_passthrough(sig, data):
|
@@ -552,7 +555,6 @@ def read_commands():
|
|
552
555
|
'last_update': datetime.now().timestamp(),
|
553
556
|
'last_output_line': get_last_line(output_file_path, status.get('cols'), status.get('rows')),
|
554
557
|
})
|
555
|
-
status_cache[command_id] = status
|
556
558
|
commands.append({
|
557
559
|
'command_id': command_id,
|
558
560
|
'status': status.get('status'),
|
@@ -730,13 +732,6 @@ def get_command_status(command_id):
|
|
730
732
|
status = read_command_status(command_id)
|
731
733
|
if not status:
|
732
734
|
return jsonify({'error': 'Invalid command_id'}), 404
|
733
|
-
|
734
|
-
# output_file_path = get_output_file_path(command_id)
|
735
|
-
# if os.path.exists(output_file_path):
|
736
|
-
# with open(output_file_path, 'r') as output_file:
|
737
|
-
# output = output_file.read()
|
738
|
-
# status['output'] = output
|
739
|
-
|
740
735
|
return jsonify(status)
|
741
736
|
|
742
737
|
@app.route('/')
|
@@ -756,11 +751,16 @@ def get_command_output(command_id):
|
|
756
751
|
maxsize = int(request.args.get('maxsize', 10485760))
|
757
752
|
output_file_path = get_output_file_path(command_id)
|
758
753
|
if os.path.exists(output_file_path):
|
759
|
-
|
760
|
-
|
761
|
-
output =
|
762
|
-
new_offset =
|
763
|
-
|
754
|
+
size = os.path.getsize(output_file_path)
|
755
|
+
if offset >= size:
|
756
|
+
output = ''
|
757
|
+
new_offset = offset
|
758
|
+
else:
|
759
|
+
with open(output_file_path, 'rb') as output_file:
|
760
|
+
output_file.seek(offset)
|
761
|
+
output = output_file.read().decode('utf-8', errors='replace')
|
762
|
+
new_offset = output_file.tell()
|
763
|
+
status_data = read_command_status(command_id)
|
764
764
|
token = app.config.get("TOKEN_URL")
|
765
765
|
token_param = f"&token={token}" if token else ""
|
766
766
|
response = {
|
pywebexec/version.py
CHANGED
@@ -1,7 +1,7 @@
|
|
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=
|
4
|
-
pywebexec/version.py,sha256=
|
3
|
+
pywebexec/pywebexec.py,sha256=Pwsjq9VpM19l10-suEZ5nEXBv-LOaJNZy91ubuAkBos,32541
|
4
|
+
pywebexec/version.py,sha256=NlHLpXkNFmTH52K5-WhbSOpEjuVpHwg6f2tUr8gHTCY,511
|
5
5
|
pywebexec/static/css/Consolas NF.ttf,sha256=DJEOzF0eqZ-kxu3Gs_VE8X0NJqiobBzmxWDGpdgGRxI,1313900
|
6
6
|
pywebexec/static/css/style.css,sha256=fU-_eAk6Xy0L_GbH9rJBkeCFe5M2RYQA99cvRZ3pW9w,7934
|
7
7
|
pywebexec/static/css/xterm.css,sha256=uo5phWaUiJgcz0DAzv46uoByLLbJLeetYosL1xf68rY,5559
|
@@ -36,9 +36,9 @@ pywebexec/static/js/xterm/xterm.js.map,sha256=Y7O2Pb-fIS7Z8AC1D5s04_aiW_Jf1f4mCf
|
|
36
36
|
pywebexec/templates/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
37
37
|
pywebexec/templates/index.html,sha256=KSdQYBdzWKP6v0ETZsMO_729aosGBAzJxAss8T5jCto,2953
|
38
38
|
pywebexec/templates/popup.html,sha256=f5m4u8WKpkevL2mQamGqo4_y-rSuLOXGuNsezuUbniY,1508
|
39
|
-
pywebexec-1.
|
40
|
-
pywebexec-1.
|
41
|
-
pywebexec-1.
|
42
|
-
pywebexec-1.
|
43
|
-
pywebexec-1.
|
44
|
-
pywebexec-1.
|
39
|
+
pywebexec-1.8.0.dist-info/LICENSE,sha256=gRJf0JPT_wsZJsUGlWPTS8Vypfl9vQ1qjp6sNbKykuA,1064
|
40
|
+
pywebexec-1.8.0.dist-info/METADATA,sha256=BwYrBzm4blpnbGe0A1xwwobqIHCnIT211Jobsx9GpQg,8146
|
41
|
+
pywebexec-1.8.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
42
|
+
pywebexec-1.8.0.dist-info/entry_points.txt,sha256=l52GBkPCXRkmlHfEyoVauyfBdg8o-CAtC8qQpOIjJK0,55
|
43
|
+
pywebexec-1.8.0.dist-info/top_level.txt,sha256=vHoHyzngrfGdm_nM7Xn_5iLmaCrf10XO1EhldgNLEQ8,10
|
44
|
+
pywebexec-1.8.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|