Browse Source

Add option to select non-persistence of non-script end-of-queue actions.

tags/0.6.0
ShyPike 15 years ago
parent
commit
9cbedf4939
  1. 26
      sabnzbd/__init__.py
  2. 1
      sabnzbd/cfg.py
  3. 2
      sabnzbd/postproc.py

26
sabnzbd/__init__.py

@ -215,7 +215,7 @@ def initialize(pause_downloader = False, clean_up = False, evalSched=False, repa
if not os.path.exists(os.path.join(cfg.cache_dir.get_path(), QUEUE_FILE_NAME)): if not os.path.exists(os.path.join(cfg.cache_dir.get_path(), QUEUE_FILE_NAME)):
OLD_QUEUE = bool(misc.globber(cfg.cache_dir.get_path(), QUEUE_FILE_TMPL % '?')) OLD_QUEUE = bool(misc.globber(cfg.cache_dir.get_path(), QUEUE_FILE_TMPL % '?'))
sabnzbd.change_queue_complete_action(cfg.queue_complete()) sabnzbd.change_queue_complete_action(cfg.queue_complete(), new=False)
if check_repair_request(): if check_repair_request():
repair = 2 repair = 2
@ -607,10 +607,11 @@ def restart_program():
cherrypy.engine.restart() cherrypy.engine.restart()
def change_queue_complete_action(action): def change_queue_complete_action(action, new=True):
""" """
Action or script to be performed once the queue has been completed Action or script to be performed once the queue has been completed
Scripts are prefixed with 'script_' Scripts are prefixed with 'script_'
When "new" is False, check wether non-script actions are acceptable
""" """
global QUEUECOMPLETE, QUEUECOMPLETEACTION, QUEUECOMPLETEARG global QUEUECOMPLETE, QUEUECOMPLETEACTION, QUEUECOMPLETEARG
@ -620,14 +621,19 @@ def change_queue_complete_action(action):
#all scripts are labeled script_xxx #all scripts are labeled script_xxx
_action = run_script _action = run_script
_argument = action.replace('script_', '') _argument = action.replace('script_', '')
elif action == 'shutdown_pc': elif new or cfg.queue_complete_pers.get():
_action = system_shutdown if action == 'shutdown_pc':
elif action == 'hibernate_pc': _action = system_shutdown
_action = system_hibernate elif action == 'hibernate_pc':
elif action == 'standby_pc': _action = system_hibernate
_action = system_standby elif action == 'standby_pc':
elif action == 'shutdown_program': _action = system_standby
_action = shutdown_program elif action == 'shutdown_program':
_action = shutdown_program
else:
action = None
else:
action = None
#keep the name of the action for matching the current select in queue.tmpl #keep the name of the action for matching the current select in queue.tmpl
QUEUECOMPLETE = action QUEUECOMPLETE = action

1
sabnzbd/cfg.py

@ -107,6 +107,7 @@ bookmark_rate = OptionNumber('newzbin', 'bookmark_rate', 60, minval=15, maxval=2
top_only = OptionBool('misc', 'top_only', True) top_only = OptionBool('misc', 'top_only', True)
autodisconnect = OptionBool('misc', 'auto_disconnect', True) autodisconnect = OptionBool('misc', 'auto_disconnect', True)
queue_complete = OptionStr('misc', 'queue_complete') queue_complete = OptionStr('misc', 'queue_complete')
queue_complete_pers = OptionBool('misc', 'queue_complete_pers', True)
replace_spaces = OptionBool('misc', 'replace_spaces', False) replace_spaces = OptionBool('misc', 'replace_spaces', False)
replace_dots = OptionBool('misc', 'replace_dots', False) replace_dots = OptionBool('misc', 'replace_dots', False)

2
sabnzbd/postproc.py

@ -576,7 +576,7 @@ def handle_empty_queue():
Thread(target=sabnzbd.QUEUECOMPLETEACTION).start() Thread(target=sabnzbd.QUEUECOMPLETEACTION).start()
sabnzbd.QUEUECOMPLETEACTION_GO = False sabnzbd.QUEUECOMPLETEACTION_GO = False
sabnzbd.change_queue_complete_action(cfg.queue_complete()) sabnzbd.change_queue_complete_action(cfg.queue_complete(), new=False)
def cleanup_list(wdir, skip_nzb): def cleanup_list(wdir, skip_nzb):

Loading…
Cancel
Save