Fix for date/time display issues.

Fix for manual snatches not updating status in realtime.
This commit is contained in:
echel0n 2014-05-18 11:21:18 -07:00
parent cf18b3eec8
commit f4b71b7203
4 changed files with 53 additions and 25 deletions

View file

@ -50,7 +50,11 @@ class DailySearcher():
for curProviderCount, curProvider in enumerate(providers):
threading.currentThread().name = origThreadName + " :: [" + curProvider.name + "]"
curProvider.cache.updateCache()
try:
curProvider.cache.updateCache()
except exceptions.AuthException, e:
logger.log(u"Authentication error: " + ex(e), logger.ERROR)
continue
logger.log(u"Checking to see if any shows have wanted episodes available for the last week ...")

View file

@ -265,7 +265,8 @@ def parse_date_time(d, t, network):
return datetime.datetime(te.year, te.month, te.day, hr, m, tzinfo=sb_timezone)
else:
foreign_timezone = get_network_timezone(network, network_dict)
return datetime.datetime(te.year, te.month, te.day, hr, m, tzinfo=foreign_timezone)
foreign_naive = datetime.datetime(te.year, te.month, te.day, hr, m, tzinfo=foreign_timezone)
return foreign_naive.astimezone(sb_timezone)
except:
return datetime.datetime(te.year, te.month, te.day, hr, m)

View file

@ -100,16 +100,15 @@ class sbdatetime(datetime.datetime):
@static_or_instance
def sbftime(self, dt=None, show_seconds=False, t_preset=None):
try:
locale.setlocale(locale.LC_TIME, self.ORIG_LC_TIME)
except:
pass
try:locale.setlocale(locale.LC_TIME, self.ORIG_LC_TIME)
except:pass
try:
if sbdatetime.has_locale:
locale.setlocale(locale.LC_TIME, 'us_US')
except:
sbdatetime.has_locale = False
strt = ''
try:
if self is None:
@ -133,6 +132,7 @@ class sbdatetime(datetime.datetime):
locale.setlocale(locale.LC_TIME, self.ORIG_LC_TIME)
except:
sbdatetime.has_locale = False
return strt
# display Date in Sickbeard Format
@ -158,6 +158,12 @@ class sbdatetime(datetime.datetime):
else:
strd = self.strftime(sickbeard.DATE_PRESET)
finally:
try:
locale.setlocale(locale.LC_TIME, self.ORIG_LC_TIME)
except:
pass
return strd
# display Datetime in Sickbeard Format
@ -210,4 +216,5 @@ class sbdatetime(datetime.datetime):
locale.setlocale(locale.LC_TIME, self.ORIG_LC_TIME)
except:
sbdatetime.has_locale = False
return strd

View file

@ -80,18 +80,6 @@ class SearchQueue(generic_queue.GenericQueue):
else:
logger.log(u"Not adding item, it's already in the queue", logger.DEBUG)
def snatch_item(self, item):
for result in item:
# just use the first result for now
logger.log(u"Downloading " + result.name + " from " + result.provider.name)
item.success = search.snatchEpisode(result)
# give the CPU a break
time.sleep(2)
# return results of snatch
return item
class DailySearchQueueItem(generic_queue.QueueItem):
def __init__(self, show, segment):
generic_queue.QueueItem.__init__(self, 'Daily Search', DAILY_SEARCH)
@ -112,8 +100,14 @@ class DailySearchQueueItem(generic_queue.QueueItem):
if not len(foundResults):
logger.log(u"No needed episodes found during daily search for [" + self.show.name + "]")
else:
for curResult in foundResults:
SearchQueue().snatch_item(curResult)
for curEp in foundResults:
for result in curEp:
# just use the first result for now
logger.log(u"Downloading " + result.name + " from " + result.provider.name)
search.snatchEpisode(result)
# give the CPU a break
time.sleep(2)
generic_queue.QueueItem.finish(self)
@ -129,8 +123,6 @@ class ManualSearchQueueItem(generic_queue.QueueItem):
def execute(self):
generic_queue.QueueItem.execute(self)
queueItem = self
try:
logger.log("Beginning manual search for [" + self.segment.prettyName() + "]")
searchResult = search.searchProviders(self.show, self.segment.season, [self.segment], True)
@ -139,7 +131,13 @@ class ManualSearchQueueItem(generic_queue.QueueItem):
threading.currentThread().name = self.thread_name
if searchResult:
self.success = SearchQueue().snatch_item(searchResult)
# just use the first result for now
logger.log(u"Downloading " + searchResult[0].name + " from " + searchResult[0].provider.name)
self.success = search.snatchEpisode(searchResult[0])
# give the CPU a break
time.sleep(2)
else:
ui.notifications.message('No downloads were found',
"Couldn't find a download for <i>%s</i>" % self.segment.prettyName())
@ -149,6 +147,10 @@ class ManualSearchQueueItem(generic_queue.QueueItem):
except Exception:
logger.log(traceback.format_exc(), logger.DEBUG)
def finish(self):
# don't let this linger if something goes wrong
if self.success == None:
self.success = False
generic_queue.QueueItem.finish(self)
class BacklogQueueItem(generic_queue.QueueItem):
@ -176,7 +178,14 @@ class BacklogQueueItem(generic_queue.QueueItem):
threading.currentThread().name = self.thread_name
if searchResult:
SearchQueue().snatch_item(searchResult)
for result in searchResult:
# just use the first result for now
logger.log(u"Downloading " + result.name + " from " + result.provider.name)
search.snatchEpisode(result)
# give the CPU a break
time.sleep(2)
else:
logger.log(u"No needed episodes found during backlog search for [" + self.show.name + "]")
@ -221,7 +230,14 @@ class FailedQueueItem(generic_queue.QueueItem):
threading.currentThread().name = self.thread_name
if searchResult:
SearchQueue().snatch_item(searchResult)
for result in searchResult:
# just use the first result for now
logger.log(u"Downloading " + result.name + " from " + result.provider.name)
search.snatchEpisode(result)
# give the CPU a break
time.sleep(2)
else:
logger.log(u"No episodes found to retry for failed downloads return from providers!")
except Exception, e: