Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

default value and variable error #320

Open
antonellocaroli opened this issue Jul 12, 2020 · 11 comments
Open

default value and variable error #320

antonellocaroli opened this issue Jul 12, 2020 · 11 comments

Comments

@antonellocaroli
Copy link

antonellocaroli commented Jul 12, 2020

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'

@bugy
Copy link
Owner

bugy commented Jul 12, 2020 via email

@antonellocaroli
Copy link
Author

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

@bugy
Copy link
Owner

bugy commented Jul 13, 2020 via email

@antonellocaroli
Copy link
Author

ok, but how do I calculate a certain value based on the first parameter chosen? I can't find a solution...

@bugy
Copy link
Owner

bugy commented Jul 13, 2020 via email

@bugy
Copy link
Owner

bugy commented Mar 16, 2023

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.

@antonellocaroli
Copy link
Author

antonellocaroli commented Mar 17, 2023

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?

@bugy
Copy link
Owner

bugy commented Mar 17, 2023

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?

@antonellocaroli
Copy link
Author

@bugy do you have the possibility to make a live connection with teamviewer? i'll show you directly.

if yes, write me at antonellocaroli@gmail.com and i will send you the teamviewer credentials..

@bugy
Copy link
Owner

bugy commented Mar 17, 2023

To be honest, I would prefer a script, so I can debug it locally in IDE. Just seeing it is not very helpful

@antonellocaroli
Copy link
Author

I sent you an e-mail

bugy added a commit that referenced this issue Mar 18, 2023
… fixed swallowing a websocket future exception
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants