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)):
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():
repair = 2
@ -607,10 +607,11 @@ def restart_program():
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
Scripts are prefixed with 'script_'
When "new" is False, check wether non-script actions are acceptable
"""
global QUEUECOMPLETE, QUEUECOMPLETEACTION, QUEUECOMPLETEARG
@ -620,14 +621,19 @@ def change_queue_complete_action(action):
#all scripts are labeled script_xxx
_action = run_script
_argument = action.replace('script_', '')
elif action == 'shutdown_pc':
_action = system_shutdown
elif action == 'hibernate_pc':
_action = system_hibernate
elif action == 'standby_pc':
_action = system_standby
elif action == 'shutdown_program':
_action = shutdown_program
elif new or cfg.queue_complete_pers.get():
if action == 'shutdown_pc':
_action = system_shutdown
elif action == 'hibernate_pc':
_action = system_hibernate
elif action == 'standby_pc':
_action = system_standby
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
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)
autodisconnect = OptionBool('misc', 'auto_disconnect', True)
queue_complete = OptionStr('misc', 'queue_complete')
queue_complete_pers = OptionBool('misc', 'queue_complete_pers', True)
replace_spaces = OptionBool('misc', 'replace_spaces', 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()
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):

Loading…
Cancel
Save