pywebexec 2.0.5__py3-none-any.whl → 2.0.6__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
@@ -1007,7 +1007,7 @@ def swagger_yaml():
1007
1007
  "parameters": [
1008
1008
  {
1009
1009
  "in": "body",
1010
- "name": "commandRequest",
1010
+ "name": "reuqestBody",
1011
1011
  "schema": cmd_schema
1012
1012
  }
1013
1013
  ],
@@ -66,9 +66,14 @@
66
66
  font-size: 14px;
67
67
  color: #333;
68
68
  background-color: #dfdfff;
69
- padding: 1px 4px;
70
69
  border-radius: 5px;
71
70
  }
71
+ code {
72
+ padding: 1px 4px;
73
+ }
74
+ pre code {
75
+ padding: 0;
76
+ }
72
77
  pre {
73
78
  padding: 5px 10px;
74
79
  border-radius: 10px;
@@ -420,7 +420,7 @@ body.dimmed * {
420
420
  font-size: 13px;
421
421
  }
422
422
  .command-line {
423
- padding: 6px 10px 6px 10px;
423
+ padding: 5px 10px 6px 10px;
424
424
  background-color: #111;
425
425
  color: #eee;
426
426
  max-width: 300px;
@@ -429,7 +429,7 @@ body.dimmed * {
429
429
  overflow: hidden;
430
430
  text-overflow: ellipsis;
431
431
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
432
- font-size: 13px;
432
+ font-size: 14px;
433
433
  }
434
434
 
435
435
  .nbrunning {
@@ -34,7 +34,7 @@ function filterCommands() {
34
34
  items[i].style.display = 'none';
35
35
  }
36
36
  }
37
- if (nbVisibleItems > 1) {
37
+ if (nbVisibleItems > 1 || commandInput.value.length == 0) {
38
38
  commandListDiv.style.display = 'block';
39
39
  } else {
40
40
  commandListDiv.style.display = 'none';
pywebexec/swagger.yaml CHANGED
@@ -47,7 +47,7 @@ paths:
47
47
  - application/json
48
48
  parameters:
49
49
  - in: body
50
- name: commandRequest
50
+ name: requestBody
51
51
  schema:
52
52
  type: object
53
53
  properties:
pywebexec/version.py CHANGED
@@ -17,5 +17,5 @@ __version__: str
17
17
  __version_tuple__: VERSION_TUPLE
18
18
  version_tuple: VERSION_TUPLE
19
19
 
20
- __version__ = version = '2.0.5'
21
- __version_tuple__ = version_tuple = (2, 0, 5)
20
+ __version__ = version = '2.0.6'
21
+ __version_tuple__ = version_tuple = (2, 0, 6)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: pywebexec
3
- Version: 2.0.5
3
+ Version: 2.0.6
4
4
  Summary: Simple Python HTTP Exec Server
5
5
  Home-page: https://github.com/joknarf/pywebexec
6
6
  Author: Franck Jouvanceau
@@ -208,12 +208,67 @@ The help message is displayed:
208
208
 
209
209
  <img src="https://github.com/user-attachments/assets/2d69cef2-3371-4282-99bb-e994eb0c0b24" width="400"/>
210
210
 
211
+ ## Add schema to commands
212
+
213
+ For each exposed command, you can add a schema by creating a file named `<command>.schema.yaml` in the same directory as the command. The schema must be written in yaml format.
214
+ The schema is used to generate a form in the web interface and in the swagger-ui in the `/commands/<command>` route.
215
+ The schema is also used to validate the input parameters when calling the API `/commands/<command>`.
216
+ The schema must be written in the openapi schema format.
217
+
218
+ ```yaml
219
+ type: object
220
+ properties:
221
+ param1:
222
+ type: string
223
+ description: "param1 description"
224
+ example: "value"
225
+ param2:
226
+ type: integer
227
+ description: "param2 description"
228
+ enum: [1, 2, 3]
229
+ param3:
230
+ type: array
231
+ items:
232
+ type: string
233
+ description: "param3 description"
234
+ example: ["value1", "value2"]
235
+ required:
236
+ - param1
237
+ - param2
238
+ ```
239
+ The payload will be converted to command line arguments when calling the command.
240
+ ```
241
+ command --param1 value --param2 1 --param3 value1 value2
242
+ ```
243
+
244
+ * On the web inferface, and swagger-ui the form will be generated from the schema.
245
+
246
+ <img src="https://github.com/user-attachments/assets/c7cdf117-aa38-4366-97c7-1aa26e5ebf0d" width=400>
247
+
248
+ When using schema, the command can now be launched with:
249
+ ```
250
+ $ curl -X POST http://<srv>/commands/<cmd> -H "Content-Type: application/json" -d '{"param1": "value", "param2": 1, "param3": ["value1", "value2"]}'
251
+ ```
252
+
253
+ ## Schema options
254
+
255
+ The schema options are used to customize the command line arguments generation, just add a `schema_options` section to the schema.
256
+ ```yaml
257
+ schema_options:
258
+ separator: "=" # --param=value (default is " ")
259
+ noprefix_params: ["param1", "param2"] # omit --param prefix, use "*" to omit all
260
+ convert_params: {"param1": "param2"} # convert param1 to param2
261
+ ```
262
+
211
263
  ## Swagger UI
212
264
 
213
- A swagger UI is available at `http[s]://<srv>/v0/documentation`
265
+ A custom swagger UI is available at `http[s]://<srv>/v0/documentation` with enhanced markdown rendering and form generation for body parameters.
214
266
 
215
267
  <img src="https://github.com/user-attachments/assets/c80a341e-c04c-4606-9510-a57b473a74e5" width="400"/>
216
268
 
269
+ <img src="https://github.com/user-attachments/assets/22261048-459e-4ace-8d04-c568d67bef37" width="400">
270
+
271
+
217
272
  ## API reference
218
273
 
219
274
 
@@ -1,11 +1,11 @@
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=BQtNhOJImk5jzAldE3XxQbkn4VHJ5kkGvWx4oLAxVsM,40741
4
- pywebexec/swagger.yaml,sha256=0fM22kXURoLi97xSncRuVBLaUB5iYA6ROkB9YaLrlwM,5861
5
- pywebexec/version.py,sha256=UwrRCi4EXT2M-9b7px4pzWAWypR42eEWODHeqQoFYpU,511
3
+ pywebexec/pywebexec.py,sha256=bC9mOWBsOEVX_70BfJl6tF-4T0tm2WXcBvxcLprN4rw,40738
4
+ pywebexec/swagger.yaml,sha256=j-KZnU4rGR-Fsk8y_EbqYzqVgtAZ8EjZIKAqZSxyyc0,5858
5
+ pywebexec/version.py,sha256=Fo_Ssf3RDhryNW1qawxeulSMH8DrIVOcRvBytMAoNrc,511
6
6
  pywebexec/static/css/form.css,sha256=V8EeV7LTmIcbbi-lDdQ39SYNL02lWIOzYY9zyhJp204,3530
7
- pywebexec/static/css/markdown.css,sha256=CxvZsCt6h7VcNTeyrrEsZpd4VuTFmWA33Y68T2N0pOU,1881
8
- pywebexec/static/css/style.css,sha256=JBG_0DphjyZmFlno_-EeKzihl6KeDlhcQUb6RIx2RIA,9434
7
+ pywebexec/static/css/markdown.css,sha256=3RzUnpVBdF6cQuB_NXV7hMTc0quYU8sfyuZcpsREj6A,1939
8
+ pywebexec/static/css/style.css,sha256=o5iWsFOYtP1W-R_lTcWoaxzlh8EoaL__ycVZOori1Ws,9434
9
9
  pywebexec/static/css/swagger-ui.css,sha256=xhXN8fnUaIACGHuPIEIr9-qmyYr6Zx0k2wv4Qy7Bg1Y,154985
10
10
  pywebexec/static/css/swagger-ui.css.map,sha256=dJy-xBn_htK4BNupTMIl33ddse7BXsrCdDJWlTJodnw,258842
11
11
  pywebexec/static/css/xterm.css,sha256=uo5phWaUiJgcz0DAzv46uoByLLbJLeetYosL1xf68rY,5559
@@ -33,7 +33,7 @@ pywebexec/static/images/resume.svg,sha256=99LP1Ya2JXakRCO9kW8JMuT_4a_CannF65Eiuw
33
33
  pywebexec/static/images/running.svg,sha256=fBCYwYb2O9K4N3waC2nURP25NRwZlqR4PbDZy6JQMww,610
34
34
  pywebexec/static/images/success.svg,sha256=NVwezvVMplt46ElW798vqGfrL21Mw_DWHUp_qiD_FU8,489
35
35
  pywebexec/static/images/swagger-ui.svg,sha256=FR0yeOVwe4zCYKZAjCGcT_m0Mf25NexIVaSXifIkoU0,2117
36
- pywebexec/static/js/executables.js,sha256=NC5KZsq665oheVWVHTHRpr95iUHnLdF_Lck-obBXh3w,11728
36
+ pywebexec/static/js/executables.js,sha256=iltgIJXWVUxAUhBfXGCHSP8mK8cQdtg-AagbGe7Hv9o,11762
37
37
  pywebexec/static/js/popup.js,sha256=0fr3pp4j9D2fXEVnHyQrx2bPWFHfgbb336dbewgH1d8,9023
38
38
  pywebexec/static/js/schemaform.js,sha256=bd874Geg9vri1c_seUGVynxZswGb5IcyWLZxYlcryCA,2784
39
39
  pywebexec/static/js/script.js,sha256=fwTo9Iz4xsl6wGs-Nm8-Ng8aXzDfvews5cHfzhSfg_0,17987
@@ -66,9 +66,9 @@ pywebexec/templates/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSu
66
66
  pywebexec/templates/index.html,sha256=KeNLBH9PN_ZuGhzwrjvRTj2oBtbINv_SbwGQpOahNWo,3820
67
67
  pywebexec/templates/popup.html,sha256=3kpMccKD_OLLhJ4Y9KRw6Ny8wQWjVaRrUfV9y5-bDiQ,1580
68
68
  pywebexec/templates/swagger_ui.html,sha256=9ngyldkyEdLonBjl97mbIZUlVk-jxwcHrvFzMSrveyU,1067
69
- pywebexec-2.0.5.dist-info/LICENSE,sha256=gRJf0JPT_wsZJsUGlWPTS8Vypfl9vQ1qjp6sNbKykuA,1064
70
- pywebexec-2.0.5.dist-info/METADATA,sha256=kD2sukHFymHzkEPXIVjI91SnNaECKRhedjP8Mx0KRb8,9644
71
- pywebexec-2.0.5.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
72
- pywebexec-2.0.5.dist-info/entry_points.txt,sha256=l52GBkPCXRkmlHfEyoVauyfBdg8o-CAtC8qQpOIjJK0,55
73
- pywebexec-2.0.5.dist-info/top_level.txt,sha256=vHoHyzngrfGdm_nM7Xn_5iLmaCrf10XO1EhldgNLEQ8,10
74
- pywebexec-2.0.5.dist-info/RECORD,,
69
+ pywebexec-2.0.6.dist-info/LICENSE,sha256=gRJf0JPT_wsZJsUGlWPTS8Vypfl9vQ1qjp6sNbKykuA,1064
70
+ pywebexec-2.0.6.dist-info/METADATA,sha256=Fhj5kZ-HH8yPPDp72ES7MAMJ-6_RkHVFzzVv-_aRMM4,11615
71
+ pywebexec-2.0.6.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
72
+ pywebexec-2.0.6.dist-info/entry_points.txt,sha256=l52GBkPCXRkmlHfEyoVauyfBdg8o-CAtC8qQpOIjJK0,55
73
+ pywebexec-2.0.6.dist-info/top_level.txt,sha256=vHoHyzngrfGdm_nM7Xn_5iLmaCrf10XO1EhldgNLEQ8,10
74
+ pywebexec-2.0.6.dist-info/RECORD,,