pywebexec 1.4.13__tar.gz → 1.4.14__tar.gz

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.
Files changed (38) hide show
  1. {pywebexec-1.4.13/pywebexec.egg-info → pywebexec-1.4.14}/PKG-INFO +1 -1
  2. {pywebexec-1.4.13 → pywebexec-1.4.14}/pywebexec/pywebexec.py +27 -14
  3. {pywebexec-1.4.13 → pywebexec-1.4.14}/pywebexec/version.py +2 -2
  4. {pywebexec-1.4.13 → pywebexec-1.4.14/pywebexec.egg-info}/PKG-INFO +1 -1
  5. {pywebexec-1.4.13 → pywebexec-1.4.14}/.github/workflows/python-publish.yml +0 -0
  6. {pywebexec-1.4.13 → pywebexec-1.4.14}/.gitignore +0 -0
  7. {pywebexec-1.4.13 → pywebexec-1.4.14}/LICENSE +0 -0
  8. {pywebexec-1.4.13 → pywebexec-1.4.14}/README.md +0 -0
  9. {pywebexec-1.4.13 → pywebexec-1.4.14}/pyproject.toml +0 -0
  10. {pywebexec-1.4.13 → pywebexec-1.4.14}/pywebexec/__init__.py +0 -0
  11. {pywebexec-1.4.13 → pywebexec-1.4.14}/pywebexec/static/css/Consolas NF.ttf +0 -0
  12. {pywebexec-1.4.13 → pywebexec-1.4.14}/pywebexec/static/css/style.css +0 -0
  13. {pywebexec-1.4.13 → pywebexec-1.4.14}/pywebexec/static/css/xterm.css +0 -0
  14. {pywebexec-1.4.13 → pywebexec-1.4.14}/pywebexec/static/images/aborted.svg +0 -0
  15. {pywebexec-1.4.13 → pywebexec-1.4.14}/pywebexec/static/images/copy.svg +0 -0
  16. {pywebexec-1.4.13 → pywebexec-1.4.14}/pywebexec/static/images/copy_ok.svg +0 -0
  17. {pywebexec-1.4.13 → pywebexec-1.4.14}/pywebexec/static/images/down-arrow.svg +0 -0
  18. {pywebexec-1.4.13 → pywebexec-1.4.14}/pywebexec/static/images/failed.svg +0 -0
  19. {pywebexec-1.4.13 → pywebexec-1.4.14}/pywebexec/static/images/favicon.svg +0 -0
  20. {pywebexec-1.4.13 → pywebexec-1.4.14}/pywebexec/static/images/popup.svg +0 -0
  21. {pywebexec-1.4.13 → pywebexec-1.4.14}/pywebexec/static/images/running.gif +0 -0
  22. {pywebexec-1.4.13 → pywebexec-1.4.14}/pywebexec/static/images/success.svg +0 -0
  23. {pywebexec-1.4.13 → pywebexec-1.4.14}/pywebexec/static/js/commands.js +0 -0
  24. {pywebexec-1.4.13 → pywebexec-1.4.14}/pywebexec/static/js/popup.js +0 -0
  25. {pywebexec-1.4.13 → pywebexec-1.4.14}/pywebexec/static/js/script.js +0 -0
  26. {pywebexec-1.4.13 → pywebexec-1.4.14}/pywebexec/static/js/xterm/LICENSE +0 -0
  27. {pywebexec-1.4.13 → pywebexec-1.4.14}/pywebexec/static/js/xterm/ansi_up.min.js +0 -0
  28. {pywebexec-1.4.13 → pywebexec-1.4.14}/pywebexec/static/js/xterm/xterm-addon-fit.js +0 -0
  29. {pywebexec-1.4.13 → pywebexec-1.4.14}/pywebexec/static/js/xterm/xterm.js +0 -0
  30. {pywebexec-1.4.13 → pywebexec-1.4.14}/pywebexec/templates/__init__.py +0 -0
  31. {pywebexec-1.4.13 → pywebexec-1.4.14}/pywebexec/templates/index.html +0 -0
  32. {pywebexec-1.4.13 → pywebexec-1.4.14}/pywebexec/templates/popup.html +0 -0
  33. {pywebexec-1.4.13 → pywebexec-1.4.14}/pywebexec.egg-info/SOURCES.txt +0 -0
  34. {pywebexec-1.4.13 → pywebexec-1.4.14}/pywebexec.egg-info/dependency_links.txt +0 -0
  35. {pywebexec-1.4.13 → pywebexec-1.4.14}/pywebexec.egg-info/entry_points.txt +0 -0
  36. {pywebexec-1.4.13 → pywebexec-1.4.14}/pywebexec.egg-info/requires.txt +0 -0
  37. {pywebexec-1.4.13 → pywebexec-1.4.14}/pywebexec.egg-info/top_level.txt +0 -0
  38. {pywebexec-1.4.13 → pywebexec-1.4.14}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: pywebexec
3
- Version: 1.4.13
3
+ Version: 1.4.14
4
4
  Summary: Simple Python HTTP Exec Server
5
5
  Home-page: https://github.com/joknarf/pywebexec
6
6
  Author: Franck Jouvanceau
@@ -223,7 +223,7 @@ def start_gunicorn(daemonized=False, baselog=None):
223
223
  if daemonized:
224
224
  if daemon_d('status', pidfilepath=baselog, silent=True):
225
225
  print(f"Error: pywebexec already running on {args.listen}:{args.port}", file=sys.stderr)
