本文整理汇总了Python中sickbeard.failed_history.trimHistory函数的典型用法代码示例。如果您正苦于以下问题:Python trimHistory函数的具体用法?Python trimHistory怎么用?Python trimHistory使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了trimHistory函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
def run(self, force=False):
self.amActive = True
update_datetime = datetime.datetime.now()
update_date = update_datetime.date()
# refresh network timezones
network_timezones.update_network_dict()
# sure, why not?
if sickbeard.USE_FAILED_DOWNLOADS:
failed_history.trimHistory()
logger.log(u"Doing full update on all shows")
# select 10 'Ended' tv_shows updated more than 90 days ago to include in this update
stale_should_update = []
stale_update_date = (update_date - datetime.timedelta(days=90)).toordinal()
# last_update_date <= 90 days, sorted ASC because dates are ordinal
myDB = db.DBConnection()
sql_result = myDB.select(
"SELECT indexer_id FROM tv_shows WHERE status = 'Ended' AND last_update_indexer <= ? ORDER BY last_update_indexer ASC LIMIT 10;",
[stale_update_date])
for cur_result in sql_result:
stale_should_update.append(int(cur_result['indexer_id']))
# start update process
piList = []
for curShow in sickbeard.showList:
try:
# get next episode airdate
curShow.nextEpisode()
# if should_update returns True (not 'Ended') or show is selected stale 'Ended' then update, otherwise just refresh
if curShow.should_update(update_date=update_date) or curShow.indexerid in stale_should_update:
try:
piList.append(sickbeard.showQueueScheduler.action.updateShow(curShow, True)) # @UndefinedVariable
except CantUpdateShowException as e:
logger.log(u"Unable to update show: {0}".format(str(e)),logger.DEBUG)
else:
logger.log(
u"Not updating episodes for show " + curShow.name + " because it's marked as ended and last/next episode is not within the grace period.",
logger.DEBUG)
piList.append(sickbeard.showQueueScheduler.action.refreshShow(curShow, True)) # @UndefinedVariable
except (CantUpdateShowException, CantRefreshShowException) as e:
logger.log(u"Automatic update failed: {}".format(ex(e)), logger.ERROR)
ui.ProgressIndicators.setIndicator('dailyUpdate', ui.QueueProgressIndicator("Daily Update", piList))
logger.log(u"Completed full update on all shows")
self.amActive = False
示例2: run
def run(self):
self.check_for_new_version()
# refresh scene exceptions too
scene_exceptions.retrieve_exceptions()
# sure, why not?
if sickbeard.USE_FAILED_DOWNLOADS:
failed_history.trimHistory()
示例3: run
def run(self, force=False):
update_datetime = datetime.datetime.now()
update_date = update_datetime.date()
# refresh network timezones
network_timezones.update_network_dict()
# sure, why not?
if sickbeard.USE_FAILED_DOWNLOADS:
failed_history.trimHistory()
logger.log(u"Doing full update on all shows")
# clean out cache directory, remove everything > 12 hours old
sickbeard.helpers.clearCache()
# select 10 'Ended' tv_shows updated more than 90 days ago to include in this update
stale_should_update = []
stale_update_date = (update_date - datetime.timedelta(days=90)).toordinal()
# last_update_date <= 90 days, sorted ASC because dates are ordinal
myDB = db.DBConnection()
sql_result = myDB.select(
"SELECT indexer_id FROM tv_shows WHERE status = 'Ended' AND last_update_indexer <= ? ORDER BY last_update_indexer ASC LIMIT 10;",
[stale_update_date])
for cur_result in sql_result:
stale_should_update.append(int(cur_result['indexer_id']))
# start update process
piList = []
for curShow in sickbeard.showList:
try:
# get next episode airdate
curShow.nextEpisode()
# if should_update returns True (not 'Ended') or show is selected stale 'Ended' then update, otherwise just refresh
if curShow.should_update(update_date=update_date) or curShow.indexerid in stale_should_update:
curQueueItem = sickbeard.showQueueScheduler.action.updateShow(curShow, True) # @UndefinedVariable
else:
logger.log(
u"Not updating episodes for show " + curShow.name + " because it's marked as ended and last/next episode is not within the grace period.",
logger.DEBUG)
curQueueItem = sickbeard.showQueueScheduler.action.refreshShow(curShow, True) # @UndefinedVariable
piList.append(curQueueItem)
except (exceptions.CantUpdateException, exceptions.CantRefreshException), e:
logger.log(u"Automatic update failed: " + ex(e), logger.ERROR)
示例4: run
def run(self, force=False):
self.amActive = True
# get and update scene exceptions lists
scene_exceptions.retrieve_exceptions()
# refresh network timezones
network_timezones.update_network_dict()
# sure, why not?
if sickbeard.USE_FAILED_DOWNLOADS:
failed_history.trimHistory()
self.amActive = False
示例5: run
def run(self, force=False):
update_datetime = datetime.datetime.now()
update_date = update_datetime.date()
# refresh network timezones
network_timezones.update_network_dict()
# sure, why not?
if sickbeard.USE_FAILED_DOWNLOADS:
failed_history.trimHistory()
logger.log(u"Doing full update on all shows")
# clean out cache directory, remove everything > 12 hours old
if sickbeard.CACHE_DIR:
for indexer in sickbeard.indexerApi().indexers:
cache_dir = sickbeard.indexerApi(indexer).cache
logger.log(u"Trying to clean cache folder " + cache_dir)
# Does our cache_dir exists
if not ek.ek(os.path.isdir, cache_dir):
logger.log(u"Can't clean " + cache_dir + " if it doesn't exist", logger.WARNING)
else:
max_age = datetime.timedelta(hours=12)
# Get all our cache files
cache_files = ek.ek(os.listdir, cache_dir)
for cache_file in cache_files:
cache_file_path = ek.ek(os.path.join, cache_dir, cache_file)
if ek.ek(os.path.isfile, cache_file_path):
cache_file_modified = datetime.datetime.fromtimestamp(
ek.ek(os.path.getmtime, cache_file_path)
)
if update_datetime - cache_file_modified > max_age:
try:
ek.ek(os.remove, cache_file_path)
except OSError, e:
logger.log(
u"Unable to clean " + cache_dir + ": " + repr(e) + " / " + str(e),
logger.WARNING,
)
break
示例6: run
def run(self):
if self.check_for_new_version():
if sickbeard.AUTO_UPDATE:
logger.log(u"New update found for SickBeard, starting auto-updater ...")
updated = sickbeard.versionCheckScheduler.action.update()
if updated:
logger.log(u"Update was successfull, restarting SickBeard ...")
sickbeard.restart(False)
# refresh scene exceptions too
scene_exceptions.retrieve_exceptions()
# refresh network timezones
network_timezones.update_network_dict()
# sure, why not?
if sickbeard.USE_FAILED_DOWNLOADS:
failed_history.trimHistory()
示例7: run
def run(self, force=False):
self.amActive = True
# clear internal name cache
name_cache.clearCache()
# get and update scene exceptions lists
scene_exceptions.retrieve_exceptions()
# build internal name cache for searches and parsing
name_cache.buildNameCache()
# refresh network timezones
network_timezones.update_network_dict()
# sure, why not?
if sickbeard.USE_FAILED_DOWNLOADS:
failed_history.trimHistory()
self.amActive = False
示例8: run
def run(self):
updated = None
if self.check_for_new_version():
if sickbeard.AUTO_UPDATE:
logger.log(u"New update found for SickRage, starting auto-updater ...")
updated = sickbeard.versionCheckScheduler.action.update()
if updated:
logger.log(u"Update was successfull, restarting SickRage ...")
# do a soft restart
threading.Timer(2, sickbeard.invoke_restart, [False]).start()
if not updated:
# refresh scene exceptions too
scene_exceptions.retrieve_exceptions()
# refresh network timezones
network_timezones.update_network_dict()
# sure, why not?
if sickbeard.USE_FAILED_DOWNLOADS:
failed_history.trimHistory()
示例9: start
#.........这里部分代码省略.........
# Make sure we can write to the config file
if not ek(os.access, sickbeard.CONFIG_FILE, os.W_OK):
if ek(os.path.isfile, sickbeard.CONFIG_FILE):
raise SystemExit('Config file must be writeable: {0}'.format(sickbeard.CONFIG_FILE))
elif not ek(os.access, ek(os.path.dirname, sickbeard.CONFIG_FILE), os.W_OK):
raise SystemExit('Config file root dir must be writeable: {0}'.format(ek(os.path.dirname, sickbeard.CONFIG_FILE)))
ek(os.chdir, sickbeard.DATA_DIR)
# Check if we need to perform a restore first
restore_dir = ek(os.path.join, sickbeard.DATA_DIR, 'restore')
if ek(os.path.exists, restore_dir):
success = self.restore_db(restore_dir, sickbeard.DATA_DIR)
if self.console_logging:
sys.stdout.write('Restore: restoring DB and config.ini {0}!\n'.format(('FAILED', 'SUCCESSFUL')[success]))
# Load the config and publish it to the sickbeard package
if self.console_logging and not ek(os.path.isfile, sickbeard.CONFIG_FILE):
sys.stdout.write('Unable to find {0}, all settings will be default!\n'.format(sickbeard.CONFIG_FILE))
sickbeard.CFG = ConfigObj(sickbeard.CONFIG_FILE)
# Initialize the config and our threads
sickbeard.initialize(consoleLogging=self.console_logging)
if self.run_as_daemon:
self.daemonize()
# Get PID
sickbeard.PID = os.getpid()
# Build from the DB to start with
self.load_shows_from_db()
logger.log('Starting SickRage [{branch}] using \'{config}\''.format
(branch=sickbeard.BRANCH, config=sickbeard.CONFIG_FILE))
self.clear_cache()
if self.forced_port:
logger.log('Forcing web server to port {port}'.format(port=self.forced_port))
self.start_port = self.forced_port
else:
self.start_port = sickbeard.WEB_PORT
if sickbeard.WEB_LOG:
self.log_dir = sickbeard.LOG_DIR
else:
self.log_dir = None
# sickbeard.WEB_HOST is available as a configuration value in various
# places but is not configurable. It is supported here for historic reasons.
if sickbeard.WEB_HOST and sickbeard.WEB_HOST != '0.0.0.0':
self.web_host = sickbeard.WEB_HOST
else:
self.web_host = '' if sickbeard.WEB_IPV6 else '0.0.0.0'
# web server options
self.web_options = {
'port': int(self.start_port),
'host': self.web_host,
'data_root': ek(os.path.join, sickbeard.PROG_DIR, 'gui', sickbeard.GUI_NAME),
'web_root': sickbeard.WEB_ROOT,
'log_dir': self.log_dir,
'username': sickbeard.WEB_USERNAME,
'password': sickbeard.WEB_PASSWORD,
'enable_https': sickbeard.ENABLE_HTTPS,
'handle_reverse_proxy': sickbeard.HANDLE_REVERSE_PROXY,
'https_cert': ek(os.path.join, sickbeard.PROG_DIR, sickbeard.HTTPS_CERT),
'https_key': ek(os.path.join, sickbeard.PROG_DIR, sickbeard.HTTPS_KEY),
}
# start web server
self.web_server = SRWebServer(self.web_options)
self.web_server.start()
# Fire up all our threads
sickbeard.start()
# Build internal name cache
name_cache.buildNameCache()
# Pre-populate network timezones, it isn't thread safe
network_timezones.update_network_dict()
# sure, why not?
if sickbeard.USE_FAILED_DOWNLOADS:
failed_history.trimHistory()
# Check for metadata indexer updates for shows (sets the next aired ep!)
# sickbeard.showUpdateScheduler.forceRun()
# Launch browser
if sickbeard.LAUNCH_BROWSER and not (self.no_launch or self.run_as_daemon):
sickbeard.launchBrowser('https' if sickbeard.ENABLE_HTTPS else 'http', self.start_port, sickbeard.WEB_ROOT)
# main loop
while True:
time.sleep(1)
示例10: start
#.........这里部分代码省略.........
restoreDir = ek(os.path.join, sickbeard.DATA_DIR, 'restore')
if ek(os.path.exists, restoreDir):
success = self.restoreDB(restoreDir, sickbeard.DATA_DIR)
if self.consoleLogging:
sys.stdout.write(u"Restore: restoring DB and config.ini %s!\n" % ("FAILED", "SUCCESSFUL")[success])
# Load the config and publish it to the sickbeard package
if self.consoleLogging and not ek(os.path.isfile, sickbeard.CONFIG_FILE):
sys.stdout.write(u"Unable to find '" + sickbeard.CONFIG_FILE + "' , all settings will be default!" + "\n")
sickbeard.CFG = ConfigObj(sickbeard.CONFIG_FILE)
# Initialize the config and our threads
sickbeard.initialize(consoleLogging=self.consoleLogging)
if self.runAsDaemon:
self.daemonize()
# Get PID
sickbeard.PID = os.getpid()
# Build from the DB to start with
self.loadShowsFromDB()
if self.forcedPort:
logger.log(u"Forcing web server to port " + str(self.forcedPort))
self.startPort = self.forcedPort
else:
self.startPort = sickbeard.WEB_PORT
if sickbeard.WEB_LOG:
self.log_dir = sickbeard.LOG_DIR
else:
self.log_dir = None
# sickbeard.WEB_HOST is available as a configuration value in various
# places but is not configurable. It is supported here for historic reasons.
if sickbeard.WEB_HOST and sickbeard.WEB_HOST != '0.0.0.0':
self.webhost = sickbeard.WEB_HOST
else:
if sickbeard.WEB_IPV6:
self.webhost = ''
else:
self.webhost = '0.0.0.0'
# web server options
self.web_options = {
'port': int(self.startPort),
'host': self.webhost,
'data_root': ek(os.path.join, sickbeard.PROG_DIR, 'gui', sickbeard.GUI_NAME),
'web_root': sickbeard.WEB_ROOT,
'log_dir': self.log_dir,
'username': sickbeard.WEB_USERNAME,
'password': sickbeard.WEB_PASSWORD,
'enable_https': sickbeard.ENABLE_HTTPS,
'handle_reverse_proxy': sickbeard.HANDLE_REVERSE_PROXY,
'https_cert': ek(os.path.join, sickbeard.PROG_DIR, sickbeard.HTTPS_CERT),
'https_key': ek(os.path.join, sickbeard.PROG_DIR, sickbeard.HTTPS_KEY),
}
# start web server
self.webserver = SRWebServer(self.web_options)
self.webserver.start()
if self.consoleLogging:
print "Starting up SickRage " + sickbeard.BRANCH + " from " + sickbeard.CONFIG_FILE
# Clean up after update
if sickbeard.GIT_NEWVER:
toclean = ek(os.path.join, sickbeard.CACHE_DIR, 'mako')
for root, dirs, files in ek(os.walk, toclean, topdown=False):
for name in files:
ek(os.remove, ek(os.path.join, root, name))
for name in dirs:
ek(os.rmdir, ek(os.path.join, root, name))
sickbeard.GIT_NEWVER = False
# Fire up all our threads
sickbeard.start()
# Build internal name cache
name_cache.buildNameCache()
# Prepopulate network timezones, it isn't thread safe
network_timezones.update_network_dict()
# sure, why not?
if sickbeard.USE_FAILED_DOWNLOADS:
failed_history.trimHistory()
# # Check for metadata indexer updates for shows (Disabled until we use api)
# sickbeard.showUpdateScheduler.forceRun()
# Launch browser
if sickbeard.LAUNCH_BROWSER and not (self.noLaunch or self.runAsDaemon):
sickbeard.launchBrowser('https' if sickbeard.ENABLE_HTTPS else 'http', self.startPort, sickbeard.WEB_ROOT)
# main loop
while True:
time.sleep(1)
示例11: start
#.........这里部分代码省略.........
print u'Your database version (%s) has been incremented past what this version of SickGear supports' \
% CUR_DB_VERSION
sys.exit(
u'If you have used other forks of SG, your database may be unusable due to their modifications')
# Initialize the config and our threads
sickbeard.initialize(consoleLogging=self.consoleLogging)
if self.runAsDaemon:
self.daemonize()
# Get PID
sickbeard.PID = os.getpid()
if self.forcedPort:
logger.log(u'Forcing web server to port %s' % self.forcedPort)
self.startPort = self.forcedPort
else:
self.startPort = sickbeard.WEB_PORT
if sickbeard.WEB_LOG:
self.log_dir = sickbeard.LOG_DIR
else:
self.log_dir = None
# sickbeard.WEB_HOST is available as a configuration value in various
# places but is not configurable. It is supported here for historic reasons.
if sickbeard.WEB_HOST and sickbeard.WEB_HOST != '0.0.0.0':
self.webhost = sickbeard.WEB_HOST
else:
if sickbeard.WEB_IPV6:
self.webhost = '::'
else:
self.webhost = '0.0.0.0'
# web server options
self.web_options = {
'port': int(self.startPort),
'host': self.webhost,
'data_root': os.path.join(sickbeard.PROG_DIR, 'gui', sickbeard.GUI_NAME),
'web_root': sickbeard.WEB_ROOT,
'log_dir': self.log_dir,
'username': sickbeard.WEB_USERNAME,
'password': sickbeard.WEB_PASSWORD,
'enable_https': sickbeard.ENABLE_HTTPS,
'handle_reverse_proxy': sickbeard.HANDLE_REVERSE_PROXY,
'https_cert': os.path.join(sickbeard.PROG_DIR, sickbeard.HTTPS_CERT),
'https_key': os.path.join(sickbeard.PROG_DIR, sickbeard.HTTPS_KEY),
}
# start web server
try:
# used to check if existing SG instances have been started
sickbeard.helpers.wait_for_free_port(self.web_options['host'], self.web_options['port'])
self.webserver = WebServer(self.web_options)
self.webserver.start()
except Exception:
logger.log(u'Unable to start web server, is something else running on port %d?' % self.startPort,
logger.ERROR)
if sickbeard.LAUNCH_BROWSER and not self.runAsDaemon:
logger.log(u'Launching browser and exiting', logger.ERROR)
sickbeard.launchBrowser(self.startPort)
os._exit(1)
# Check if we need to perform a restore first
restoreDir = os.path.join(sickbeard.DATA_DIR, 'restore')
if os.path.exists(restoreDir):
if self.restore(restoreDir, sickbeard.DATA_DIR):
logger.log(u'Restore successful...')
else:
logger.log_error_and_exit(u'Restore FAILED!')
# Build from the DB to start with
self.loadShowsFromDB()
# Fire up all our threads
sickbeard.start()
# Build internal name cache
name_cache.buildNameCache()
# refresh network timezones
network_timezones.update_network_dict()
# sure, why not?
if sickbeard.USE_FAILED_DOWNLOADS:
failed_history.trimHistory()
# Start an update if we're supposed to
if self.forceUpdate or sickbeard.UPDATE_SHOWS_ON_START:
sickbeard.showUpdateScheduler.action.run(force=True) # @UndefinedVariable
# Launch browser
if sickbeard.LAUNCH_BROWSER and not (self.noLaunch or self.runAsDaemon):
sickbeard.launchBrowser(self.startPort)
# main loop
while True:
time.sleep(1)
示例12: run
def run(self, force=False): # pylint: disable=unused-argument, too-many-locals, too-many-branches, too-many-statements
self.amActive = True
bad_indexer = [INDEXER_TVRAGE]
update_datetime = datetime.datetime.now()
update_date = update_datetime.date()
# update_timestamp = calendar.timegm(update_datetime.timetuple())
update_timestamp = time.mktime(update_datetime.timetuple())
my_db = db.DBConnection('cache.db')
result = my_db.select("SELECT `time` FROM lastUpdate WHERE provider = 'theTVDB'")
if result:
last_update = int(result[0]['time'])
else:
last_update = update_timestamp - 86400
my_db.action("INSERT INTO lastUpdate (provider,`time`) VALUES (?, ?)", ['theTVDB', last_update])
# refresh network timezones
network_timezones.update_network_dict()
# sure, why not?
if sickbeard.USE_FAILED_DOWNLOADS:
failed_history.trimHistory()
update_delta = update_timestamp - last_update
if update_delta >= 691200: # 8 days ( 7 days + 1 day of buffer time)
update_file = 'updates_month.xml'
elif update_delta >= 90000: # 25 hours ( 1 day + 1 hour of buffer time)
update_file = 'updates_week.xml'
else:
update_file = 'updates_day.xml'
# url = 'http://thetvdb.com/api/Updates.php?type=series&time=%s' % last_update
url = 'http://thetvdb.com/api/%s/updates/%s' % (sickbeard.indexerApi(INDEXER_TVDB).api_params['apikey'], update_file)
data = helpers.getURL(url, session=self.session)
if not data:
logger.log(u"Could not get the recently updated show data from %s. Retrying later. Url was: %s" % (sickbeard.indexerApi(INDEXER_TVDB).name, url))
self.amActive = False
return
updated_shows = []
try:
tree = ET.fromstring(data)
for show in tree.findall("Series"):
updated_shows.append(int(show.find('id').text))
except SyntaxError:
pass
logger.log(u"Doing full update on all shows")
pi_list = []
for cur_show in sickbeard.showList:
if cur_show.indexer in bad_indexer:
logger.log(u"Indexer is no longer available for show [ %s ] " % cur_show.name, logger.WARNING)
else:
indexer_name = sickbeard.indexerApi(cur_show.indexer).name
try:
if indexer_name == 'theTVDB':
if cur_show.indexerid in updated_shows:
pi_list.append(sickbeard.showQueueScheduler.action.updateShow(cur_show, True))
# else:
# pi_list.append(sickbeard.showQueueScheduler.action.refreshShow(cur_show, True))
else:
cur_show.nextEpisode()
if cur_show.should_update(update_date=update_date):
try:
pi_list.append(sickbeard.showQueueScheduler.action.updateShow(cur_show, True))
except CantUpdateShowException as e:
logger.log(u"Unable to update show: {0}".format(str(e)), logger.DEBUG)
else:
logger.log(
u"Not updating episodes for show " + cur_show.name + " because it's last/next episode is not within the grace period.",
logger.DEBUG)
# pi_list.append(sickbeard.showQueueScheduler.action.refreshShow(cur_show, True))
except (CantUpdateShowException, CantRefreshShowException) as e:
logger.log(u"Automatic update failed: " + ex(e), logger.ERROR)
ui.ProgressIndicators.setIndicator('dailyUpdate', ui.QueueProgressIndicator("Daily Update", pi_list))
my_db.action("UPDATE lastUpdate SET `time` = ? WHERE provider=?", [update_timestamp, 'theTVDB'])
logger.log(u"Completed full update on all shows")
self.amActive = False
示例13: start
#.........这里部分代码省略.........
ek(os.makedirs, sickbeard.DATA_DIR, 0o744)
except os.error as e:
raise SystemExit("Unable to create datadir '" + sickbeard.DATA_DIR + "'")
# Make sure we can write to the data dir
if not ek(os.access, sickbeard.DATA_DIR, os.W_OK):
raise SystemExit("Datadir must be writeable '" + sickbeard.DATA_DIR + "'")
# Make sure we can write to the config file
if not ek(os.access, sickbeard.CONFIG_FILE, os.W_OK):
if ek(os.path.isfile, sickbeard.CONFIG_FILE):
raise SystemExit("Config file '" + sickbeard.CONFIG_FILE + "' must be writeable.")
elif not ek(os.access, ek(os.path.dirname, sickbeard.CONFIG_FILE), os.W_OK):
raise SystemExit(
"Config file root dir '" + ek(os.path.dirname, sickbeard.CONFIG_FILE) + "' must be writeable.")
ek(os.chdir, sickbeard.DATA_DIR)
# Check if we need to perform a restore first
restoreDir = ek(os.path.join, sickbeard.DATA_DIR, 'restore')
if ek(os.path.exists, restoreDir):
success = self.restoreDB(restoreDir, sickbeard.DATA_DIR)
if self.consoleLogging:
sys.stdout.write("Restore: restoring DB and config.ini %s!\n" % ("FAILED", "SUCCESSFUL")[success])
# Load the config and publish it to the sickbeard package
if self.consoleLogging and not ek(os.path.isfile, sickbeard.CONFIG_FILE):
sys.stdout.write("Unable to find '" + sickbeard.CONFIG_FILE + "' , all settings will be default!" + "\n")
sickbeard.CFG = ConfigObj(sickbeard.CONFIG_FILE)
# Initialize the config and our threads
sickbeard.initialize(consoleLogging=self.consoleLogging)
if self.runAsDaemon:
sickbeard.DAEMONIZE = True
self.daemonize()
# Get PID
sickbeard.PID = os.getpid()
# Build from the DB to start with
self.loadShowsFromDB()
if self.forcedPort:
logging.info("Forcing web server to port " + str(self.forcedPort))
self.startPort = self.forcedPort
else:
self.startPort = sickbeard.WEB_PORT
if sickbeard.WEB_LOG:
self.log_dir = sickbeard.LOG_DIR
else:
self.log_dir = None
# sickbeard.WEB_HOST is available as a configuration value in various
# places but is not configurable. It is supported here for historic reasons.
if sickbeard.WEB_HOST and sickbeard.WEB_HOST != '0.0.0.0':
self.webhost = sickbeard.WEB_HOST
else:
if sickbeard.WEB_IPV6:
self.webhost = '::'
else:
self.webhost = '0.0.0.0'
# Clean up after update
if sickbeard.GIT_NEWVER:
toclean = ek(os.path.join, sickbeard.CACHE_DIR, 'mako')
for root, dirs, files in ek(os.walk, toclean, topdown=False):
for name in files:
ek(os.remove, ek(os.path.join, root, name))
for name in dirs:
ek(os.rmdir, ek(os.path.join, root, name))
sickbeard.GIT_NEWVER = False
# Fire up all our threads
logging.info("Starting SiCKRAGE:[{}] CONFIG:[{}]".format(sickbeard.BRANCH, sickbeard.CONFIG_FILE))
sickbeard.start()
# sure, why not?
if sickbeard.USE_FAILED_DOWNLOADS:
failed_history.trimHistory()
# Check for metadata indexer updates for shows (Disabled until we use api)
# sickbeard.showUpdateScheduler.forceRun()
# start tornado web server
sickbeard.WEB_SERVER = SRWebServer({
'port': int(self.startPort),
'host': self.webhost,
'gui_root': sickbeard.GUI_DIR,
'web_root': sickbeard.WEB_ROOT,
'log_dir': self.log_dir,
'username': sickbeard.WEB_USERNAME,
'password': sickbeard.WEB_PASSWORD,
'enable_https': sickbeard.ENABLE_HTTPS,
'handle_reverse_proxy': sickbeard.HANDLE_REVERSE_PROXY,
'https_cert': ek(os.path.join, sickbeard.PROG_DIR, sickbeard.HTTPS_CERT),
'https_key': ek(os.path.join, sickbeard.PROG_DIR, sickbeard.HTTPS_KEY),
}).start()
示例14: run
def run(self, force=False): # pylint: disable=unused-argument, too-many-locals, too-many-branches, too-many-statements
self.amActive = True
bad_indexer = [INDEXER_TVRAGE]
update_datetime = datetime.datetime.now()
update_date = update_datetime.date()
# update_timestamp = calendar.timegm(update_datetime.timetuple())
update_timestamp = time.mktime(update_datetime.timetuple())
cache_db_con = db.DBConnection('cache.db')
result = cache_db_con.select("SELECT `time` FROM lastUpdate WHERE provider = 'theTVDB'")
if result:
last_update = int(result[0]['time'])
else:
last_update = update_timestamp - 86400
cache_db_con.action("INSERT INTO lastUpdate (provider,`time`) VALUES (?, ?)", ['theTVDB', last_update])
# refresh network timezones
network_timezones.update_network_dict()
# sure, why not?
if sickbeard.USE_FAILED_DOWNLOADS:
failed_history.trimHistory()
update_delta = update_timestamp - last_update
if update_delta >= 691200: # 8 days ( 7 days + 1 day of buffer time)
update_file = 'updates_month.xml'
elif update_delta >= 90000: # 25 hours ( 1 day + 1 hour of buffer time)
update_file = 'updates_week.xml'
else:
update_file = 'updates_day.xml'
# url = 'http://thetvdb.com/api/Updates.php?type=series&time=%s' % last_update
url = 'http://thetvdb.com/api/{0}/updates/{1}'.format(sickbeard.indexerApi(INDEXER_TVDB).api_params['apikey'], update_file)
data = helpers.getURL(url, session=self.session, returns='text')
if not data:
logger.info(u'Could not get the recently updated show data from {indexer}. Retrying later. Url was: {logurl}', indexer=sickbeard.indexerApi(INDEXER_TVDB).name, logurl=url)
self.amActive = False
return
updated_shows = []
try:
tree = ET.fromstring(data)
for show in tree.findall("Series"):
updated_shows.append(int(show.find('id').text))
except SyntaxError:
pass
logger.info(u'Doing full update on all shows')
pi_list = []
for cur_show in sickbeard.showList:
if cur_show.indexer in bad_indexer:
logger.warning(u'Indexer is no longer available for show [ {show} ] ', show=cur_show.name)
else:
indexer_name = sickbeard.indexerApi(cur_show.indexer).name
try:
if indexer_name == 'theTVDB':
if cur_show.indexerid in updated_shows:
# If the cur_show is not 'paused' then add to the showQueueSchedular
if not cur_show.paused:
pi_list.append(sickbeard.showQueueScheduler.action.updateShow(cur_show, True))
else:
logger.info(u'Show update skipped, show: {show} is paused.', show=cur_show.name)
else:
cur_show.next_episode()
if cur_show.should_update(update_date=update_date):
try:
pi_list.append(sickbeard.showQueueScheduler.action.updateShow(cur_show, True))
except CantUpdateShowException as e:
logger.debug(u'Unable to update show: {error}', error=e)
else:
logger.debug(
u'Not updating episodes for show {show} because the last or next episode is not within the grace period.', show = cur_show.name)
except (CantUpdateShowException, CantRefreshShowException) as e:
logger.error(u'Automatic update failed: {0}', error=e)
ui.ProgressIndicators.setIndicator('dailyUpdate', ui.QueueProgressIndicator("Daily Update", pi_list))
cache_db_con.action("UPDATE lastUpdate SET `time` = ? WHERE provider=?", [update_timestamp, 'theTVDB'])
logger.info(u'Completed full update on all shows')
self.amActive = False
示例15: run
def run(self, force=False):
self.amActive = True
try:
update_datetime = datetime.datetime.now()
update_date = update_datetime.date()
# refresh network timezones
network_timezones.update_network_dict()
# update xem id lists
sickbeard.scene_exceptions.get_xem_ids()
# update scene exceptions
sickbeard.scene_exceptions.retrieve_exceptions()
# sure, why not?
if sickbeard.USE_FAILED_DOWNLOADS:
failed_history.trimHistory()
# clear the data of unused providers
sickbeard.helpers.clear_unused_providers()
logger.log(u'Doing full update on all shows')
# clean out cache directory, remove everything > 12 hours old
sickbeard.helpers.clearCache()
# select 10 'Ended' tv_shows updated more than 90 days ago and all shows not updated more then 180 days ago to include in this update
stale_should_update = []
stale_update_date = (update_date - datetime.timedelta(days=90)).toordinal()
stale_update_date_max = (update_date - datetime.timedelta(days=180)).toordinal()
# last_update_date <= 90 days, sorted ASC because dates are ordinal
myDB = db.DBConnection()
sql_results = myDB.mass_action([[
'SELECT indexer_id FROM tv_shows WHERE last_update_indexer <= ? AND last_update_indexer >= ? ORDER BY last_update_indexer ASC LIMIT 10;',
[stale_update_date, stale_update_date_max]], ['SELECT indexer_id FROM tv_shows WHERE last_update_indexer < ?;', [stale_update_date_max]]])
for sql_result in sql_results:
for cur_result in sql_result:
stale_should_update.append(int(cur_result['indexer_id']))
# start update process
piList = []
for curShow in sickbeard.showList:
try:
# get next episode airdate
curShow.nextEpisode()
# if should_update returns True (not 'Ended') or show is selected stale 'Ended' then update, otherwise just refresh
if curShow.should_update(update_date=update_date) or curShow.indexerid in stale_should_update:
curQueueItem = sickbeard.showQueueScheduler.action.updateShow(curShow, scheduled_update=True) # @UndefinedVariable
else:
logger.log(
u'Not updating episodes for show ' + curShow.name + ' because it\'s marked as ended and last/next episode is not within the grace period.',
logger.DEBUG)
curQueueItem = sickbeard.showQueueScheduler.action.refreshShow(curShow, True, True) # @UndefinedVariable
piList.append(curQueueItem)
except (exceptions.CantUpdateException, exceptions.CantRefreshException) as e:
logger.log(u'Automatic update failed: ' + ex(e), logger.ERROR)
ui.ProgressIndicators.setIndicator('dailyUpdate', ui.QueueProgressIndicator('Daily Update', piList))
logger.log(u'Added all shows to show queue for full update')
finally:
self.amActive = False