pywebexec 1.4.11__py3-none-any.whl → 1.4.13__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
@@ -9,6 +9,7 @@ import argparse
9
9
  import random
10
10
  import string
11
11
  from datetime import datetime, timezone, timedelta
12
+ import time
12
13
  import shlex
13
14
  from gunicorn.app.base import Application
14
15
  import ipaddress
@@ -43,7 +44,7 @@ app.config['LDAP_BIND_PASSWORD'] = os.environ.get('PYWEBEXEC_LDAP_BIND_PASSWORD'
43
44
  # Directory to store the command status and output
44
45
  CWD = os.getcwd()
45
46
  COMMAND_STATUS_DIR = '.web_status'
46
- CONFDIR = os.path.expanduser("~/")
47
+ CONFDIR = os.path.expanduser("~/").rstrip('/')
47
48
  if os.path.isdir(f"{CONFDIR}/.config"):
48
49
  CONFDIR += '/.config'
49
50
  CONFDIR += "/.pywebexec"
@@ -285,6 +286,7 @@ def daemon_d(action, pidfilepath, silent=False, hostname=None, args=None):
285
286
  print(e)
286
287
 
287
288
  def start_term():
289
+ os.environ["PYWEBEXEC"] = " (shared)"
288
290
  os.chdir(CWD)
289
291
  command_id = str(uuid.uuid4())
290
292
  start_time = datetime.now().isoformat()
@@ -309,7 +311,7 @@ def parseargs():
309
311
  "-p", "--port", type=int, default=8080, help="HTTP server listen port"
310
312
  )
311
313
  parser.add_argument(
312
- "-d", "--dir", type=str, default=os.getcwd(), help="Serve target directory"
314
+ "-d", "--dir", type=str, help=f"Serve target directory. default {CONFDIR}"
313
315
  )
314
316
  parser.add_argument(
315
317
  "-t",
@@ -326,6 +328,9 @@ def parseargs():
326
328
  choices=["start","stop","restart","status","shareterm", "term"])
327
329
 
328
330
  args = parser.parse_args()
331
+ if not os.path.exists(CONFDIR):
332
+ os.mkdir(CONFDIR, mode=0o700)
333
+ args.dir = args.dir or CONFDIR
329
334
  if os.path.isdir(args.dir):
330
335
  try:
331
336
  os.chdir(args.dir)
@@ -336,9 +341,7 @@ def parseargs():
336
341
  print(f"Error: {args.dir} not found", file=sys.stderr)
337
342
  sys.exit(1)
338
343
  if not os.path.exists(COMMAND_STATUS_DIR):
339
- os.makedirs(COMMAND_STATUS_DIR)
340
- if not os.path.exists(CONFDIR):
341
- os.mkdir(CONFDIR, mode=0o700)
344
+ os.mkdir(COMMAND_STATUS_DIR, mode=0o700)
342
345
  if args.action == "term":
343
346
  COMMAND_STATUS_DIR = f"{os.getcwd()}/{COMMAND_STATUS_DIR}"
344
347
  sys.exit(start_term())
@@ -454,7 +457,6 @@ def script(output_file):
454
457
  sigwinch_passthrough(None, None)
455
458
  signal.signal(signal.SIGWINCH, sigwinch_passthrough)
456
459
  p.interact()
457
-
458
460
 
459
461
 
460
462
  def run_command(command, params, command_id, user):
@@ -703,6 +705,7 @@ def main():
703
705
  with open(basef + ".log", "ab+") as log:
704
706
  pywebexec = subprocess.Popen([sys.executable] + sys.argv[:-1], stdout=log, stderr=log)
705
707
  start_term()
708
+ time.sleep(1)
706
709
  pywebexec.terminate()
707
710
  sys.exit()
708
711
 
@@ -267,14 +267,12 @@ span {
267
267
  width: 100%;
268
268
  }
269
269
  .popup-button {
270
- background: none;
271
- border: none;
270
+ background-color: transparent;
271
+ background-image: url("/static/images/popup.svg");
272
272
  cursor: pointer;
273
+ border: none;
273
274
  padding: 0;
274
- margin-left: 5px;
275
275
  vertical-align: middle;
276
- }
277
- .popup-button img {
278
276
  width: 16px;
279
277
  height: 16px;
280
278
  }
@@ -47,6 +47,7 @@ async function fetchOutput(url) {
47
47
  try {
48
48
  const response = await fetch(url);
49
49
  if (!response.ok) {
50
+ document.getElementById('dimmer').style.display = 'none';
50
51
  return;
51
52
  }
52
53
  const data = await response.json();
@@ -72,6 +73,7 @@ async function fetchOutput(url) {
72
73
  }
73
74
  }
74
75
  } catch (error) {
76
+ document.getElementById('dimmer').style.display = 'block';
75
77
  console.log('Error fetching output:', error);
76
78
  }
77
79
  }
@@ -111,9 +111,7 @@ async function fetchCommands() {
111
111
  ${command.command.startsWith('term') ? '' : command.status === 'running' ? `<button onclick="stopCommand('${command.command_id}', event)">Stop</button>` : `<button onclick="relaunchCommand('${command.command_id}', event)">Run</button>`}
112
112
  </td>
113
113
  <td class="monospace outcol">
114
- <button class="popup-button" onclick="openPopup('${command.command_id}', event)">
115
- <img src="/static/images/popup.svg" alt="Popup">
116
- </button>
114
+ <button class="popup-button" onclick="openPopup('${command.command_id}', event)"></button>
117
115
  ${command.last_output_line || ''}
118
116
  </td>
119
117
  `;
@@ -8,6 +8,9 @@
8
8
  <link rel="stylesheet" href="/static/css/xterm.css">
9
9
  </head>
10
10
  <body>
11
+ <div id="dimmer" class="dimmer">
12
+ <div class="dimmer-text">Server not available</div>
13
+ </div>
11
14
  <div id="output" class="output"></div>
12
15
  <div class="slider-container">
13
16
  <input type="range" id="outputSlider" min="0" max="100" value="100">
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.4.11'
16
- __version_tuple__ = version_tuple = (1, 4, 11)
15
+ __version__ = version = '1.4.13'
16
+ __version_tuple__ = version_tuple = (1, 4, 13)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: pywebexec
3
- Version: 1.4.11
3
+ Version: 1.4.13
4
4
  Summary: Simple Python HTTP Exec Server
5
5
  Home-page: https://github.com/joknarf/pywebexec
6
6
  Author: Franck Jouvanceau
@@ -76,8 +76,14 @@ $ pip install pywebexec
76
76
 
77
77
  ## Quick start
78
78
 
79
- * put in a directory the scripts/commands/links to commands you want to expose
80
- * start http server serving current directory executables listening on 0.0.0.0 port 8080
79
+ * share terminal
80
+ ```shell
81
+ $ pywebexec shareterm
82
+ ```
83
+
84
+ * serve executables
85
+ * put in a directory the scripts/commands/links to commands you want to expose
86
+ * start http server serving current directory executables listening on 0.0.0.0 port 8080
81
87
  ```shell
82
88
  $ pywebexec -d <dir>
83
89
  ```
@@ -1,8 +1,8 @@
1
1
  pywebexec/__init__.py,sha256=4spIsVaF8RJt8S58AG_wWoORRNkws9Iwqprj27C3ljM,99
2
- pywebexec/pywebexec.py,sha256=gZNUbNeFI2TWimUXmHva9ABHv8S4QH_xiUXOWKlswJM,26843
3
- pywebexec/version.py,sha256=CiEe7E8jVlrB3YZUumeEso6PXucVNqiDDQfL8kleYok,413
2
+ pywebexec/pywebexec.py,sha256=KNRO31L0ArCxkS9Ph98YKzMumn0j41-ocr9TkQgKMmQ,26977
3
+ pywebexec/version.py,sha256=bhORB-auReBqhWH8Z8Dx1LQ8cW3mTgChFk4qt6yE3rs,413
4
4
  pywebexec/static/css/Consolas NF.ttf,sha256=DJEOzF0eqZ-kxu3Gs_VE8X0NJqiobBzmxWDGpdgGRxI,1313900
5
- pywebexec/static/css/style.css,sha256=sDBhZ-csW5THIKfTDsHqxCSg6rIJ91Oh15sjw_HjJo4,5702
5
+ pywebexec/static/css/style.css,sha256=cGJHPFj23SQ_bFpesfUaFA3VFxhXtpRUOL_zzx3x_X8,5726
6
6
  pywebexec/static/css/xterm.css,sha256=gy8_LGA7Q61DUf8ElwFQzHqHMBQnbbEmpgZcbdgeSHI,5383
7
7
  pywebexec/static/images/aborted.svg,sha256=_mP43hU5QdRLFZIknBgjx-dIXrHgQG23-QV27ApXK2A,381
8
8
  pywebexec/static/images/copy.svg,sha256=d9OwtGh5GzzZHzYcDrLfNxZYLth1Q64x7bRyYxu4Px0,622
@@ -14,18 +14,18 @@ pywebexec/static/images/popup.svg,sha256=0Bl9A_v5cBsMPn6FnOlVWlAQKgd2zqiWQbhjcL9
14
14
  pywebexec/static/images/running.gif,sha256=iYuzQGkMxrakSIwt6gPieKCImGZoSAHmU5MUNZa7cpw,25696
15
15
  pywebexec/static/images/success.svg,sha256=PJDcCSTevJh7rkfSFLtc7P0pbeh8PVQBS8DaOLQemmc,489
16
16
  pywebexec/static/js/commands.js,sha256=8JDb3Q55EJOYf2Q9Uy6qEuqAnn1oGjM0RndgQ4aOjqo,7725
17
- pywebexec/static/js/popup.js,sha256=VdkDXEIwd4IawhDIWew6poWhpE7sAReVn0MopdSx5wY,4519
18
- pywebexec/static/js/script.js,sha256=QlYuIdvolTwxkJtgp7-X1IRM9Hr8D08iQCyCzZjv3hk,12255
17
+ pywebexec/static/js/popup.js,sha256=i7BPBh6oS0Q6H528DwP6KwJ8CKh7ULwm1rLHSbyvDhk,4656
18
+ pywebexec/static/js/script.js,sha256=x3YJn61YOpV5bSum3nrV7MRP7lMAAWv1-mhWBJen2nE,12161
19
19
  pywebexec/static/js/xterm/LICENSE,sha256=EU1P4eXTull-_T9I80VuwnJXubB-zLzUl3xpEYj2T1M,1083
20
20
  pywebexec/static/js/xterm/ansi_up.min.js,sha256=KNGV0vEr30hNqKQimTAvGVy-icD5A1JqMQTtvYtKR2Y,13203
21
21
  pywebexec/static/js/xterm/xterm-addon-fit.js,sha256=Pprm9pZe4SadVXS5Bc8b9VnC9Ex4QlWwA0pxOH53Gck,1460
22
22
  pywebexec/static/js/xterm/xterm.js,sha256=Bzka76jZwEhVt_LlS0e0qMw7ryGa1p5qfxFyeohphBo,283371
23
23
  pywebexec/templates/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
24
24
  pywebexec/templates/index.html,sha256=DYtT555wSNhnFtzzHhPMWJireynCJNnAuTytpoORQeE,2321
25
- pywebexec/templates/popup.html,sha256=6kmZKb0tGJ7jsr9DqDEriSMlbkW-PJTtCiUE9U5_FOE,837
26
- pywebexec-1.4.11.dist-info/LICENSE,sha256=gRJf0JPT_wsZJsUGlWPTS8Vypfl9vQ1qjp6sNbKykuA,1064
27
- pywebexec-1.4.11.dist-info/METADATA,sha256=g3K50Awl5n3qkU5zltFdfS_d5w7GbV_pRbhrsKO2HPo,7724
28
- pywebexec-1.4.11.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
29
- pywebexec-1.4.11.dist-info/entry_points.txt,sha256=l52GBkPCXRkmlHfEyoVauyfBdg8o-CAtC8qQpOIjJK0,55
30
- pywebexec-1.4.11.dist-info/top_level.txt,sha256=vHoHyzngrfGdm_nM7Xn_5iLmaCrf10XO1EhldgNLEQ8,10
31
- pywebexec-1.4.11.dist-info/RECORD,,
25
+ pywebexec/templates/popup.html,sha256=T6_tAOUoA58sA1oxB5pb8i42RenoMdCsH8T86Gccb6Q,945
26
+ pywebexec-1.4.13.dist-info/LICENSE,sha256=gRJf0JPT_wsZJsUGlWPTS8Vypfl9vQ1qjp6sNbKykuA,1064
27
+ pywebexec-1.4.13.dist-info/METADATA,sha256=vbf7BnbahIuCrkt8wGfyAo25vU5PqIGHgaor4L8uV2Y,7801
28
+ pywebexec-1.4.13.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
29
+ pywebexec-1.4.13.dist-info/entry_points.txt,sha256=l52GBkPCXRkmlHfEyoVauyfBdg8o-CAtC8qQpOIjJK0,55
30
+ pywebexec-1.4.13.dist-info/top_level.txt,sha256=vHoHyzngrfGdm_nM7Xn_5iLmaCrf10XO1EhldgNLEQ8,10
31
+ pywebexec-1.4.13.dist-info/RECORD,,