From cee865461c323bdac89d13b44ed3aa2fe5f55e4c Mon Sep 17 00:00:00 2001 From: Prinz23 Date: Sat, 6 Feb 2016 19:57:19 +0100 Subject: [PATCH] Change move dateutil-zoneinfo.tar.gz file to data files /cache. Add dateutil library hack for new location. --- CHANGES.md | 1 + HACKS.txt | 5 +++-- lib/dateutil/zoneinfo/__init__.py | 7 ++++++- sickbeard/__init__.py | 7 ++++++- sickbeard/network_timezones.py | 12 +++++++----- 5 files changed, 23 insertions(+), 9 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 7a519137..1efd7750 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -25,6 +25,7 @@ * Change emails to Unicode aware * Add force episode recent search to API * Change process episodes with utf8 dir and nzb names, handle failed episodes without a dir, add log output streaming +* Change move dateutil-zoneinfo.tar.gz file to data files /cache ### 0.11.5 (2016-02-01 19:40:00 UTC) diff --git a/HACKS.txt b/HACKS.txt index f2b8be2c..66ed4087 100644 --- a/HACKS.txt +++ b/HACKS.txt @@ -1,10 +1,11 @@ Libs with customisations... /lib/cachecontrol/caches/file_cache.py +/lib/dateutil/zoneinfo/__init__.py /lib/hachoir_core/config.py /lib/pynma/pynma.py /lib/requests/packages/urllib3/connectionpool.py /lib/requests/packages/urllib3/util/ssl_.py -/tornado +/lib/tornado +/lib/tvdb/tvdb_api.py /lib/unrar2/unix.py -/lib/tvdb/tvdb_api.py \ No newline at end of file diff --git a/lib/dateutil/zoneinfo/__init__.py b/lib/dateutil/zoneinfo/__init__.py index 8156092e..8d8dfb41 100644 --- a/lib/dateutil/zoneinfo/__init__.py +++ b/lib/dateutil/zoneinfo/__init__.py @@ -14,6 +14,9 @@ from contextlib import closing from dateutil.tz import tzfile +from sickbeard import encodingKludge as ek +import sickbeard + __all__ = ["gettz", "gettz_db_metadata", "rebuild"] ZONEFILENAME = "dateutil-zoneinfo.tar.gz" @@ -34,7 +37,9 @@ class tzfile(tzfile): def getzoneinfofile_stream(): try: - return BytesIO(get_data(__name__, ZONEFILENAME)) + # return BytesIO(get_data(__name__, ZONEFILENAME)) + with open(ek.ek(os.path.join, sickbeard.ZONEINFO_DIR, ZONEFILENAME), 'rb') as f: + return BytesIO(f.read()) except IOError as e: # TODO switch to FileNotFoundError? warnings.warn("I/O error({0}): {1}".format(e.errno, e.strerror)) return None diff --git a/sickbeard/__init__.py b/sickbeard/__init__.py index ceb58feb..cb67f6ef 100755 --- a/sickbeard/__init__.py +++ b/sickbeard/__init__.py @@ -43,6 +43,7 @@ from indexers.indexer_api import indexerApi from indexers.indexer_exceptions import indexer_shownotfound, indexer_exception, indexer_error, \ indexer_episodenotfound, indexer_attributenotfound, indexer_seasonnotfound, indexer_userabort, indexerExcepts from sickbeard.providers.generic import GenericProvider +from sickbeard import encodingKludge as ek from lib.configobj import ConfigObj from lib.libtrakt import TraktAPI import trakt_helpers @@ -133,6 +134,7 @@ HTTPS_KEY = None LAUNCH_BROWSER = False CACHE_DIR = None ACTUAL_CACHE_DIR = None +ZONEINFO_DIR = None ROOT_DIRS = None TRASH_REMOVE_SHOW = False TRASH_ROTATE_LOGS = False @@ -503,7 +505,7 @@ def initialize(consoleLogging=True): USE_PUSHBULLET, PUSHBULLET_NOTIFY_ONSNATCH, PUSHBULLET_NOTIFY_ONDOWNLOAD, PUSHBULLET_NOTIFY_ONSUBTITLEDOWNLOAD, PUSHBULLET_ACCESS_TOKEN, PUSHBULLET_DEVICE_IDEN, \ versionCheckScheduler, VERSION_NOTIFY, AUTO_UPDATE, NOTIFY_ON_UPDATE, PROCESS_AUTOMATICALLY, UNPACK, CPU_PRESET, \ KEEP_PROCESSED_DIR, PROCESS_METHOD, TV_DOWNLOAD_DIR, MIN_RECENTSEARCH_FREQUENCY, DEFAULT_UPDATE_FREQUENCY, MIN_UPDATE_FREQUENCY, UPDATE_FREQUENCY, \ - showQueueScheduler, searchQueueScheduler, ROOT_DIRS, CACHE_DIR, ACTUAL_CACHE_DIR, TIMEZONE_DISPLAY, \ + showQueueScheduler, searchQueueScheduler, ROOT_DIRS, CACHE_DIR, ACTUAL_CACHE_DIR, ZONEINFO_DIR, TIMEZONE_DISPLAY, \ NAMING_PATTERN, NAMING_MULTI_EP, NAMING_ANIME_MULTI_EP, NAMING_FORCE_FOLDERS, NAMING_ABD_PATTERN, NAMING_CUSTOM_ABD, NAMING_SPORTS_PATTERN, NAMING_CUSTOM_SPORTS, NAMING_ANIME_PATTERN, NAMING_CUSTOM_ANIME, NAMING_STRIP_YEAR, \ RENAME_EPISODES, AIRDATE_EPISODES, properFinderScheduler, PROVIDER_ORDER, autoPostProcesserScheduler, \ providerList, newznabProviderList, torrentRssProviderList, \ @@ -581,6 +583,9 @@ def initialize(consoleLogging=True): # clean cache folders if CACHE_DIR: helpers.clearCache() + ZONEINFO_DIR = ek.ek(os.path.join, CACHE_DIR, 'zoneinfo') + if not ek.ek(os.path.isdir, ZONEINFO_DIR) and not helpers.make_dirs(ZONEINFO_DIR): + logger.log(u'!!! Creating local zoneinfo dir failed', logger.ERROR) THEME_NAME = check_setting_str(CFG, 'GUI', 'theme_name', 'dark') GUI_NAME = check_setting_str(CFG, 'GUI', 'gui_name', 'slick') diff --git a/sickbeard/network_timezones.py b/sickbeard/network_timezones.py index 61404a96..3964f4d9 100644 --- a/sickbeard/network_timezones.py +++ b/sickbeard/network_timezones.py @@ -24,9 +24,11 @@ from sickbeard import helpers from sickbeard import logger from sickbeard import encodingKludge as ek from os.path import basename, join, isfile +from itertools import chain import os import re import datetime +import sickbeard # regex to parse time (12/24 hour format) time_regex = re.compile(r'(\d{1,2})(([:.](\d{2}))? ?([PA][. ]? ?M)|[:.](\d{2}))\b', flags=re.I) @@ -53,10 +55,10 @@ def _remove_old_zoneinfo(): return cur_zoneinfo = ek.ek(basename, zonefilename) - cur_file = helpers.real_path(ek.ek(join, ek.ek(os.path.dirname, zoneinfo.__file__), cur_zoneinfo)) + cur_file = helpers.real_path(ek.ek(join, sickbeard.ZONEINFO_DIR, cur_zoneinfo)) - for (path, dirs, files) in ek.ek(os.walk, - helpers.real_path(ek.ek(os.path.dirname, zoneinfo.__file__))): + for (path, dirs, files) in chain.from_iterable(ek.ek(os.walk, + helpers.real_path(di)) for di in (sickbeard.ZONEINFO_DIR, ek.ek(os.path.dirname, zoneinfo.__file__))): for filename in files: if filename.endswith('.tar.gz'): file_w_path = ek.ek(join, path, filename) @@ -87,7 +89,7 @@ def _update_zoneinfo(): cur_zoneinfo = zonefilename if None is not cur_zoneinfo: cur_zoneinfo = ek.ek(basename, zonefilename) - zonefile = helpers.real_path(ek.ek(join, ek.ek(os.path.dirname, zoneinfo.__file__), cur_zoneinfo)) + zonefile = helpers.real_path(ek.ek(join, sickbeard.ZONEINFO_DIR, cur_zoneinfo)) zonemetadata = zoneinfo.gettz_db_metadata() if ek.ek(os.path.isfile, zonefile) else None (new_zoneinfo, zoneinfo_md5) = url_data.decode('utf-8').strip().rsplit(u' ') newtz_regex = re.search(r'(\d{4}[^.]+)', new_zoneinfo) @@ -125,7 +127,7 @@ def _update_zoneinfo(): # remove the old zoneinfo file if cur_zoneinfo is not None: old_file = helpers.real_path( - ek.ek(join, ek.ek(os.path.dirname, zoneinfo.__file__), cur_zoneinfo)) + ek.ek(join, sickbeard.ZONEINFO_DIR, cur_zoneinfo)) if ek.ek(os.path.exists, old_file): ek.ek(os.remove, old_file) # rename downloaded file