226
- sys.exit(1)
226
+ return 1
227
227
 
228
228
  if sys.stdout.isatty():
229
229
  errorlog = "-"
@@ -244,6 +244,7 @@ def start_gunicorn(daemonized=False, baselog=None):
244
244
  'pidfile': pidfile,
245
245
  }
246
246
  PyWebExec(app, options=options).run()
247
+ return 0
247
248
 
248
249
  def daemon_d(action, pidfilepath, silent=False, hostname=None, args=None):
249
250
  """start/stop daemon"""
@@ -285,10 +286,9 @@ def daemon_d(action, pidfilepath, silent=False, hostname=None, args=None):
285
286
  except Exception as e:
286
287
  print(e)
287
288
 
288
- def start_term():
289
+ def start_term(command_id):
289
290
  os.environ["PYWEBEXEC"] = " (shared)"
290
291
  os.chdir(CWD)
291
- command_id = str(uuid.uuid4())
292
292
  start_time = datetime.now().isoformat()
293
293
  user = pwd.getpwuid(os.getuid())[0]
294
294
  update_command_status(command_id, 'running', command="term", params=[user,os.ttyname(sys.stdout.fileno())], start_time=start_time, user=user)
@@ -296,10 +296,25 @@ def start_term():
296
296
  res = script(output_file_path)
297
297
  end_time = datetime.now().isoformat()
298
298
  update_command_status(command_id, status="success", end_time=end_time, exit_code=res)
299
- return res
299
+ return command_id
300
+
301
+
302
+ def print_urls(command_id=None):
303
+ protocol = 'https' if args.cert else 'http'
304
+ url_params = ""
305
+ token = os.environ.get("PYWEBEXEC_TOKEN")
306
+ if token:
307
+ url_params = f"?token={token}"
308
+ if command_id:
309
+ print(f"{protocol}://{hostname}:{args.port}/popup/{command_id}{url_params}")
310
+ print(f"{protocol}://{ip}:{args.port}/popup/{command_id}{url_params}")
311
+ else:
312
+ print(f"{protocol}://{hostname}:{args.port}{url_params}")
313
+ print(f"{protocol}://{ip}:{args.port}{url_params}")
314
+
300
315
 
301
316
  def parseargs():
302
- global app, args, COMMAND_STATUS_DIR
317
+ global app, args, COMMAND_STATUS_DIR, hostname, ip
303
318
 
304
319
  parser = argparse.ArgumentParser(description='Run the command execution server.')
305
320
  parser.add_argument('-u', '--user', help='Username for basic auth')
@@ -344,15 +359,14 @@ def parseargs():
344
359
  os.mkdir(COMMAND_STATUS_DIR, mode=0o700)
345
360
  if args.action == "term":
346
361
  COMMAND_STATUS_DIR = f"{os.getcwd()}/{COMMAND_STATUS_DIR}"
347
- sys.exit(start_term())
362
+ start_term(str(uuid.uuid4()))
363
+ sys.exit(0)
348
364
  (hostname, ip) = resolve(gethostname()) if args.listen == '0.0.0.0' else resolve(args.listen)
349
- url_params = ""
350
365
 
351
366
  if args.tokenurl:
352
367
  token = os.environ.get("PYWEBEXEC_TOKEN", token_urlsafe())
353
368
  os.environ["PYWEBEXEC_TOKEN"] = token
354
369
  app.config["TOKEN_URL"] = token
355
- url_params = f"?token={token}"
356
370
 
357
371
  if args.gencert:
358
372
  args.cert = args.cert or f"{CONFDIR}/pywebexec.crt"
@@ -377,10 +391,7 @@ def parseargs():
377
391
 
378
392
  if args.action != 'stop':
379
393
  print("Starting server:")
380
- protocol = 'https' if args.cert else 'http'
381
- print(f"{protocol}://{hostname}:{args.port}{url_params}")
382
- print(f"{protocol}://{ip}:{args.port}{url_params}")
383
-
394
+ print_urls()
384
395
  return args
385
396
 
386
397
  def get_status_file_path(command_id):
@@ -704,7 +715,9 @@ def main():
704
715
  COMMAND_STATUS_DIR = f"{os.getcwd()}/{COMMAND_STATUS_DIR}"
705
716
  with open(basef + ".log", "ab+") as log:
706
717
  pywebexec = subprocess.Popen([sys.executable] + sys.argv[:-1], stdout=log, stderr=log)
707
- start_term()
718
+ command_id = str(uuid.uuid4())
719
+ print_urls(command_id)
720
+ res = start_term(command_id)
708
721
  time.sleep(1)
709
722
  pywebexec.terminate()
710
723
  sys.exit()
@@ -720,5 +733,5 @@ def main():
720
733
 
721
734
 
722
735
  if __name__ == '__main__':
723
- main()
736
+ sys.exit(main())
724
737
  # app.run(host='0.0.0.0', port=5000)
@@ -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.13'
16
- __version_tuple__ = version_tuple = (1, 4, 13)
15
+ __version__ = version = '1.4.14'
16
+ __version_tuple__ = version_tuple = (1, 4, 14)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: pywebexec
3
- Version: 1.4.13
3
+ Version: 1.4.14
4
4
  Summary: Simple Python HTTP Exec Server
5
5
  Home-page: https://github.com/joknarf/pywebexec
6
6
  Author: Franck Jouvanceau
File without changes
File without changes
File without changes
File without changes
File without changes