def four(self, **kwargs): """ Accept Indexers and show Restart screen """ if kwargs: if 'newzbin_user' in kwargs and 'newzbin_pass' in kwargs: cfg.newzbin_username.set(kwargs.get('newzbin_user', '')) cfg.newzbin_password.set(kwargs.get('newzbin_pass', '')) cfg.newzbin_bookmarks.set(kwargs.get('newzbin_bookmarks', '0')) if 'matrix_user' in kwargs and 'matrix_apikey' in kwargs: cfg.matrix_username.set(kwargs.get('matrix_user', '')) cfg.matrix_apikey.set(kwargs.get('matrix_apikey', '')) config.save_config() # Show Restart screen info = self.info.copy() info['num'] = '» %s' % T('Step Four') info['number'] = 4 info['helpuri'] = 'http://wiki.sabnzbd.org/' info['session'] = cfg.api_key() info['access_url'], info['urls'] = self.get_access_info() info['T'] = Ttemplate template = Template(file=os.path.join(self.__web_dir, 'four.html'), searchList=[info], compilerSettings=sabnzbd.interface.DIRECTIVES) return template.respond()
def three(self, **kwargs): """ Accept webserver parms and show Indexers page """ if kwargs: if 'access' in kwargs: cfg.cherryhost.set(kwargs['access']) cfg.enable_https.set(kwargs.get('enable_https', 0)) cfg.autobrowser.set(kwargs.get('autobrowser', 0)) cfg.username.set(kwargs.get('web_user', '')) cfg.password.set(kwargs.get('web_pass', '')) if not cfg.username() or not cfg.password(): sabnzbd.interface.set_auth(cherrypy.config) config.save_config() # Show Restart screen info = self.info.copy() info['num'] = '» %s' % T('Step Three') info['number'] = 3 info['helpuri'] = 'http://wiki.sabnzbd.org/' info['session'] = cfg.api_key() info['access_url'], info['urls'] = self.get_access_info() info['T'] = Ttemplate template = Template(file=os.path.join(self.__web_dir, 'three.html'), searchList=[info], compilerSettings=sabnzbd.interface.DIRECTIVES) return template.respond()
def analyse(was_paused=False): """ Determine what pause/resume state we would have now. """ paused = None paused_all = False pause_post = False speedlimit = None servers = {} for ev in sort_schedules(forward=False): logging.debug('Schedule check result = %s', ev) action = ev[1] try: value = ev[2] except: value = None if action == 'pause': paused = True elif action == 'pause_all': paused_all = True elif action == 'resume': paused = False paused_all = False elif action == 'pause_post': pause_post = True elif action == 'resume_post': pause_post = False elif action == 'speedlimit' and value!=None: speedlimit = int(ev[2]) elif action == 'enable_server': try: servers[value] = 1 except: logging.warning(Ta('Schedule for non-existing server %s'), value) elif action == 'disable_server': try: servers[value] = 0 except: logging.warning(Ta('Schedule for non-existing server %s'), value) if not was_paused: if paused_all: sabnzbd.pause_all() else: sabnzbd.unpause_all() sabnzbd.downloader.Downloader.do.set_paused_state(paused or paused_all) PostProcessor.do.paused = pause_post if speedlimit: sabnzbd.downloader.Downloader.do.limit_speed(speedlimit) for serv in servers: try: item = config.get_config('servers', serv) value = servers[serv] if bool(item.enable()) != bool(value): item.enable.set(value) sabnzbd.downloader.Downloader.do.init_server(serv, serv) except: pass config.save_config()
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 whether non-script actions are acceptable """ global QUEUECOMPLETE, QUEUECOMPLETEACTION, QUEUECOMPLETEARG _action = None _argument = None if 'script_' in action: # all scripts are labeled script_xxx _action = run_script _argument = action.replace('script_', '') 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 if new: cfg.queue_complete.set(action or '') config.save_config() # keep the name of the action for matching the current select in queue.tmpl QUEUECOMPLETE = action QUEUECOMPLETEACTION = _action QUEUECOMPLETEARG = _argument
def four(self, **kwargs): """ Accept Indexers and show Restart screen """ if kwargs: if 'newzbin_user' in kwargs and 'newzbin_pass' in kwargs: cfg.newzbin_username.set(kwargs.get('newzbin_user','')) cfg.newzbin_password.set(kwargs.get('newzbin_pass','')) cfg.newzbin_bookmarks.set(kwargs.get('newzbin_bookmarks', '0')) if 'matrix_user' in kwargs and 'matrix_apikey' in kwargs: cfg.matrix_username.set(kwargs.get('matrix_user','')) cfg.matrix_apikey.set(kwargs.get('matrix_apikey','')) config.save_config() # Show Restart screen info = self.info.copy() info['num'] = '» %s' % T('Step Four') info['number'] = 4 info['helpuri'] = 'http://wiki.sabnzbd.org/' info['session'] = cfg.api_key() info['access_url'], info['urls'] = self.get_access_info() info['T'] = Ttemplate template = Template(file=os.path.join(self.__web_dir, 'four.html'), searchList=[info], compilerSettings=sabnzbd.interface.DIRECTIVES) return template.respond()
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 whether non-script actions are acceptable """ global QUEUECOMPLETE, QUEUECOMPLETEACTION, QUEUECOMPLETEARG _action = None _argument = None if "script_" in action: # all scripts are labeled script_xxx _action = run_script _argument = action.replace("script_", "") 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 if new: cfg.queue_complete.set(action or "") config.save_config() # keep the name of the action for matching the current select in queue.tmpl QUEUECOMPLETE = action QUEUECOMPLETEACTION = _action QUEUECOMPLETEARG = _argument
def two(self, **kwargs): """ Accept server and show the final page for restart """ if cfg.configlock() or not sabnzbd.interface.check_access(): return sabnzbd.interface.Protected() if not sabnzbd.interface.check_login(): raise sabnzbd.interface.NeedLogin() # Save server details if kwargs: kwargs['enable'] = 1 sabnzbd.interface.handle_server(kwargs) config.save_config() # Show Restart screen info = self.info.copy() info['helpuri'] = 'https://sabnzbd.org/wiki/' info['session'] = cfg.api_key() info['access_url'], info['urls'] = self.get_access_info() info['active_lang'] = cfg.language() info['T'] = Ttemplate info['download_dir'] = cfg.download_dir.get_path() info['complete_dir'] = cfg.complete_dir.get_path() template = Template(file=os.path.join(self.__web_dir, 'two.html'), searchList=[info], compilerSettings=sabnzbd.interface.DIRECTIVES) return template.respond()
def three(self, **kwargs): """ Accept webserver parms and show Indexer page """ if kwargs: if 'access' in kwargs: cfg.cherryhost.set(kwargs['access']) cfg.enable_https.set(kwargs.get('enable_https',0)) cfg.autobrowser.set(kwargs.get('autobrowser',0)) cfg.username.set(kwargs.get('web_user', '')) cfg.password.set(kwargs.get('web_pass', '')) if not cfg.username() or not cfg.password(): sabnzbd.interface.set_auth(cherrypy.config) config.save_config() # Create indexer page info = self.info.copy() info['num'] = '» %s' % T('Step Three') info['number'] = 3 info['T'] = Ttemplate info['rating_enable'] = cfg.rating_enable() info['rating_api_key'] = cfg.rating_api_key() template = Template(file=os.path.join(self.__web_dir, 'three.html'), searchList=[info], compilerSettings=sabnzbd.interface.DIRECTIVES) return template.respond()
def check_server_quota(): """Check quota on servers""" for srv, server in config.get_servers().items(): if server.quota(): if server.quota.get_int() + server.usage_at_start() < sabnzbd.BPSMeter.grand_total.get(srv, 0): logging.warning(T("Server %s has used the specified quota"), server.displayname()) server.quota.set("") config.save_config()
def enable_server(server): """ Enable server (scheduler only) """ try: config.get_config("servers", server).enable.set(1) except: logging.warning(T("Trying to set status of non-existing server %s"), server) return config.save_config() Downloader.do.update_server(server, server)
def enable_server(server): """ Enable server (scheduler only) """ try: config.get_config('servers', server).enable.set(1) except: logging.warning(T('Trying to set status of non-existing server %s'), server) return config.save_config() Downloader.do.update_server(server, server)
def disable_server(server): """ Disable server (scheduler only) """ try: config.get_config('servers', server).enable.set(0) except: logging.warning(T('Trying to set status of non-existing server %s'), server) return config.save_config() Downloader.do.update_server(server, server)
def disable_server(server): """ Disable server (scheduler only) """ try: config.get_config("servers", server).enable.set(0) except: logging.warning(T("Trying to set status of non-existing server %s"), server) return config.save_config() Downloader.do.update_server(server, server)
def save_state(): """ Save all internal bookkeeping to disk """ config.save_config() sabnzbd.ArticleCache.flush_articles() sabnzbd.NzbQueue.save() sabnzbd.BPSMeter.save() sabnzbd.Rating.save() sabnzbd.DirScanner.save() sabnzbd.PostProcessor.save() sabnzbd.RSSReader.save()
def check_server_expiration(): """Check if user should get warning about server date expiration""" for server in config.get_servers().values(): if server.expire_date(): days_to_expire = ceil( (time.mktime(time.strptime(server.expire_date(), "%Y-%m-%d")) - time.time()) / (60 * 60 * 24) ) # Notify from 5 days in advance if days_to_expire < 6: logging.warning(T("Server %s is expiring in %s day(s)"), server.displayname(), days_to_expire) # Reset on the day of expiration if days_to_expire <= 0: server.expire_date.set("") config.save_config()
def four(self, **kwargs): if kwargs: cfg.rating_enable.set(kwargs.get('rating_enable', 0)) cfg.rating_api_key.set(kwargs.get('rating_api_key', '')) config.save_config() # Show Restart screen info = self.info.copy() info['num'] = '» %s' % T('Step Four') info['number'] = 4 info['helpuri'] = 'http://wiki.sabnzbd.org/' info['session'] = cfg.api_key() info['access_url'], info['urls'] = self.get_access_info() info['T'] = Ttemplate template = Template(file=os.path.join(self.__web_dir, 'four.html'), searchList=[info], compilerSettings=sabnzbd.interface.DIRECTIVES) return template.respond()
def two(self, **kwargs): """ Accept server and show the final page for restart """ # Save server details if kwargs: kwargs['enable'] = 1 sabnzbd.interface.handle_server(kwargs) config.save_config() # Show Restart screen info = self.info.copy() info['helpuri'] = 'https://sabnzbd.org/wiki/' info['session'] = cfg.api_key() info['access_url'], info['urls'] = self.get_access_info() info['active_lang'] = cfg.language() info['T'] = Ttemplate template = Template(file=os.path.join(self.__web_dir, 'two.html'), searchList=[info], compilerSettings=sabnzbd.interface.DIRECTIVES) return template.respond()
def two(self, **kwargs): """ Accept server and show the final page for restart """ # Save server details if kwargs: kwargs['enable'] = 1 sabnzbd.interface.handle_server(kwargs) config.save_config() # Show Restart screen info = self.info.copy() info['helpuri'] = 'http://wiki.sabnzbd.org/' info['session'] = cfg.api_key() info['access_url'], info['urls'] = self.get_access_info() info['active_lang'] = cfg.language() info['T'] = Ttemplate template = Template(file=os.path.join(self.__web_dir, 'two.html'), searchList=[info], compilerSettings=sabnzbd.interface.DIRECTIVES) return template.respond()
def analyse(was_paused=False, priority=None): """ Determine what pause/resume state we would have now. 'priority': evaluate only effect for given priority, return True for paused """ global PP_PAUSE_EVENT PP_PAUSE_EVENT = False paused = None paused_all = False pause_post = False pause_low = pause_normal = pause_high = False speedlimit = None quota = True servers = {} for ev in sort_schedules(all_events=True): if priority is None: logging.debug('Schedule check result = %s', ev) action = ev[1] try: value = ev[2] except: value = None if action == 'pause': paused = True elif action == 'pause_all': paused_all = True PP_PAUSE_EVENT = True elif action == 'resume': paused = False paused_all = False elif action == 'pause_post': pause_post = True PP_PAUSE_EVENT = True elif action == 'resume_post': pause_post = False PP_PAUSE_EVENT = True elif action == 'speedlimit' and value is not None: speedlimit = ev[2] elif action == 'pause_all_low': pause_low = True elif action == 'pause_all_normal': pause_normal = True elif action == 'pause_all_high': pause_high = True elif action == 'resume_all_low': pause_low = False elif action == 'resume_all_normal': pause_normal = False elif action == 'resume_all_high': pause_high = False elif action == 'enable_quota': quota = True elif action == 'disable_quota': quota = False elif action == 'enable_server': try: servers[value] = 1 except: logging.warning(T('Schedule for non-existing server %s'), value) elif action == 'disable_server': try: servers[value] = 0 except: logging.warning(T('Schedule for non-existing server %s'), value) # Special case, a priority was passed, so evaluate only that and return state if priority == LOW_PRIORITY: return pause_low if priority == NORMAL_PRIORITY: return pause_normal if priority == HIGH_PRIORITY: return pause_high if priority is not None: return False # Normal analysis if not was_paused: if paused_all: sabnzbd.pause_all() else: sabnzbd.unpause_all() sabnzbd.downloader.Downloader.do.set_paused_state(paused or paused_all) PostProcessor.do.paused = pause_post if speedlimit is not None: sabnzbd.downloader.Downloader.do.limit_speed(speedlimit) sabnzbd.bpsmeter.BPSMeter.do.set_status(quota, action=False) for serv in servers: try: item = config.get_config('servers', serv) value = servers[serv] if bool(item.enable()) != bool(value): item.enable.set(value) sabnzbd.downloader.Downloader.do.init_server(serv, serv) except: pass config.save_config()
def initialize(pause_downloader=False, clean_up=False, evalSched=False, repair=0): global __INITIALIZED__, __SHUTTING_DOWN__, LOGFILE, WEBLOGFILE, LOGHANDLER, GUIHANDLER, AMBI_LOCALHOST, WAITEXIT, DAEMON, MY_NAME, MY_FULLNAME, NEW_VERSION, DIR_HOME, DIR_APPDATA, DIR_LCLDATA, DIR_PROG, DIR_INTERFACES, DARWIN, RESTART_REQ if __INITIALIZED__: return False __SHUTTING_DOWN__ = False # Set global database connection for Web-UI threads cherrypy.engine.subscribe("start_thread", get_db_connection) # Paused? pause_downloader = pause_downloader or cfg.start_paused() # Clean-up, if requested if clean_up: # New admin folder filesystem.remove_all(cfg.admin_dir.get_path(), "*.sab") # Optionally wait for "incomplete" to become online if cfg.wait_for_dfolder(): wait_for_download_folder() else: cfg.download_dir.set(cfg.download_dir(), create=True) cfg.download_dir.set_create(True) # Set access rights for "incomplete" base folder filesystem.set_permissions(cfg.download_dir.get_path(), recursive=False) # If dirscan_dir cannot be created, set a proper value anyway. # Maybe it's a network path that's temporarily missing. path = cfg.dirscan_dir.get_path() if not os.path.exists(path): filesystem.create_real_path(cfg.dirscan_dir.ident(), "", path, False) # Set call backs for Config items cfg.cache_limit.callback(new_limit) cfg.cherryhost.callback(guard_restart) cfg.cherryport.callback(guard_restart) cfg.web_dir.callback(guard_restart) cfg.web_color.callback(guard_restart) cfg.username.callback(guard_restart) cfg.password.callback(guard_restart) cfg.log_dir.callback(guard_restart) cfg.https_port.callback(guard_restart) cfg.https_cert.callback(guard_restart) cfg.https_key.callback(guard_restart) cfg.enable_https.callback(guard_restart) cfg.top_only.callback(guard_top_only) cfg.pause_on_post_processing.callback(guard_pause_on_pp) cfg.quota_size.callback(guard_quota_size) cfg.quota_day.callback(guard_quota_dp) cfg.quota_period.callback(guard_quota_dp) cfg.language.callback(guard_language) cfg.enable_https_verification.callback(guard_https_ver) guard_https_ver() # Set cache limit if not cfg.cache_limit() or (cfg.cache_limit() in ("200M", "450M") and (sabnzbd.WIN32 or sabnzbd.DARWIN)): cfg.cache_limit.set(misc.get_cache_limit()) ArticleCache.do.new_limit(cfg.cache_limit.get_int()) check_incomplete_vs_complete() # Set language files lang.set_locale_info("SABnzbd", DIR_LANGUAGE) lang.set_language(cfg.language()) sabnzbd.api.clear_trans_cache() sabnzbd.change_queue_complete_action(cfg.queue_complete(), new=False) # One time conversion "speedlimit" in schedules. if not cfg.sched_converted(): schedules = cfg.schedules() newsched = [] for sched in schedules: if "speedlimit" in sched: newsched.append(re.sub(r"(speedlimit \d+)$", r"\1K", sched)) else: newsched.append(sched) cfg.schedules.set(newsched) cfg.sched_converted.set(1) # Second time schedule conversion if cfg.sched_converted() != 2: cfg.schedules.set(["%s %s" % (1, schedule) for schedule in cfg.schedules()]) cfg.sched_converted.set(2) config.save_config() # Convert auto-sort if cfg.auto_sort() == "0": cfg.auto_sort.set("") elif cfg.auto_sort() == "1": cfg.auto_sort.set("avg_age asc") # Add hostname to the whitelist if not cfg.host_whitelist(): cfg.host_whitelist.set(socket.gethostname()) # Do repair if requested if check_repair_request(): repair = 2 pause_downloader = True # Initialize threads rss.init() paused = BPSMeter.do.read() NzbQueue() Downloader(pause_downloader or paused) Decoder() Assembler() PostProcessor() NzbQueue.do.read_queue(repair) DirScanner() Rating() URLGrabber() scheduler.init() if evalSched: scheduler.analyse(pause_downloader) logging.info("All processes started") RESTART_REQ = False __INITIALIZED__ = True return True
def initialize(pause_downloader=False, clean_up=False, evalSched=False, repair=0): global __INITIALIZED__, __SHUTTING_DOWN__,\ LOGFILE, WEBLOGFILE, LOGHANDLER, GUIHANDLER, AMBI_LOCALHOST, WAITEXIT, \ DAEMON, MY_NAME, MY_FULLNAME, NEW_VERSION, \ DIR_HOME, DIR_APPDATA, DIR_LCLDATA, DIR_PROG, DIR_INTERFACES, \ DARWIN, RESTART_REQ, OLD_QUEUE if __INITIALIZED__: return False __SHUTTING_DOWN__ = False # Set global database connection for Web-UI threads cherrypy.engine.subscribe('start_thread', get_db_connection) # Paused? pause_downloader = pause_downloader or cfg.start_paused() # Clean-up, if requested if clean_up: # New admin folder misc.remove_all(cfg.admin_dir.get_path(), '*.sab') # Optionally wait for "incomplete" to become online if cfg.wait_for_dfolder(): wait_for_download_folder() else: cfg.download_dir.set(cfg.download_dir(), create=True) cfg.download_dir.set_create(True) # Set access rights for "incomplete" base folder misc.set_permissions(cfg.download_dir.get_path(), recursive=False) # If dirscan_dir cannot be created, set a proper value anyway. # Maybe it's a network path that's temporarily missing. path = cfg.dirscan_dir.get_path() if not os.path.exists(path): sabnzbd.misc.create_real_path(cfg.dirscan_dir.ident(), '', path, False) # Set call backs for Config items cfg.cache_limit.callback(new_limit) cfg.cherryhost.callback(guard_restart) cfg.cherryport.callback(guard_restart) cfg.web_dir.callback(guard_restart) cfg.web_color.callback(guard_restart) cfg.username.callback(guard_restart) cfg.password.callback(guard_restart) cfg.log_dir.callback(guard_restart) cfg.https_port.callback(guard_restart) cfg.https_cert.callback(guard_restart) cfg.https_key.callback(guard_restart) cfg.enable_https.callback(guard_restart) cfg.top_only.callback(guard_top_only) cfg.pause_on_post_processing.callback(guard_pause_on_pp) cfg.growl_server.callback(sabnzbd.notifier.change_value) cfg.growl_password.callback(sabnzbd.notifier.change_value) cfg.quota_size.callback(guard_quota_size) cfg.quota_day.callback(guard_quota_dp) cfg.quota_period.callback(guard_quota_dp) cfg.fsys_type.callback(guard_fsys_type) cfg.language.callback(guard_language) cfg.enable_https_verification.callback(guard_https_ver) guard_https_ver() # Set Posix filesystem encoding sabnzbd.encoding.change_fsys(cfg.fsys_type()) # Set cache limit if not cfg.cache_limit() or (cfg.cache_limit() in ('200M', '450M') and (sabnzbd.WIN32 or sabnzbd.DARWIN)): cfg.cache_limit.set(misc.get_cache_limit()) ArticleCache.do.new_limit(cfg.cache_limit.get_int()) check_incomplete_vs_complete() # Set language files lang.set_locale_info('SABnzbd', DIR_LANGUAGE) lang.set_language(cfg.language()) sabnzbd.api.clear_trans_cache() OLD_QUEUE = check_old_queue() sabnzbd.change_queue_complete_action(cfg.queue_complete(), new=False) # One time conversion "speedlimit" in schedules. if not cfg.sched_converted(): schedules = cfg.schedules() newsched = [] for sched in schedules: if 'speedlimit' in sched: newsched.append(re.sub(r'(speedlimit \d+)$', r'\1K', sched)) else: newsched.append(sched) cfg.schedules.set(newsched) cfg.sched_converted.set(1) # Second time schedule conversion if cfg.sched_converted() != 2: cfg.schedules.set(['%s %s' % (1, schedule) for schedule in cfg.schedules()]) cfg.sched_converted.set(2) config.save_config() # Add hostname to the whitelist if not cfg.host_whitelist(): cfg.host_whitelist.set(socket.gethostname()) # Do repair if requested if check_repair_request(): repair = 2 pause_downloader = True # Initialize threads rss.init() paused = BPSMeter.do.read() NzbQueue() Downloader(pause_downloader or paused) Assembler() PostProcessor() NzbQueue.do.read_queue(repair) DirScanner() Rating() URLGrabber() scheduler.init() if evalSched: scheduler.analyse(pause_downloader) logging.info('All processes started') RESTART_REQ = False __INITIALIZED__ = True return True
def analyse(self, was_paused=False, priority=None): """Determine what pause/resume state we would have now. 'priority': evaluate only effect for given priority, return True for paused """ self.pp_pause_event = False paused = None paused_all = False pause_post = False pause_low = pause_normal = pause_high = False speedlimit = None quota = True servers = {} for ev in sort_schedules(all_events=True): if priority is None: logging.debug("Schedule check result = %s", ev) # Skip if disabled if ev[4] == "0": continue action = ev[1] try: value = ev[2] except: value = None if action == "pause": paused = True elif action == "pause_all": paused_all = True self.pp_pause_event = True elif action == "resume": paused = False paused_all = False elif action == "pause_post": pause_post = True self.pp_pause_event = True elif action == "resume_post": pause_post = False self.pp_pause_event = True elif action == "speedlimit" and value is not None: speedlimit = ev[2] elif action == "pause_all_low": pause_low = True elif action == "pause_all_normal": pause_normal = True elif action == "pause_all_high": pause_high = True elif action == "resume_all_low": pause_low = False elif action == "resume_all_normal": pause_normal = False elif action == "resume_all_high": pause_high = False elif action == "enable_quota": quota = True elif action == "disable_quota": quota = False elif action == "enable_server": try: servers[value] = 1 except: logging.warning(T("Schedule for non-existing server %s"), value) elif action == "disable_server": try: servers[value] = 0 except: logging.warning(T("Schedule for non-existing server %s"), value) # Special case, a priority was passed, so evaluate only that and return state if priority == LOW_PRIORITY: return pause_low if priority == NORMAL_PRIORITY: return pause_normal if priority == HIGH_PRIORITY: return pause_high if priority is not None: return False # Normal analysis if not was_paused: if paused_all: sabnzbd.pause_all() else: sabnzbd.unpause_all() sabnzbd.Downloader.set_paused_state(paused or paused_all) sabnzbd.PostProcessor.paused = pause_post if speedlimit is not None: sabnzbd.Downloader.limit_speed(speedlimit) sabnzbd.BPSMeter.set_status(quota, action=False) for serv in servers: try: item = config.get_config("servers", serv) value = servers[serv] if bool(item.enable()) != bool(value): item.enable.set(value) sabnzbd.Downloader.init_server(serv, serv) except: pass config.save_config()