pywebexec 1.1.2__py3-none-any.whl → 1.1.11__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
@@ -342,7 +342,10 @@ def read_command_status(command_id):
342
342
  if not os.path.exists(status_file_path):
343
343
  return None
344
344
  with open(status_file_path, 'r') as f:
345
- status_data = json.load(f)
345
+ try:
346
+ status_data = json.load(f)
347
+ except json.JSONDecodeError:
348
+ return None
346
349
 
347
350
  # Cache the status if it is not "running"
348
351
  if status_data['status'] != 'running':
@@ -382,6 +385,8 @@ def run_command(command, params, command_id):
382
385
 
383
386
  @app.before_request
384
387
  def check_authentication():
388
+ if not app.config['USER'] and not app.config['LDAP_SERVER']:
389
+ return
385
390
  if 'username' not in session and request.endpoint not in ['login', 'static']:
386
391
  return auth.login_required(lambda: None)()
387
392
 
@@ -518,7 +523,7 @@ def list_commands():
518
523
  params = shlex.join(status['params'])
519
524
  except AttributeError:
520
525
  params = " ".join([shlex.quote(p) if " " in p else p for p in status['params']])
521
- command = status['command'] + ' ' + params
526
+ command = status.get('command', '-') + ' ' + params
522
527
  commands.append({
523
528
  'command_id': command_id,
524
529
  'status': status['status'],
@@ -539,6 +544,8 @@ def get_command_output(command_id):
539
544
  with open(output_file_path, 'r') as output_file:
540
545
  output = output_file.read()
541
546
  status_data = read_command_status(command_id) or {}
547
+ if request.headers.get('Accept') == 'text/plain':
548
+ return f"{output}\nstatus: {status_data.get('status')}", 200, {'Content-Type': 'text/plain'}
542
549
  return jsonify({'output': output, 'status': status_data.get("status")})
543
550
  return jsonify({'error': 'Invalid command_id'}), 404
544
551
 
@@ -1,23 +1,46 @@
1
- body { font-family: Arial, sans-serif; }
2
- .table-container { height: 270px; overflow-y: auto; position: relative; }
3
- table { width: 100%; border-collapse: collapse; }
1
+ body {
2
+ font-family: Arial, sans-serif;
3
+ }
4
+ .table-container {
5
+ height: 270px;
6
+ overflow-y: auto;
7
+ position: relative;
8
+ border-radius: 10px;
9
+ border: 1px solid #aaa;
10
+ box-shadow: 0 0 10px rgba(0, 0, 0, 0.30);
11
+ }
12
+ table {
13
+ width: 100%;
14
+ border-collapse: collapse;
15
+ }
4
16
  th, td {
5
17
  padding: 8px;
6
18
  text-align: left;
7
19
  border-bottom: 1px solid #ddd;
8
20
  white-space: nowrap;
9
21
  }
10
- th { background-color: #f2f2f2; position: sticky; top: 0; z-index: 1; }
22
+ th {
23
+ background-color: #444;
24
+ color: #eee;
25
+ position: sticky;
26
+ top: 0;
27
+ z-index: 1;
28
+ }
11
29
  .outcol {
12
30
  width: 100%;
13
31
  }
32
+ select { /* Safari bug */
33
+ font-size: 15px;
34
+ border: #aaa solid 1px;
35
+ border-radius: 5px;
36
+ }
14
37
  .output {
15
38
  white-space: pre-wrap;
16
39
  background: #f0f0f0;
17
40
  padding: 10px;
18
41
  border: 1px solid #ccc;
19
42
  font-family: monospace;
20
- border-radius: 15px;
43
+ border-radius: 10px;
21
44
  overflow-y: auto;
22
45
  }
23
46
  .copy-icon { cursor: pointer; }
@@ -28,7 +51,6 @@ button {
28
51
  -webkit-border-radius: none;
29
52
  appearance: none;
30
53
  border-radius: 15px;
31
- padding: 3px;
32
54
  padding-right: 13px;
33
55
  border: 1px #555 solid;
34
56
  height: 22px;
@@ -49,8 +71,13 @@ form {
49
71
  background-repeat: no-repeat;
50
72
  vertical-align: middle;
51
73
  }
74
+ .title-icon {
75
+ width: 30px;
76
+ height: 30px;
77
+ background-image: url("/static/images/favicon.svg")
78
+ }
52
79
  .status-running {
53
- background-image: url("/static/images/running.svg")
80
+ background-image: url("/static/images/running.gif")
54
81
  }
55
82
  .status-success {
56
83
  background-image: url("/static/images/success.svg")
@@ -62,10 +89,10 @@ form {
62
89
  background-image: url("/static/images/aborted.svg")
63
90
  }
64
91
  .copy_clip {
65
- padding-right: 25px;
92
+ padding-right: 20px;
66
93
  background-repeat: no-repeat;
67
94
  background-position: right top;
68
- background-size: 25px 16px;
95
+ background-size: 20px 12px;
69
96
  white-space: nowrap;
70
97
  }
71
98
  .copy_clip:hover {
@@ -87,7 +114,7 @@ input {
87
114
  height: 15px;
88
115
  font-size: 15px;
89
116
  outline: none;
90
- text-indent: 10px;
117
+ text-indent: 5px;
91
118
  background-color: white;
92
119
  }
93
120
  .currentcommand {
@@ -96,6 +123,7 @@ input {
96
123
  .resizer {
97
124
  width: 100%;
98
125
  height: 5px;
126
+ border-radius: 5px;
99
127
  background: #aaa;
100
128
  cursor: ns-resize;
101
129
  position: absolute;
@@ -105,7 +133,8 @@ input {
105
133
  .resizer-container {
106
134
  position: relative;
107
135
  height: 5px;
108
- margin-bottom: 10px;
136
+ margin: 5px;
137
+ /*margin-bottom: 10px;*/
109
138
  }
110
139
  tr.clickable-row {
111
140
  cursor: pointer;
Binary file
@@ -33,7 +33,7 @@ async function fetchCommands() {
33
33
  commandRow.onclick = () => viewOutput(command.command_id);
34
34
  commandRow.innerHTML = `
35
35
  <td class="monospace">
36
- <span class="copy_clip" onclick="copyToClipboard('${command.command_id}', this)">${command.command_id.slice(0, 8)}</span>
36
+ ${navigator.clipboard == undefined ? `${command.command_id}` : `<span class="copy_clip" onclick="copyToClipboard('${command.command_id.slice(0, 8)}', this, event)">${command.command_id.slice(0, 8)}</span>`}
37
37
  </td>
38
38
  <td><span class="status-icon status-${command.status}"></span>${command.status}</td>
39
39
  <td>${formatTime(command.start_time)}</td>
@@ -41,8 +41,7 @@ async function fetchCommands() {
41
41
  <td>${command.exit_code}</td>
42
42
  <td>${command.command.replace(/^\.\//, '')}</td>
43
43
  <td>
44
- ${command.status === 'running' ? `<button onclick="stopCommand('${command.command_id}')">Stop</button>` : ` <button onclick="relaunchCommand('${command.command_id}')">Run</button>
45
- `}
44
+ ${command.status === 'running' ? `<button onclick="stopCommand('${command.command_id}')">Stop</button>` : `<button onclick="relaunchCommand('${command.command_id}')">Run</button>`}
46
45
  </td>
47
46
  <td class="monospace outcol">${command.last_output_line || ''}</td>
48
47
  `;
@@ -146,12 +145,14 @@ function formatDuration(startTime, endTime) {
146
145
  return `${hours}h ${minutes}m ${seconds}s`;
147
146
  }
148
147
 
149
- function copyToClipboard(text, element) {
148
+ function copyToClipboard(text, element, event) {
149
+ event.stopPropagation();
150
+ event.stopImmediatePropagation();
150
151
  navigator.clipboard.writeText(text).then(() => {
151
152
  element.classList.add('copy_clip_ok');
152
153
  setTimeout(() => {
153
154
  element.classList.remove('copy_clip_ok');
154
- }, 2000);
155
+ }, 1000);
155
156
  });
156
157
  }
157
158
 
@@ -7,7 +7,7 @@
7
7
  <link rel="stylesheet" href="/static/css/style.css">
8
8
  </head>
9
9
  <body>
10
- <h2>{{ title }}</h2>
10
+ <h2><span class="status-icon title-icon"></span>{{ title }}</h2>
11
11
  <form id="launchForm">
12
12
  <label for="commandName">Command</label>
13
13
  <select id="commandName" name="commandName"></select>
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.1.2'
16
- __version_tuple__ = version_tuple = (1, 1, 2)
15
+ __version__ = version = '1.1.11'
16
+ __version_tuple__ = version_tuple = (1, 1, 11)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: pywebexec
3
- Version: 1.1.2
3
+ Version: 1.1.11
4
4
  Summary: Simple Python HTTP Exec Server
5
5
  Home-page: https://github.com/joknarf/pywebexec
6
6
  Author: Franck Jouvanceau
@@ -30,7 +30,7 @@ License: MIT License
30
30
  Project-URL: Homepage, https://github.com/joknarf/pywebexec
31
31
  Project-URL: Documentation, https://github.com/joknarf/pywebexec/blob/main/README.md
32
32
  Project-URL: Repository, https://github.com/joknarf/pywebexec.git
33
- Keywords: http,fileserver,browser,explorer
33
+ Keywords: http,server,remote commands,api,website
34
34
  Classifier: Development Status :: 5 - Production/Stable
35
35
  Classifier: Intended Audience :: System Administrators
36
36
  Classifier: License :: OSI Approved :: MIT License
@@ -63,7 +63,7 @@ Requires-Dist: ldap3>=2.9.1
63
63
  [![Pypi version](https://img.shields.io/pypi/v/pywebexec.svg)](https://pypi.org/project/pywebexec/)
64
64
  ![example](https://github.com/joknarf/pywebexec/actions/workflows/python-publish.yml/badge.svg)
65
65
  [![Licence](https://img.shields.io/badge/licence-MIT-blue.svg)](https://shields.io/)
66
- [![](https://pepy.tech/badge/pywebexec)](https://pepy.tech/project/pywebexec)
66
+ [![PyPI Downloads](https://static.pepy.tech/badge/pywebexec)](https://pepy.tech/projects/pywebexec)
67
67
  [![Python versions](https://img.shields.io/badge/python-3.6+-blue.svg)](https://shields.io/)
68
68
 
69
69
  # pywebexec
@@ -83,7 +83,7 @@ $ pywebexec
83
83
  ```
84
84
 
85
85
  * Launch commands with params/view live output/Status using browser
86
- ![pywebexec](https://github.com/user-attachments/assets/d352cc23-1552-4b79-a6ff-f02f05cf328e)
86
+ ![pywebexecnew](https://github.com/user-attachments/assets/06290b5e-284e-4e41-b32a-0f5aad074658)
87
87
 
88
88
  all commands output / statuses are available in the executables directory in subdirectory `.web_status`
89
89
 
@@ -99,8 +99,8 @@ all commands output / statuses are available in the executables directory in sub
99
99
  * Basic Auth
100
100
  * LDAP(S)
101
101
  * Can be started as a daemon (POSIX)
102
- * uses gunicorn to serve http/https
103
- * compatible Linux/MacOS
102
+ * Uses gunicorn to serve http/https
103
+ * Linux/MacOS compatible
104
104
 
105
105
  ## Customize server
106
106
  ```shell
@@ -122,7 +122,7 @@ Generated password is given if no `--pasword` option
122
122
  $ export PYWEBEXEC_LDAP_SERVER=ldap://ldap.forumsys.com:389
123
123
  $ export PYWEBEXEC_LDAP_BIND_DN="cn=read-only-admin,dc=example,dc=com"
124
124
  $ export PYWEBEXEC_LDAP_BIND_PASSWORD="password"
125
- $ export PYWEBEXEC_LDAP_GROUPS=ou=mathematicians,ou=scientists
125
+ $ export PYWEBEXEC_LDAP_GROUPS="ou=mathematicians,ou=scientists"
126
126
  $ export PYWEBEXEC_LDAP_USER_ID="uid"
127
127
  $ export PYWEBEXEC_LDAP_BASE_DN="dc=example,dc=com"
128
128
  $ pywebexec
@@ -148,12 +148,14 @@ $ pywebexec start
148
148
  $ pywebexec status
149
149
  $ pywebexec stop
150
150
  ```
151
- * log of server are stored in directory `[.config/].pywebexec/pywebexec_<listen>:<port>.log`
151
+ * log of server are stored in directory `~/[.config/].pywebexec/pywebexec_<listen>:<port>.log`
152
152
 
153
153
  ## Launch command through API
154
154
 
155
155
  ```shell
156
- $ curl http://myhost:8080/run_script -H 'Content-Type: application/json' -X POST -d '{ "script_name":"myscript", "param":["param1", ...]}
156
+ $ curl http://myhost:8080/run_script -H 'Content-Type: application/json' -X POST -d '{ "script_name":"myscript", "params":["param1", ...]}
157
+ $ curl http://myhost:8080/command_status/<command_id>
158
+ $ curl http://myhost:8080/command_output/<command_id> -H "Accept: text/plain"
157
159
  ```
158
160
 
159
161
  ## API reference
@@ -0,0 +1,20 @@
1
+ pywebexec/__init__.py,sha256=4spIsVaF8RJt8S58AG_wWoORRNkws9Iwqprj27C3ljM,99
2
+ pywebexec/pywebexec.py,sha256=nXo0K6dBS9zKRUEP1hFyGWpL3BV2sUku3CFeGi0QQ-w,21479
3
+ pywebexec/version.py,sha256=9JSmVS_AC0iwzCn3SBDWoTqahTE6DWQZLNs5YmBeMMk,413
4
+ pywebexec/static/css/style.css,sha256=rYpzhBftpZ9pw_FTZFwcAnGC9-EhVOOSy6w56Ybe-Wk,2902
5
+ pywebexec/static/images/aborted.svg,sha256=_mP43hU5QdRLFZIknBgjx-dIXrHgQG23-QV27ApXK2A,381
6
+ pywebexec/static/images/copy.svg,sha256=d9OwtGh5GzzZHzYcDrLfNxZYLth1Q64x7bRyYxu4Px0,622
7
+ pywebexec/static/images/copy_ok.svg,sha256=mEqUVUhSq8xaJK2msQkxRawnz_KwlCZ-tok8QS6hJ3g,451
8
+ pywebexec/static/images/failed.svg,sha256=ADZ7IKrUyOXtqpivnz3VcH0-Wru-I5MOi3OJAkI3hxk,1439
9
+ pywebexec/static/images/favicon.svg,sha256=ti80IfuDZwIvQcmJxkOeUaB1iMsiyOPmQmVO-h0y1IU,1126
10
+ pywebexec/static/images/running.gif,sha256=iYuzQGkMxrakSIwt6gPieKCImGZoSAHmU5MUNZa7cpw,25696
11
+ pywebexec/static/images/success.svg,sha256=PJDcCSTevJh7rkfSFLtc7P0pbeh8PVQBS8DaOLQemmc,489
12
+ pywebexec/static/js/script.js,sha256=fbxMRP_BsRNYlFRJjVipaahV9_7letVITJD0ic4IwfA,7230
13
+ pywebexec/templates/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
+ pywebexec/templates/index.html,sha256=7dFHAmHXGMrK1-M6PIAbMS0bv7Pi5-6vDoyUk3irnQc,1346
15
+ pywebexec-1.1.11.dist-info/LICENSE,sha256=gRJf0JPT_wsZJsUGlWPTS8Vypfl9vQ1qjp6sNbKykuA,1064
16
+ pywebexec-1.1.11.dist-info/METADATA,sha256=fc3XLIyoELPSQnOZsUFyFrGCb1OCfrB8AeX3J1ytMqE,6906
17
+ pywebexec-1.1.11.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
18
+ pywebexec-1.1.11.dist-info/entry_points.txt,sha256=l52GBkPCXRkmlHfEyoVauyfBdg8o-CAtC8qQpOIjJK0,55
19
+ pywebexec-1.1.11.dist-info/top_level.txt,sha256=vHoHyzngrfGdm_nM7Xn_5iLmaCrf10XO1EhldgNLEQ8,10
20
+ pywebexec-1.1.11.dist-info/RECORD,,
@@ -1 +0,0 @@
1
- <svg viewBox="0 0 1024 1024" class="icon" version="1.1" xmlns="http://www.w3.org/2000/svg" fill="#000000"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"><path d="M661.333333 170.666667l253.866667 34.133333-209.066667 209.066667zM362.666667 853.333333L108.8 819.2l209.066667-209.066667zM170.666667 362.666667L204.8 108.8l209.066667 209.066667z" fill="#4949d1"></path><path d="M198.4 452.266667l-89.6 17.066666c-2.133333 14.933333-2.133333 27.733333-2.133333 42.666667 0 98.133333 34.133333 192 98.133333 264.533333l64-55.466666C219.733333 663.466667 192 588.8 192 512c0-19.2 2.133333-40.533333 6.4-59.733333zM512 106.666667c-115.2 0-217.6 49.066667-292.266667 125.866666l59.733334 59.733334C339.2 230.4 420.266667 192 512 192c19.2 0 40.533333 2.133333 59.733333 6.4l14.933334-83.2C563.2 108.8 537.6 106.666667 512 106.666667zM825.6 571.733333l89.6-17.066666c2.133333-14.933333 2.133333-27.733333 2.133333-42.666667 0-93.866667-32-185.6-91.733333-258.133333l-66.133333 53.333333c46.933333 57.6 72.533333 130.133333 72.533333 202.666667 0 21.333333-2.133333 42.666667-6.4 61.866666zM744.533333 731.733333C684.8 793.6 603.733333 832 512 832c-19.2 0-40.533333-2.133333-59.733333-6.4l-14.933334 83.2c25.6 4.266667 51.2 6.4 74.666667 6.4 115.2 0 217.6-49.066667 292.266667-125.866667l-59.733334-57.6z" fill="#4949d1"></path><path d="M853.333333 661.333333l-34.133333 253.866667-209.066667-209.066667z" fill="#4949d1"></path></g></svg>
@@ -1,20 +0,0 @@
1
- pywebexec/__init__.py,sha256=4spIsVaF8RJt8S58AG_wWoORRNkws9Iwqprj27C3ljM,99
2
- pywebexec/pywebexec.py,sha256=mRvTAK8O9VtGPqUdQxIeYBzpjLYkYVru1rzWmS3Ui5Q,21149
3
- pywebexec/version.py,sha256=nmVMEP2kpLDIzjgS-U1taCdJbVrmv_k8ao6RojGcvRg,411
4
- pywebexec/static/css/style.css,sha256=NiBoOzZ35eBM1ZP2HFNda-dzOsAv4xRPh3vsvVgLL9c,2513
5
- pywebexec/static/images/aborted.svg,sha256=_mP43hU5QdRLFZIknBgjx-dIXrHgQG23-QV27ApXK2A,381
6
- pywebexec/static/images/copy.svg,sha256=d9OwtGh5GzzZHzYcDrLfNxZYLth1Q64x7bRyYxu4Px0,622
7
- pywebexec/static/images/copy_ok.svg,sha256=mEqUVUhSq8xaJK2msQkxRawnz_KwlCZ-tok8QS6hJ3g,451
8
- pywebexec/static/images/failed.svg,sha256=ADZ7IKrUyOXtqpivnz3VcH0-Wru-I5MOi3OJAkI3hxk,1439
9
- pywebexec/static/images/favicon.svg,sha256=ti80IfuDZwIvQcmJxkOeUaB1iMsiyOPmQmVO-h0y1IU,1126
10
- pywebexec/static/images/running.svg,sha256=vBpiG6ClNUNCArkwsyqK7O-qhIKJX1NI7MSjclNSp_8,1537
11
- pywebexec/static/images/success.svg,sha256=PJDcCSTevJh7rkfSFLtc7P0pbeh8PVQBS8DaOLQemmc,489
12
- pywebexec/static/js/script.js,sha256=RrlozMlUx_7MJTf7IG98rzJsLgwEMyEV9bSW6QpQdZw,7088
13
- pywebexec/templates/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
- pywebexec/templates/index.html,sha256=Q3tubZjBzq4v1aV_BDFSvAKnoim-wKo3EkE_pkA2jm4,1302
15
- pywebexec-1.1.2.dist-info/LICENSE,sha256=gRJf0JPT_wsZJsUGlWPTS8Vypfl9vQ1qjp6sNbKykuA,1064
16
- pywebexec-1.1.2.dist-info/METADATA,sha256=7f5boEeNnoqAijinCKAqx-gPL_tGLOxdLe1Jdp9xYVI,6736
17
- pywebexec-1.1.2.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
18
- pywebexec-1.1.2.dist-info/entry_points.txt,sha256=l52GBkPCXRkmlHfEyoVauyfBdg8o-CAtC8qQpOIjJK0,55
19
- pywebexec-1.1.2.dist-info/top_level.txt,sha256=vHoHyzngrfGdm_nM7Xn_5iLmaCrf10XO1EhldgNLEQ8,10
20
- pywebexec-1.1.2.dist-info/RECORD,,