本文整理汇总了Python中sickbeard.save_config函数的典型用法代码示例。如果您正苦于以下问题:Python save_config函数的具体用法?Python save_config怎么用?Python save_config使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了save_config函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: migrate_config
def migrate_config(self):
""" Calls each successive migration until the config is the same version as SG expects """
if self.config_version > self.expected_config_version:
logger.log_error_and_exit(
u'Your config version (%s) has been incremented past what this version of SickGear supports (%s).\n'
'If you have used other forks or a newer version of SickGear, your config file may be unusable due to '
'their modifications.' % (self.config_version, self.expected_config_version))
sickbeard.CONFIG_VERSION = self.config_version
while self.config_version < self.expected_config_version:
next_version = self.config_version + 1
if next_version in self.migration_names:
migration_name = ': %s' % self.migration_names[next_version]
else:
migration_name = ''
logger.log(u'Backing up config before upgrade')
if not helpers.backupVersionedFile(sickbeard.CONFIG_FILE, self.config_version):
logger.log_error_and_exit(u'Config backup failed, abort upgrading config')
else:
logger.log(u'Proceeding with upgrade')
# do the migration, expect a method named _migrate_v<num>
logger.log(u'Migrating config up to version %s %s' % (next_version, migration_name))
getattr(self, '_migrate_v%s' % next_version)()
self.config_version = next_version
# save new config after migration
sickbeard.CONFIG_VERSION = self.config_version
logger.log(u'Saving config file to disk')
sickbeard.save_config()
示例2: migrate_config
def migrate_config(self):
"""
Calls each successive migration until the config is the same version as SB expects
"""
sickbeard.CONFIG_VERSION = self.config_version
while self.config_version < self.expected_config_version:
next_version = self.config_version + 1
if next_version in self.migration_names:
migration_name = ': ' + self.migration_names[next_version]
else:
migration_name = ''
helpers.backupVersionedFile(sickbeard.CONFIG_FILE, self.config_version)
# do the migration, expect a method named _migrate_v<num>
logger.log(u"Migrating config up to version " + str(next_version) + migration_name)
getattr(self, '_migrate_v' + str(next_version))()
self.config_version = next_version
# save new config after migration
sickbeard.CONFIG_VERSION = self.config_version
logger.log(u"Saving config file to disk")
sickbeard.save_config()
示例3: index
def index(self, limit=None):
if limit is None:
if sickbeard.HISTORY_LIMIT:
limit = int(sickbeard.HISTORY_LIMIT)
else:
limit = 100
else:
limit = try_int(limit, 100)
sickbeard.HISTORY_LIMIT = limit
sickbeard.save_config()
history = self.history.get(limit)
t = PageTemplate(rh=self, filename='history.mako')
submenu = [
{'title': 'Clear History', 'path': 'history/clearHistory', 'icon': 'ui-icon ui-icon-trash', 'class': 'clearhistory', 'confirm': True},
{'title': 'Trim History', 'path': 'history/trimHistory', 'icon': 'menu-icon-cut', 'class': 'trimhistory', 'confirm': True},
]
return t.render(historyResults=history.detailed, compactResults=history.compact, limit=limit,
submenu=submenu, title='History', header='History',
topmenu='history', controller='history', action='index')
示例4: execute
def execute(self):
use_torrents = False
use_nzbs = False
use_vods = False
for cur_provider in sickbeard.providers.sortedProviderList():
if cur_provider.isEnabled():
if cur_provider.providerType == GenericProvider.NZB:
use_nzbs = True
logger.log(u"Provider " + cur_provider.name + " is enabled, enabling NZBs in the upgrade")
break
elif cur_provider.providerType == GenericProvider.TORRENT:
use_torrents = True
logger.log(u"Provider " + cur_provider.name + " is enabled, enabling Torrents in the upgrade")
break
elif cur_provider.providerType == GenericProvider.VOD:
use_vods = True
logger.log(u"Provider "+cur_provider.name+" is enabled, enabling VideoOnDemand in the upgrade")
break
sickbeard.USE_TORRENTS = use_torrents
sickbeard.USE_NZBS = use_nzbs
sickbeard.USE_VODS = use_vods
sickbeard.save_config()
self.incDBVersion()
示例5: saveAnime
def saveAnime(self, use_anidb=None, anidb_username=None, anidb_password=None, anidb_use_mylist=None,
split_home=None):
"""
Save anime related settings
"""
results = []
sickbeard.USE_ANIDB = config.checkbox_to_value(use_anidb)
sickbeard.ANIDB_USERNAME = anidb_username
sickbeard.ANIDB_PASSWORD = anidb_password
sickbeard.ANIDB_USE_MYLIST = config.checkbox_to_value(anidb_use_mylist)
sickbeard.ANIME_SPLIT_HOME = config.checkbox_to_value(split_home)
sickbeard.save_config()
if results:
for x in results:
logger.log(x, logger.ERROR)
ui.notifications.error('Error(s) Saving Configuration',
'<br>\n'.join(results))
else:
ui.notifications.message('Configuration Saved', ek(os.path.join, sickbeard.CONFIG_FILE))
return self.redirect('/config/anime/')
示例6: saveIRC
def saveIRC(self, irc_bot=None, irc_server=None, irc_channel=None, irc_key=None, irc_nick=None):
results = []
if irc_bot == "on":
irc_bot = 1
else:
irc_bot = 0
config.change_IRC_BOT(irc_bot)
config.change_IRC_SERVER(irc_server)
config.change_IRC_CHANNEL(irc_channel, irc_key)
config.change_IRC_NICK(irc_nick)
sickbeard.save_config()
if len(results) > 0:
for x in results:
logger.log(x, logger.ERROR)
flash['error'] = 'Error(s) Saving Configuration'
flash['error-detail'] = "<br />\n".join(results)
else:
flash['message'] = 'Configuration Saved'
raise cherrypy.HTTPRedirect("index")
示例7: migrate_config
def migrate_config(self):
"""
Calls each successive migration until the config is the same version as SB expects
"""
if self.config_version > self.expected_config_version:
logger.log_error_and_exit(u"Your config version (" + str(self.config_version) + ") has been incremented past what this version of Sick Beard supports (" + str(self.expected_config_version) + ").\n" + \
"If you have used other forks or a newer version of Sick Beard, your config file may be unusable due to their modifications.")
sickbeard.CONFIG_VERSION = self.config_version
while self.config_version < self.expected_config_version:
next_version = self.config_version + 1
if next_version in self.migration_names:
migration_name = ': ' + self.migration_names[next_version]
else:
migration_name = ''
logger.log(u"Backing up config before upgrade")
if not helpers.backupVersionedFile(sickbeard.CONFIG_FILE, self.config_version):
logger.log_error_and_exit(u"Config backup failed, abort upgrading config")
else:
logger.log(u"Proceeding with upgrade")
# do the migration, expect a method named _migrate_v<num>
logger.log(u"Migrating config up to version " + str(next_version) + migration_name)
getattr(self, '_migrate_v' + str(next_version))()
self.config_version = next_version
# save new config after migration
sickbeard.CONFIG_VERSION = self.config_version
logger.log(u"Saving config file to disk")
sickbeard.save_config()
示例8: execute
def execute(self):
backupDatabase(12)
# update the default quality so we dont grab the wrong qualities after migration -- should have really been a config migration
sickbeard.QUALITY_DEFAULT = self._update_composite_qualities(sickbeard.QUALITY_DEFAULT)
sickbeard.save_config()
# upgrade previous HD to HD720p -- shift previous qualities to new placevalues
old_hd = common.Quality.combineQualities([common.Quality.HDTV, common.Quality.HDWEBDL >> 2, common.Quality.HDBLURAY >> 3], [])
new_hd = common.Quality.combineQualities([common.Quality.HDTV, common.Quality.HDWEBDL, common.Quality.HDBLURAY], [])
# update ANY -- shift existing qualities and add new 1080p qualities, note that rawHD was not added to the ANY template
old_any = common.Quality.combineQualities([common.Quality.SDTV, common.Quality.SDDVD, common.Quality.HDTV, common.Quality.HDWEBDL >> 2, common.Quality.HDBLURAY >> 3, common.Quality.UNKNOWN], [])
new_any = common.Quality.combineQualities([common.Quality.SDTV, common.Quality.SDDVD, common.Quality.HDTV, common.Quality.FULLHDTV, common.Quality.HDWEBDL, common.Quality.FULLHDWEBDL, common.Quality.HDBLURAY, common.Quality.FULLHDBLURAY, common.Quality.UNKNOWN], [])
# update qualities (including templates)
logger.log(u"[1/4] Updating pre-defined templates and the quality for each show...", logger.MESSAGE)
ql = []
shows = self.connection.select("SELECT * FROM tv_shows")
for cur_show in shows:
if cur_show["quality"] == old_hd:
new_quality = new_hd
elif cur_show["quality"] == old_any:
new_quality = new_any
else:
new_quality = self._update_composite_qualities(cur_show["quality"])
ql.append(["UPDATE tv_shows SET quality = ? WHERE show_id = ?", [new_quality, cur_show["show_id"]]])
self.connection.mass_action(ql)
# update status that are are within the old hdwebdl (1<<3 which is 8) and better -- exclude unknown (1<<15 which is 32768)
logger.log(u"[2/4] Updating the status for the episodes within each show...", logger.MESSAGE)
ql = []
episodes = self.connection.select("SELECT * FROM tv_episodes WHERE status < 3276800 AND status >= 800")
for cur_episode in episodes:
ql.append(["UPDATE tv_episodes SET status = ? WHERE episode_id = ?", [self._update_status(cur_episode["status"]), cur_episode["episode_id"]]])
self.connection.mass_action(ql)
# make two separate passes through the history since snatched and downloaded (action & quality) may not always coordinate together
# update previous history so it shows the correct action
logger.log(u"[3/4] Updating history to reflect the correct action...", logger.MESSAGE)
ql = []
historyAction = self.connection.select("SELECT * FROM history WHERE action < 3276800 AND action >= 800")
for cur_entry in historyAction:
ql.append(["UPDATE history SET action = ? WHERE showid = ? AND date = ?", [self._update_status(cur_entry["action"]), cur_entry["showid"], cur_entry["date"]]])
self.connection.mass_action(ql)
# update previous history so it shows the correct quality
logger.log(u"[4/4] Updating history to reflect the correct quality...", logger.MESSAGE)
ql = []
historyQuality = self.connection.select("SELECT * FROM history WHERE quality < 32768 AND quality >= 8")
for cur_entry in historyQuality:
ql.append(["UPDATE history SET quality = ? WHERE showid = ? AND date = ?", [self._update_quality(cur_entry["quality"]), cur_entry["showid"], cur_entry["date"]]])
self.connection.mass_action(ql)
self.incDBVersion()
# cleanup and reduce db if any previous data was removed
logger.log(u"Performing a vacuum on the database.", logger.DEBUG)
self.connection.action("VACUUM")
示例9: trakt_request
def trakt_request(self, path, data=None, headers=None, url=None, method='GET', count=0):
if None is sickbeard.TRAKT_TOKEN:
logger.log(u'You must get a Trakt token. Check your Trakt settings', logger.WARNING)
return {}
headers = headers or self.headers
url = url or self.api_url
count += 1
headers['Authorization'] = 'Bearer ' + sickbeard.TRAKT_TOKEN
try:
resp = self.session.request(method, url + path, headers=headers, timeout=self.timeout,
data=json.dumps(data) if data else [], verify=self.verify)
# check for http errors and raise if any are present
resp.raise_for_status()
# convert response to json
resp = resp.json()
except requests.RequestException as e:
code = getattr(e.response, 'status_code', None)
if not code:
if 'timed out' in e:
logger.log(u'Timeout connecting to Trakt. Try to increase timeout value in Trakt settings', logger.WARNING)
# This is pretty much a fatal error if there is no status_code
# It means there basically was no response at all
else:
logger.log(u'Could not connect to Trakt. Error: {0}'.format(e), logger.WARNING)
elif 502 == code:
# Retry the request, Cloudflare had a proxying issue
logger.log(u'Retrying trakt api request: %s' % path, logger.WARNING)
return self.trakt_request(path, data, headers, url, method, count=count)
elif 401 == code:
if self.trakt_token(refresh=True, count=count):
sickbeard.save_config()
return self.trakt_request(path, data, headers, url, method, count=count)
else:
logger.log(u'Unauthorized. Please check your Trakt settings', logger.WARNING)
raise traktAuthException()
elif code in (500, 501, 503, 504, 520, 521, 522):
# http://docs.trakt.apiary.io/#introduction/status-codes
logger.log(u'Trakt may have some issues and it\'s unavailable. Try again later please', logger.WARNING)
elif 404 == code:
logger.log(u'Trakt error (404) the resource does not exist: %s' % url + path, logger.WARNING)
else:
logger.log(u'Could not connect to Trakt. Code error: {0}'.format(code), logger.ERROR)
return {}
# check and confirm Trakt call did not fail
if isinstance(resp, dict) and 'failure' == resp.get('status', None):
if 'message' in resp:
raise traktException(resp['message'])
if 'error' in resp:
raise traktException(resp['error'])
else:
raise traktException('Unknown Error')
return resp
示例10: execute
def execute(self):
dir_results = self.connection.select("SELECT location FROM tv_shows")
dir_counts = {}
for cur_dir in dir_results:
cur_root_dir = ek.ek(os.path.dirname, ek.ek(os.path.normpath, cur_dir["location"]))
if cur_root_dir not in dir_counts:
dir_counts[cur_root_dir] = 1
else:
dir_counts[cur_root_dir] += 1
logger.log(u"Dir counts: "+str(dir_counts), logger.DEBUG)
if not dir_counts:
self.incDBVersion()
return
default_root_dir = dir_counts.values().index(max(dir_counts.values()))
new_root_dirs = str(default_root_dir)+'|'+'|'.join(dir_counts.keys())
logger.log(u"Setting ROOT_DIRS to: "+new_root_dirs, logger.DEBUG)
sickbeard.ROOT_DIRS = new_root_dirs
sickbeard.save_config()
self.incDBVersion()
示例11: saveSubtitles
def saveSubtitles(self, use_subtitles=None, subtitles_plugins=None, subtitles_languages=None, subtitles_dir=None, subtitles_perfect_match=None,
service_order=None, subtitles_history=None, subtitles_finder_frequency=None,
subtitles_multi=None, embedded_subtitles_all=None, subtitles_extra_scripts=None, subtitles_pre_scripts=None, subtitles_hearing_impaired=None,
addic7ed_user=None, addic7ed_pass=None, itasa_user=None, itasa_pass=None, legendastv_user=None, legendastv_pass=None, opensubtitles_user=None, opensubtitles_pass=None,
subtitles_download_in_pp=None, subtitles_keep_only_wanted=None):
"""
Save Subtitle Search related settings
"""
results = []
config.change_SUBTITLES_FINDER_FREQUENCY(subtitles_finder_frequency)
config.change_USE_SUBTITLES(use_subtitles)
sickbeard.SUBTITLES_LANGUAGES = [code.strip() for code in subtitles_languages.split(',') if code.strip() in subtitles.subtitle_code_filter()] if subtitles_languages else []
sickbeard.SUBTITLES_DIR = subtitles_dir
sickbeard.SUBTITLES_PERFECT_MATCH = config.checkbox_to_value(subtitles_perfect_match)
sickbeard.SUBTITLES_HISTORY = config.checkbox_to_value(subtitles_history)
sickbeard.EMBEDDED_SUBTITLES_ALL = config.checkbox_to_value(embedded_subtitles_all)
sickbeard.SUBTITLES_HEARING_IMPAIRED = config.checkbox_to_value(subtitles_hearing_impaired)
sickbeard.SUBTITLES_MULTI = 1 if len(sickbeard.SUBTITLES_LANGUAGES) > 1 else config.checkbox_to_value(subtitles_multi)
sickbeard.SUBTITLES_DOWNLOAD_IN_PP = config.checkbox_to_value(subtitles_download_in_pp)
sickbeard.SUBTITLES_KEEP_ONLY_WANTED = config.checkbox_to_value(subtitles_keep_only_wanted)
sickbeard.SUBTITLES_EXTRA_SCRIPTS = [x.strip() for x in subtitles_extra_scripts.split('|') if x.strip()]
sickbeard.SUBTITLES_PRE_SCRIPTS = [x.strip() for x in subtitles_pre_scripts.split('|') if x.strip()]
# Subtitles services
services_str_list = service_order.split()
subtitles_services_list = []
subtitles_services_enabled = []
for curServiceStr in services_str_list:
cur_service, cur_enabled = curServiceStr.split(':')
subtitles_services_list.append(cur_service)
subtitles_services_enabled.append(int(cur_enabled))
sickbeard.SUBTITLES_SERVICES_LIST = subtitles_services_list
sickbeard.SUBTITLES_SERVICES_ENABLED = subtitles_services_enabled
sickbeard.ADDIC7ED_USER = addic7ed_user or ''
sickbeard.ADDIC7ED_PASS = addic7ed_pass or ''
sickbeard.ITASA_USER = itasa_user or ''
sickbeard.ITASA_PASS = itasa_pass or ''
sickbeard.LEGENDASTV_USER = legendastv_user or ''
sickbeard.LEGENDASTV_PASS = legendastv_pass or ''
sickbeard.OPENSUBTITLES_USER = opensubtitles_user or ''
sickbeard.OPENSUBTITLES_PASS = opensubtitles_pass or ''
sickbeard.save_config()
# Reset provider pool so next time we use the newest settings
subtitles.get_provider_pool.invalidate()
if results:
for x in results:
logger.log(x, logger.ERROR)
ui.notifications.error('Error(s) Saving Configuration',
'<br>\n'.join(results))
else:
ui.notifications.message('Configuration Saved', ek(os.path.join, sickbeard.CONFIG_FILE))
return self.redirect('/config/subtitles/')
示例12: delete_account
def delete_account(account):
if account in sickbeard.TRAKT_ACCOUNTS:
try:
TraktAPI().trakt_request('/oauth/revoke', send_oauth=account, method='POST')
except TraktException:
logger.log('Failed to remove account from trakt.tv')
sickbeard.TRAKT_ACCOUNTS.pop(account)
sickbeard.save_config()
return True
return False
示例13: _check_auth
def _check_auth(self, **kwargs):
try:
secret_key = 'secret_key=' + re.split('secret_key\s*=\s*([0-9a-zA-Z]+)', self.api_key)[1]
except (StandardError, Exception):
raise sickbeard.exceptions.AuthException('Invalid secret key for %s in Media Providers/Options' % self.name)
if secret_key != self.api_key:
self.api_key = secret_key
sickbeard.save_config()
return True
示例14: replace_account
def replace_account(account, token, refresh_token, token_valid_date, refresh):
if account in sickbeard.TRAKT_ACCOUNTS:
sickbeard.TRAKT_ACCOUNTS[account].token = token
sickbeard.TRAKT_ACCOUNTS[account].refresh_token = refresh_token
sickbeard.TRAKT_ACCOUNTS[account].token_valid_date = token_valid_date
if not refresh:
sickbeard.TRAKT_ACCOUNTS[account].reset_name()
sickbeard.TRAKT_ACCOUNTS[account].reset_auth_failure()
sickbeard.save_config()
return True
else:
return False
示例15: saveGeneral
def saveGeneral(self, log_dir=None, web_port=None, web_log=None, web_ipv6=None,
launch_browser=None, web_username=None,
web_password=None, version_notify=None):
results = []
if web_ipv6 == "on":
web_ipv6 = 1
else:
web_ipv6 = 0
if web_log == "on":
web_log = 1
else:
web_log = 0
if launch_browser == "on":
launch_browser = 1
else:
launch_browser = 0
if version_notify == "on":
version_notify = 1
else:
version_notify = 0
if not config.change_LOG_DIR(log_dir):
results += ["Unable to create directory " + os.path.normpath(log_dir) + ", log dir not changed."]
sickbeard.LAUNCH_BROWSER = launch_browser
sickbeard.WEB_PORT = int(web_port)
sickbeard.WEB_IPV6 = web_ipv6
sickbeard.WEB_LOG = web_log
sickbeard.WEB_USERNAME = web_username
sickbeard.WEB_PASSWORD = web_password
config.change_VERSION_NOTIFY(version_notify)
sickbeard.save_config()
if len(results) > 0:
for x in results:
logger.log(x, logger.ERROR)
ui.notifications.error('Error(s) Saving Configuration',
'<br />\n'.join(results))
else:
ui.notifications.message('Configuration Saved', ek.ek(os.path.join, sickbeard.CONFIG_FILE) )
redirect("/config/general/")