Skip to content

Commit

Permalink
lms: improve/fix database scan commands
Browse files Browse the repository at this point in the history
  • Loading branch information
onkelandy committed Dec 22, 2024
1 parent db1e5e7 commit d867e12
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 5 deletions.
35 changes: 31 additions & 4 deletions lms/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
},
'database': {
'rescan': {
'start': {'read': False, 'write': True, 'write_cmd': 'rescan {VALUE}', 'item_type': 'str', 'dev_datatype': 'str', 'cmd_settings': {'valid_list': ['playlists', 'onlinelibrary', 'external', 'full']}, 'item_attrs': {'attributes': {'remark': 'playlists|onlinelibrary|external|full|full file://some/path'}, 'custom1': ''}},
'running': {'read': True, 'write': False, 'read_cmd': 'rescan ?', 'item_type': 'bool', 'dev_datatype': 'LMSRescan', 'reply_pattern': 'rescan (.*)', 'item_attrs': {'cycle': '120', 'initial': True, 'custom1': ''}},
'progress': {'read': True, 'item_type': 'str', 'dev_datatype': 'str', 'reply_pattern': 'scanner notify progress:(.*)', 'item_attrs': {'custom1': ''}},
'runningtime': {'read': True, 'read_cmd': 'rescanprogress totaltime', 'item_type': 'str', 'dev_datatype': 'str', 'reply_pattern': 'rescanprogress totaltime .* rescan:([0-9]{2}:[0-9]{2}:[0-9]{2})', 'item_attrs': {'custom1': ''}},
'start': {'read': False, 'write': True, 'write_cmd': 'rescan {VALUE}', 'item_type': 'str', 'dev_datatype': 'str', 'cmd_settings': {'valid_list_re': ['playlists', 'onlinelibrary', 'external', 'full', r'full file://.*']}, 'item_attrs': {'attributes': {'remark': 'playlists|onlinelibrary|external|full|full file://some/path'}, 'custom1': ''}},
'running': {'read': True, 'write': False, 'read_cmd': 'rescan ?', 'item_type': 'bool', 'dev_datatype': 'LMSRescan', 'reply_pattern': ['rescanprogress rescan:(.*)', 'rescan (.*)', 'scanner notify progress:(.*)'], 'item_attrs': {'cycle': '120', 'initial': True, 'custom1': ''}},
'progress': {'read': True, 'item_type': 'str', 'dev_datatype': 'str', 'reply_pattern': 'scanner notify progress:(.*)', 'item_attrs': {'custom1': '', 'item_template': 'rescanprogress'}},
'runningtime': {'read': True, 'read_cmd': 'rescanprogress totaltime', 'item_type': 'str', 'dev_datatype': 'str', 'reply_pattern': '(?:rescanprogress totaltime.*)?rescan:(0|[0-9]{2}:[0-9]{2}:[0-9]{2})', 'item_attrs': {'custom1': ''}},
'fail': {'read': True, 'item_type': 'str', 'dev_datatype': 'str', 'reply_pattern': 'rescanprogress totaltime rescan:0 lastscanfailed:(.*)', 'item_attrs': {'custom1': ''}},
'abortscan': {'read': True, 'write': True, 'write_cmd': 'abortscan', 'item_type': 'bool', 'dev_datatype': 'str', 'reply_pattern': 'abortscan', 'item_attrs': {'custom1': ''}},
'wipecache': {'read': True, 'write': True, 'write_cmd': 'wipecache', 'item_type': 'bool', 'dev_datatype': 'LMSWipecache', 'reply_pattern': 'wipecache', 'item_attrs': {'custom1': ''}}
Expand Down Expand Up @@ -117,6 +117,33 @@
}

item_templates = {
'rescanprogress': {
'start':
{
'type': 'num',
'eval_trigger': '..',
'eval': '0 if len(sh...()) == 0 else sh...().split("||")[0]'
},
'info':
{
'type': 'str',
'eval_trigger': '..',
'eval': '0 if len(sh...()) < 3 else sh...().split("||")[2]'
},
'step':
{
'type': 'num',
'eval_trigger': '..',
'eval': '0 if len(sh...()) < 4 else sh...().split("||")[3]'
},
'totalsteps':
{
'type': 'num',
'eval_trigger': '..',
'eval': '0 if len(sh...()) <5 else sh...().split("||")[4]'
},

},
'duration': {
'duration_format':
{
Expand Down
2 changes: 1 addition & 1 deletion lms/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# handle feedback if rescan is running or not
class DT_LMSRescan(DT.Datatype):
def get_shng_data(self, data, type=None, **kwargs):
return True if data == "1" else False
return False if data in ["0", "done"] else True


class DT_LMSWipecache(DT.Datatype):
Expand Down
40 changes: 40 additions & 0 deletions lms/plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,26 @@ item_structs:
sqb_write@instance: false
sqb_custom1@instance: ''

start:
type: num
eval_trigger: '..'
eval: 0 if len(sh...()) == 0 else sh...().split("||")[0]

info:
type: str
eval_trigger: '..'
eval: 0 if len(sh...()) < 3 else sh...().split("||")[2]

step:
type: num
eval_trigger: '..'
eval: 0 if len(sh...()) < 4 else sh...().split("||")[3]

totalsteps:
type: num
eval_trigger: '..'
eval: 0 if len(sh...()) <5 else sh...().split("||")[4]

runningtime:
type: str
sqb_command@instance: database.rescan.runningtime
Expand Down Expand Up @@ -1120,6 +1140,26 @@ item_structs:
sqb_write@instance: false
sqb_custom1@instance: ''

start:
type: num
eval_trigger: '..'
eval: 0 if len(sh...()) == 0 else sh...().split("||")[0]

info:
type: str
eval_trigger: '..'
eval: 0 if len(sh...()) < 3 else sh...().split("||")[2]

step:
type: num
eval_trigger: '..'
eval: 0 if len(sh...()) < 4 else sh...().split("||")[3]

totalsteps:
type: num
eval_trigger: '..'
eval: 0 if len(sh...()) <5 else sh...().split("||")[4]

runningtime:
type: str
sqb_command@instance: database.rescan.runningtime
Expand Down

0 comments on commit d867e12

Please sign in to comment.