script-server
script-server copied to clipboard
default value and variable error
Hi, I'm not sure if this is expected behavior or a bug.
############################### { "name": "Select seftware to set", "param": "-b", "type": "list", "default": "networkaudiod", "values": [ "networkaudiod", "squeezelite-R2", "squeezelite" ], "description": "Select seftware to set" }, { "name": "Set affinity", "param": "-c", "type": "text", "default": { "script": "/opt/.gentooplayer/web/scripts/script/expert1/${Select seftware to set}/affinity.sh" }, "description": "Set CPU affinity" }, ################################
2020-07-12 07:27:23,794 [root.INFO] Starting GentooPlayer, v1.16.0-master@995fec1 2020-07-12 07:27:23,811 [asyncio.DEBUG] Using selector: EpollSelector Server is running on: http://0.0.0.0:5000 2020-07-12 07:27:27,678 [identification.INFO] Assigned user_id=192.168.178.22-6d9fb38bcbd547e6 to {'ip': '192.168.178.22', 'hostname': 'GentooServer.fritz.box'} 2020-07-12 07:27:27,719 [tornado.access.INFO] 304 GET /index.html (192.168.178.22) 45.99ms 2020-07-12 07:27:27,748 [tornado.access.INFO] 304 GET /css/chunk-index-vendors.47bd9eac.css (192.168.178.22) 3.77ms 2020-07-12 07:27:27,758 [tornado.access.INFO] 304 GET /css/index.00b840dd.css (192.168.178.22) 7.60ms 2020-07-12 07:27:27,763 [tornado.access.INFO] 304 GET /js/chunk-index-vendors.3dee9c44.js (192.168.178.22) 10.09ms 2020-07-12 07:27:27,766 [tornado.access.INFO] 304 GET /js/index.807c7662.js (192.168.178.22) 11.71ms 2020-07-12 07:27:27,800 [tornado.access.INFO] 304 GET /favicon.ico (192.168.178.22) 3.14ms 2020-07-12 07:27:27,836 [tornado.access.INFO] 304 GET /img/titleBackground_small.8d99a14e.jpg (192.168.178.22) 3.40ms 2020-07-12 07:27:27,842 [tornado.access.INFO] 304 GET /executions/active (192.168.178.22) 3.13ms 2020-07-12 07:27:27,847 [tornado.access.INFO] 304 GET /auth/info (192.168.178.22) 4.36ms 2020-07-12 07:27:27,849 [tornado.access.INFO] 304 GET /conf (192.168.178.22) 5.11ms 2020-07-12 07:27:27,880 [tornado.access.INFO] 304 GET /scripts (192.168.178.22) 35.12ms 2020-07-12 07:27:27,895 [tornado.access.INFO] 101 GET /scripts/Set%20software (192.168.178.22) 3.91ms 2020-07-12 07:27:27,947 [web_server.ERROR] Failed to load script config Set software Traceback (most recent call last): File "src/web/server.py", line 268, in open self.config_model = yield load_config_future File "/usr/lib/python3.7/site-packages/tornado/gen.py", line 735, in run value = future.result() File "/usr/lib/python3.7/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "src/config/config_service.py", line 124, in load_config_model return self._load_script_config(path, json_object, user, parameter_values) File "src/config/config_service.py", line 188, in _load_script_config parameter_values=parameter_values) File "src/model/script_config.py", line 66, in init self._init_parameters(username, audit_name) File "src/model/script_config.py", line 139, in _init_parameters self.working_directory) File "src/model/parameter_config.py", line 54, in init self._reload() File "src/model/parameter_config.py", line 74, in _reload self.default = _resolve_default(config.get('default'), self._username, self._audit_name, self._working_dir) File "src/model/parameter_config.py", line 419, in _resolve_default output = process_utils.invoke(resolved_string_value, working_dir) File "src/utils/process_utils.py", line 27, in invoke universal_newlines=True) File "/usr/lib/python3.7/subprocess.py", line 800, in init restore_signals, start_new_session) File "/usr/lib/python3.7/subprocess.py", line 1551, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: '/opt/.gentooplayer/web/scripts/script/expert1/${Select': '/opt/.gentooplayer/web/scripts/script/expert1/${Select'
I think it's more like a bug. But could you try wrapiing the variable in double quotes: "${Select software}"
antonellocaroli [email protected] schrieb am So., 12. Juli 2020, 07:30:
Hi, I'm not sure if this is expected behavior or a bug. { "name": "Select seftware to set", "param": "-b", "type": "list", "default": "networkaudiod", "values": [ "networkaudiod", "squeezelite-R2", "squeezelite" ], "description": "Select seftware to set" }, { "name": "Set affinity", "param": "-c", "type": "text", "default": { "script": "/opt/.gentooplayer/web/scripts/script/expert1/${Select seftware to set}/affinity.sh" }, "description": "Set CPU affinity" },
2020-07-12 07:27:23,794 [root.INFO] Starting GentooPlayer, v1.16.0-master@995fec1 2020-07-12 07:27:23,811 [asyncio.DEBUG] Using selector: EpollSelector Server is running on: http://0.0.0.0:5000 2020-07-12 07:27:27,678 [identification.INFO] Assigned user_id=192.168.178.22-6d9fb38bcbd547e6 to {'ip': '192.168.178.22', 'hostname': 'GentooServer.fritz.box'} 2020-07-12 07:27:27,719 [tornado.access.INFO] 304 GET /index.html (192.168.178.22) 45.99ms 2020-07-12 07:27:27,748 [tornado.access.INFO] 304 GET /css/chunk-index-vendors.47bd9eac.css (192.168.178.22) 3.77ms 2020-07-12 07:27:27,758 [tornado.access.INFO] 304 GET /css/index.00b840dd.css (192.168.178.22) 7.60ms 2020-07-12 07:27:27,763 [tornado.access.INFO] 304 GET /js/chunk-index-vendors.3dee9c44.js (192.168.178.22) 10.09ms 2020-07-12 07:27:27,766 [tornado.access.INFO] 304 GET /js/index.807c7662.js (192.168.178.22) 11.71ms 2020-07-12 07:27:27,800 [tornado.access.INFO] 304 GET /favicon.ico (192.168.178.22) 3.14ms 2020-07-12 07:27:27,836 [tornado.access.INFO] 304 GET /img/titleBackground_small.8d99a14e.jpg (192.168.178.22) 3.40ms 2020-07-12 07:27:27,842 [tornado.access.INFO] 304 GET /executions/active (192.168.178.22) 3.13ms 2020-07-12 07:27:27,847 [tornado.access.INFO] 304 GET /auth/info (192.168.178.22) 4.36ms 2020-07-12 07:27:27,849 [tornado.access.INFO] 304 GET /conf (192.168.178.22) 5.11ms 2020-07-12 07:27:27,880 [tornado.access.INFO] 304 GET /scripts (192.168.178.22) 35.12ms 2020-07-12 07:27:27,895 [tornado.access.INFO] 101 GET /scripts/Set%20software (192.168.178.22) 3.91ms 2020-07-12 07:27:27,947 [web_server.ERROR] Failed to load script config Set software Traceback (most recent call last): File "src/web/server.py", line 268, in open self.config_model = yield load_config_future File "/usr/lib/python3.7/site-packages/tornado/gen.py", line 735, in run value = future.result() File "/usr/lib/python3.7/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "src/config/config_service.py", line 124, in load_config_model return self._load_script_config(path, json_object, user, parameter_values) File "src/config/config_service.py", line 188, in _load_script_config parameter_values=parameter_values) File "src/model/script_config.py", line 66, in init self._init_parameters(username, audit_name) File "src/model/script_config.py", line 139, in _init_parameters self.working_directory) File "src/model/parameter_config.py", line 54, in init self._reload() File "src/model/parameter_config.py", line 74, in _reload self.default = _resolve_default(config.get('default'), self._username, self._audit_name, self._working_dir) File "src/model/parameter_config.py", line 419, in _resolve_default output = process_utils.invoke(resolved_string_value, working_dir) File "src/utils/process_utils.py", line 27, in invoke universal_newlines=True) File "/usr/lib/python3.7/subprocess.py", line 800, in init restore_signals, start_new_session) File "/usr/lib/python3.7/subprocess.py", line 1551, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: '/opt/.gentooplayer/web/scripts/script/expert1/${Select': '/opt/.gentooplayer/web/scripts/script/expert1/${Select'
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/bugy/script-server/issues/320, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJXPJLP4RKPUHOR3QGJ5M3R3FC7JANCNFSM4OXUMECQ .
no, it's not working.
and it doesn't work changing like that either:
################# { "name": "Select seftware to set", "param": "-b", "type": "list", "default": "networkaudiod", "values": [ "networkaudiod", "squeezelite-R2", "squeezelite" ], "description": "Select seftware to set" }, { "name": "Set affinity", "param": "-c", "type": "text", "default": { "script": "/opt/.gentooplayer/web/scripts/script/expert1/software/affinity.sh ${Select seftware to set}" }, "description": "Set CPU affinity" }, #################### 2020-07-12 09:17:37,436 [tornado.access.INFO] 101 GET /scripts/Set%20software (192.168.178.22) 3.94ms 2020-07-12 09:17:37,494 [web_server.ERROR] Failed to load script config Set software Traceback (most recent call last): File "src/web/server.py", line 268, in open self.config_model = yield load_config_future File "/usr/lib/python3.7/site-packages/tornado/gen.py", line 735, in run value = future.result() File "/usr/lib/python3.7/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "src/config/config_service.py", line 124, in load_config_model return self._load_script_config(path, json_object, user, parameter_values) File "src/config/config_service.py", line 188, in _load_script_config parameter_values=parameter_values) File "src/model/script_config.py", line 66, in init self._init_parameters(username, audit_name) File "src/model/script_config.py", line 139, in _init_parameters self.working_directory) File "src/model/parameter_config.py", line 54, in init self._reload() File "src/model/parameter_config.py", line 74, in _reload self.default = _resolve_default(config.get('default'), self._username, self._audit_name, self._working_dir) File "src/model/parameter_config.py", line 419, in _resolve_default output = process_utils.invoke(resolved_string_value, working_dir) File "src/utils/process_utils.py", line 33, in invoke raise ExecutionException(result_code, error, output) utils.process_utils.ExecutionException: Execution failed. Code 127: /opt/.gentooplayer/web/scripts/script/expert1/software/affinity.sh: line 3: /opt/.gentooplayer/web/scripts/script/expert1/${Select/affinity.sh: No such file or directory
Hi, variables are not supported in default
field. Only authentication
parameters.
Default fields are initialized at script load time, so base them on
variables doesnt make much sense
antonellocaroli [email protected] schrieb am So., 12. Juli 2020, 09:19:
no, it's not working.
and it doesn't work changing like that either:
################# { "name": "Select seftware to set", "param": "-b", "type": "list", "default": "networkaudiod", "values": [ "networkaudiod", "squeezelite-R2", "squeezelite" ], "description": "Select seftware to set" }, { "name": "Set affinity", "param": "-c", "type": "text", "default": { "script": "/opt/.gentooplayer/web/scripts/script/expert1/software/affinity.sh ${Select seftware to set}" }, "description": "Set CPU affinity" }, #################### 2020-07-12 09:17:37,436 [tornado.access.INFO] 101 GET /scripts/Set%20software (192.168.178.22) 3.94ms 2020-07-12 09:17:37,494 [web_server.ERROR] Failed to load script config Set software Traceback (most recent call last): File "src/web/server.py", line 268, in open self.config_model = yield load_config_future File "/usr/lib/python3.7/site-packages/tornado/gen.py", line 735, in run value = future.result() File "/usr/lib/python3.7/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "src/config/config_service.py", line 124, in load_config_model return self._load_script_config(path, json_object, user, parameter_values) File "src/config/config_service.py", line 188, in _load_script_config parameter_values=parameter_values) File "src/model/script_config.py", line 66, in init self._init_parameters(username, audit_name) File "src/model/script_config.py", line 139, in _init_parameters self.working_directory) File "src/model/parameter_config.py", line 54, in init self._reload() File "src/model/parameter_config.py", line 74, in _reload self.default = _resolve_default(config.get('default'), self._username, self._audit_name, self._working_dir) File "src/model/parameter_config.py", line 419, in _resolve_default output = process_utils.invoke(resolved_string_value, working_dir) File "src/utils/process_utils.py", line 33, in invoke raise ExecutionException(result_code, error, output) utils.process_utils.ExecutionException: Execution failed. Code 127: /opt/.gentooplayer/web/scripts/script/expert1/software/affinity.sh: line 3: /opt/.gentooplayer/web/scripts/script/expert1/${Select/affinity.sh: No such file or directory
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/bugy/script-server/issues/320#issuecomment-657185362, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJXPJNSO72VBWHJC5QSUWDR3FPZVANCNFSM4OXUMECQ .
ok, but how do I calculate a certain value based on the first parameter chosen? I can't find a solution...
I'm afraid it's not possible :(
antonellocaroli [email protected] schrieb am Mo., 13. Juli 2020, 18:38:
ok, but how do I calculate a certain value based on the first parameter chosen? I can't find a solution...
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/bugy/script-server/issues/320#issuecomment-657665192, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJXPJJLAKRHVC4APQSRVUDR3MZ7HANCNFSM4OXUMECQ .
Fixed, now parameters can be specified in "default" section. A new default value will override the existing value in 2 of the cases:
- if the existing value is empty
- if the existing value equal to the previous default
In other words, if a user modifies a value manually, the new default value will be ignored.
Thank you @bugy ,
works perfectly.
I have 5 parameters that change according to the choice of parameter 1.
Only one parameter does not update, it only updates if I refresh the page, or if I wait a while, maybe it's a timing issue.
2023-03-17 16:00:22,321 [root.INFO] Starting Script Server, v1.18.0-master@a4c38f7
2023-03-17 16:00:22,360 [asyncio.DEBUG] Using selector: EpollSelector
Server is running on: http://0.0.0.0:5000
2023-03-17 16:00:23,820 [tornado.access.INFO] 101 GET /scripts/22.%20Set%20Software%20Process?initWithValues=true (10.0.0.4) 4.40ms
2023-03-17 16:00:28,094 [tornado.access.INFO] 304 GET /index.html (10.0.0.4) 40.16ms
2023-03-17 16:00:28,099 [tornado.access.INFO] 101 GET /scripts/22.%20Set%20Software%20Process?initWithValues=true (10.0.0.4) 2.70ms
2023-03-17 16:00:28,112 [tornado.general.ERROR] Could not open static file '/opt/.gentooplayer/web/conf/theme/theme.css'
2023-03-17 16:00:28,113 [tornado.access.INFO] 200 GET /theme/theme.css (10.0.0.4) 2.30ms
2023-03-17 16:00:28,141 [tornado.access.INFO] 304 GET /auth/info (10.0.0.4) 5.17ms
2023-03-17 16:00:28,154 [tornado.access.INFO] 304 GET /conf (10.0.0.4) 10.13ms
2023-03-17 16:00:28,402 [tornado.access.INFO] 304 GET /scripts (10.0.0.4) 254.95ms
2023-03-17 16:00:28,404 [tornado.access.INFO] 304 GET /executions/active (10.0.0.4) 254.10ms
2023-03-17 16:00:28,423 [tornado.access.INFO] 101 GET /scripts/22.%20Set%20Software%20Process?initWithValues=false (10.0.0.4) 2.47ms
2023-03-17 16:00:33,498 [web_server.INFO] Calling script 22. Set Software Process. User {'ip': '10.0.0.4', 'hostname': 'unknown04421a95ced9.home'}
2023-03-17 16:00:33,607 [script_server.execution_service.INFO] Calling script #17: /opt/.gentooplayer/web/scripts/expert1_software.sh -W networkaudiod -a disable -b 4 -c -10 -g r -d 55
2023-03-17 16:00:33,621 [tornado.access.INFO] 200 POST /executions/start (10.0.0.4) 377.82ms
2023-03-17 16:00:33,634 [tornado.access.INFO] 101 GET /executions/io/17 (10.0.0.4) 2.46ms
2023-03-17 16:00:34,125 [web_server.INFO] unknown04421a95ced9.home disconnected
2023-03-17 16:00:34,134 [tornado.access.INFO] 200 POST /executions/cleanup/17 (10.0.0.4) 5.99ms
2023-03-17 16:00:40,805 [web_server.INFO] Calling script 22. Set Software Process. User {'ip': '10.0.0.4', 'hostname': 'unknown04421a95ced9.home'}
2023-03-17 16:00:40,913 [script_server.execution_service.INFO] Calling script #18: /opt/.gentooplayer/web/scripts/expert1_software.sh -W squeezelite -a enable -b 3 -c -5 -g b -d 64
2023-03-17 16:00:40,919 [tornado.access.INFO] 200 POST /executions/start (10.0.0.4) 371.14ms
2023-03-17 16:00:40,931 [tornado.access.INFO] 101 GET /executions/io/18 (10.0.0.4) 2.03ms
2023-03-17 16:00:41,625 [web_server.INFO] unknown04421a95ced9.home disconnected
2023-03-17 16:00:41,634 [tornado.access.INFO] 200 POST /executions/cleanup/18 (10.0.0.4) 5.45ms
Is there any way to force the page to refresh at the end of the execution of the script in question?
Hi @antonellocaroli thanks for the feedback, could you share a simple sample script for me, so I can reproduce the issue locally?
Regarding forced page refresh, unfortunately, this is not possible. What is the use case? Are some parameters relying on values, which are changed by script during the execution?
@bugy do you have the possibility to make a live connection with teamviewer? i'll show you directly.
if yes, write me at [email protected] and i will send you the teamviewer credentials..
To be honest, I would prefer a script, so I can debug it locally in IDE. Just seeing it is not very helpful
I sent you an e-mail