Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tuneit
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ximper Linux
tuneit
Commits
3bcfab63
Commit
3bcfab63
authored
Mar 09, 2025
by
Roman Alifanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CustomSettings: add get_range
parent
0e19b429
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
2 deletions
+28
-2
custom_setting.py
src/settings/setting/custom_setting.py
+28
-2
No files found.
src/settings/setting/custom_setting.py
View file @
3bcfab63
...
...
@@ -4,6 +4,7 @@ from .widgets import WidgetFactory
import
logging
import
subprocess
import
ast
class
CustomSetting
:
...
...
@@ -22,6 +23,7 @@ class CustomSetting:
self
.
_current_value
=
None
self
.
get_command
=
setting_data
.
get
(
'get_command'
)
self
.
get_range_command
=
setting_data
.
get
(
'get_range_command'
)
self
.
set_command
=
setting_data
.
get
(
'set_command'
)
self
.
gtype
=
setting_data
.
get
(
'gtype'
,
's'
)
...
...
@@ -115,6 +117,9 @@ class CustomSetting:
self
.
_current_value
=
value
self
.
_update_widget
()
def
get_range
(
self
):
return
self
.
_execute_get_range_command
()
def
_get_selected_row_index
(
self
):
current_value
=
self
.
_get_backend_value
()
return
list
(
self
.
map
.
values
())
.
index
(
current_value
)
if
current_value
in
self
.
map
.
values
()
else
0
...
...
@@ -162,6 +167,25 @@ class CustomSetting:
self
.
logger
.
error
(
f
"Set command failed: {e.stderr}"
)
return
False
def
_execute_get_range_command
(
self
):
if
not
self
.
get_range_command
:
return
None
try
:
cmd
=
self
.
_format_command
(
self
.
get_range_command
)
result
=
subprocess
.
run
(
cmd
,
check
=
True
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
text
=
True
,
shell
=
True
)
return
ast
.
literal_eval
(
self
.
_process_output
(
result
.
stdout
))
except
subprocess
.
CalledProcessError
as
e
:
self
.
logger
.
error
(
f
"Get range command failed: {e.stderr}"
)
return
None
def
_format_command
(
self
,
template
,
value
=
None
):
variables
=
{
'value'
:
value
,
...
...
@@ -203,4 +227,7 @@ class CustomSetting:
return
self
.
get_value
()
def
_set_backend_value
(
self
,
value
):
self
.
set_value
(
value
)
\ No newline at end of file
self
.
set_value
(
value
)
def
_get_backend_range
(
self
):
return
self
.
get_range
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment