Private GIT

Skip to content
Snippets Groups Projects
Commit 6b075cfc authored by miigotu's avatar miigotu
Browse files

Merge pull request #2002 from miigotu/patch

Try again with the name_cache lock. there was a deadlock. Add submodules for scene_exceptions and network_timezones
parents 00f49154 059e4cc8
Branches
Tags
No related merge requests found
[submodule "lib/network_timezones"]
path = lib/network_timezones
url = https://github.com/SiCKRAGETV/sb_network_timezones.git
[submodule "lib/scene_exceptions/tvrage"]
path = lib/scene_exceptions/tvrage
url = https://github.com/SiCKRAGETV/sr_tvrage_scene_exceptions.git
[submodule "lib/scene_exceptions/tvdb"]
path = lib/scene_exceptions/tvdb
url = https://github.com/SiCKRAGETV/sb_tvdb_scene_exceptions.git
Subproject commit d269c99ae066d69c4f78e205ba4b29151f158975
Subproject commit 691c816a407a44d2458be71d19509d2b038db594
Subproject commit d2bbe1280fbbb6f5c1aeefbc2aee51efe70bb8c7
......@@ -40,7 +40,7 @@ indexerConfig[INDEXER_TVRAGE] = {
indexerConfig[INDEXER_TVDB]['trakt_id'] = 'tvdb_id'
indexerConfig[INDEXER_TVDB]['xem_origin'] = 'tvdb'
indexerConfig[INDEXER_TVDB]['icon'] = 'thetvdb16.png'
indexerConfig[INDEXER_TVDB]['scene_url'] = 'http://sickragetv.github.io/sb_tvdb_scene_exceptions/exceptions.txt'
indexerConfig[INDEXER_TVDB]['scene_loc'] = 'lib/scene_exceptions/tvdb/exceptions.txt'
indexerConfig[INDEXER_TVDB]['show_url'] = 'http://thetvdb.com/?tab=series&id='
indexerConfig[INDEXER_TVDB]['base_url'] = 'http://thetvdb.com/api/%(apikey)s/series/' % indexerConfig[INDEXER_TVDB]['api_params']
......@@ -48,6 +48,6 @@ indexerConfig[INDEXER_TVDB]['base_url'] = 'http://thetvdb.com/api/%(apikey)s/ser
indexerConfig[INDEXER_TVRAGE]['trakt_id'] = 'tvrage_id'
indexerConfig[INDEXER_TVRAGE]['xem_origin'] = 'rage'
indexerConfig[INDEXER_TVRAGE]['icon'] = 'tvrage16.png'
indexerConfig[INDEXER_TVRAGE]['scene_url'] = 'http://sickragetv.github.io/sr_tvrage_scene_exceptions/exceptions.txt'
indexerConfig[INDEXER_TVRAGE]['scene_loc'] = 'lib/scene_exceptions/tvrage/exceptions.txt'
indexerConfig[INDEXER_TVRAGE]['show_url'] = 'http://tvrage.com/shows/id-'
indexerConfig[INDEXER_TVRAGE]['base_url'] = 'http://tvrage.com/showinfo.php?key=%(apikey)s&sid=' % indexerConfig[INDEXER_TVRAGE]['api_params']
......@@ -22,6 +22,7 @@ from sickbeard import db
from sickbeard import helpers
from sickbeard import logger
from sickbeard import encodingKludge as ek
from sickbeard.exceptions import ex
from os.path import basename, join, isfile
import os
import re
......@@ -72,31 +73,34 @@ def _update_zoneinfo():
global sb_timezone
sb_timezone = tz.tzlocal()
# now check if the zoneinfo needs update
url_zv = 'http://sickragetv.github.io/sb_network_timezones/zoneinfo.txt'
# TODO `git submodule update`
# now check if the zoneinfo needs update form the git submodule
loc_zv = 'lib/network_timezones/zoneinfo.txt'
# Read version file
try:
url_data = helpers.getURL(url_zv)
if not url_data:
with open(loc_zv, 'r') as file:
data = file.read()
if not data:
raise
# Filename of existing zoneinfo
if lib.dateutil.zoneinfo.ZONEINFOFILE is not None:
cur_zoneinfo = ek.ek(basename, lib.dateutil.zoneinfo.ZONEINFOFILE)
else:
cur_zoneinfo = None
(new_zoneinfo, zoneinfo_md5) = url_data.decode('utf-8').strip().rsplit(u' ')
except:
# When urlData is None, trouble connecting to github
logger.log(u'Loading zoneinfo.txt failed, this can happen from time to time. Unable to get URL: %s' % url_zv,
logger.WARNING)
# Filename and hash of new zoneinfo
(new_zoneinfo, zoneinfo_md5) = data.decode('utf-8').strip().rsplit(u' ')
except Exception as e:
logger.log(u'Crazy problem with zoneinfo: %s' % ex(e), logger.ERROR)
return
if (cur_zoneinfo is not None) and (new_zoneinfo == cur_zoneinfo):
return
# now load the new zoneinfo
url_tar = u'http://sickragetv.github.io/sb_network_timezones/%s' % new_zoneinfo
loc_tar = u'lib/network_timezones/%s' % new_zoneinfo
zonefile = helpers.real_path(ek.ek(join, ek.ek(os.path.dirname, lib.dateutil.zoneinfo.__file__), new_zoneinfo))
zonefile_tmp = re.sub(r'\.tar\.gz$', '.tmp', zonefile)
......@@ -108,7 +112,7 @@ def _update_zoneinfo():
logger.log(u'Unable to delete: %s' % zonefile_tmp, logger.ERROR)
return
if not helpers.download_file(url_tar, zonefile_tmp):
if not helpers.copyFile(loc_tar, zonefile_tmp):
return
if not ek.ek(os.path.exists, zonefile_tmp):
......@@ -147,18 +151,19 @@ def update_network_dict():
d = {}
# network timezones are stored on github pages
url = 'http://sickragetv.github.io/sb_network_timezones/network_timezones.txt'
# network timezones are stored in a git submodule
loc = 'lib/network_timezones/network_timezones.txt'
with open(loc, 'r') as file:
data = file.read()
url_data = helpers.getURL(url)
if url_data is None:
# When urlData is None, trouble connecting to github
logger.log(u'Updating network timezones failed, this can happen from time to time. URL: %s' % url, logger.WARNING)
if data is None:
logger.log(u'Updating network timezones failed', logger.ERROR)
load_network_dict()
return
try:
for line in url_data.splitlines():
for line in data.splitlines():
(key, val) = line.decode('utf-8').strip().rsplit(u':', 1)
if key is None or val is None:
continue
......
......@@ -26,7 +26,7 @@ import urlparse
import sickbeard
import generic
import urllib
from sickbeard.common import Quality
from sickbeard.common import Quality, cpu_presets
from sickbeard import logger
from sickbeard import tvcache
from sickbeard import db
......
......@@ -166,23 +166,28 @@ def retrieve_exceptions():
"""
global exception_dict, anidb_exception_dict, xem_exception_dict
# exceptions are stored on github pages
# exceptions are stored in submodules in this repo, sourced from the github repos
# TODO: `git submodule update`
for indexer in sickbeard.indexerApi().indexers:
if shouldRefresh(sickbeard.indexerApi(indexer).name):
logger.log(u"Checking for scene exception updates for " + sickbeard.indexerApi(indexer).name + "")
url = sickbeard.indexerApi(indexer).config['scene_url']
loc = sickbeard.indexerApi(indexer).config['scene_loc']
if loc.startswith("http"):
data = helpers.getURL(loc)
else:
with open(loc, 'r') as file:
data = file.read()
url_data = helpers.getURL(url)
if url_data is None:
# When urlData is None, trouble connecting to github
logger.log(u"Check scene exceptions update failed. Unable to get URL: " + url, logger.WARNING)
if data is None:
# When data is None, trouble connecting to github, or reading file failed
logger.log(u"Check scene exceptions update failed. Unable to update from: " + loc, logger.WARNING)
continue
setLastRefresh(sickbeard.indexerApi(indexer).name)
# each exception is on one line with the format indexer_id: 'show name 1', 'show name 2', etc
for cur_line in url_data.splitlines():
for cur_line in data.splitlines():
indexer_id, sep, aliases = cur_line.partition(':') # @UnusedVariable
if not aliases:
......@@ -197,7 +202,7 @@ def retrieve_exceptions():
del alias_list
# cleanup
del url_data
del data
# XEM scene exceptions
_xem_exceptions_fetcher()
......
......@@ -486,7 +486,7 @@ def xem_refresh(indexer_id, indexer, force=False):
if refresh or force:
logger.log(
u'Looking up XEM scene mapping using for show %s on %s' % (indexer_id, sickbeard.indexerApi(indexer).name,),
u'Looking up XEM scene mapping for show %s on %s' % (indexer_id, sickbeard.indexerApi(indexer).name,),
logger.DEBUG)
# mark refreshed
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment