Skip to content

Commit

Permalink
Merge pull request midgetspy#730 from echel0n/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
echel0n committed Aug 18, 2014
2 parents 1b1c4f6 + e2d1178 commit 6eccffc
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 21 deletions.
12 changes: 9 additions & 3 deletions sickbeard/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
NOTIFY_ON_UPDATE = False
CUR_COMMIT_HASH = None
BRANCH = ''
CUR_COMMIT_BRANCH = ''

INIT_LOCK = Lock()
started = False
Expand Down Expand Up @@ -444,7 +445,7 @@
def initialize(consoleLogging=True):
with INIT_LOCK:

global BRANCH, CUR_COMMIT_HASH, ACTUAL_LOG_DIR, LOG_DIR, WEB_PORT, WEB_LOG, ENCRYPTION_VERSION, WEB_ROOT, WEB_USERNAME, WEB_PASSWORD, WEB_HOST, WEB_IPV6, USE_API, API_KEY, ENABLE_HTTPS, HTTPS_CERT, HTTPS_KEY, \
global BRANCH, CUR_COMMIT_HASH, CUR_COMMIT_BRANCH, ACTUAL_LOG_DIR, LOG_DIR, WEB_PORT, WEB_LOG, ENCRYPTION_VERSION, WEB_ROOT, WEB_USERNAME, WEB_PASSWORD, WEB_HOST, WEB_IPV6, USE_API, API_KEY, ENABLE_HTTPS, HTTPS_CERT, HTTPS_KEY, \
HANDLE_REVERSE_PROXY, USE_NZBS, USE_TORRENTS, NZB_METHOD, NZB_DIR, DOWNLOAD_PROPERS, CHECK_PROPERS_INTERVAL, ALLOW_HIGH_PRIORITY, TORRENT_METHOD, \
SAB_USERNAME, SAB_PASSWORD, SAB_APIKEY, SAB_CATEGORY, SAB_HOST, \
NZBGET_USERNAME, NZBGET_PASSWORD, NZBGET_CATEGORY, NZBGET_PRIORITY, NZBGET_HOST, NZBGET_USE_HTTPS, backlogSearchScheduler, \
Expand Down Expand Up @@ -511,13 +512,17 @@ def initialize(consoleLogging=True):
CheckSection(CFG, 'Pushbullet')
CheckSection(CFG, 'Subtitles')

# branch
# wanted branch
BRANCH = check_setting_str(CFG, 'General', 'branch', '')

# current commit hash
CUR_COMMIT_HASH = check_setting_str(CFG, 'General', 'cur_commit_hash', '')

# current commit branch
CUR_COMMIT_BRANCH = check_setting_str(CFG, 'General', 'cur_commit_branch', '')

ACTUAL_CACHE_DIR = check_setting_str(CFG, 'General', 'cache_dir', 'cache')

# fix bad configs due to buggy code
if ACTUAL_CACHE_DIR == 'None':
ACTUAL_CACHE_DIR = 'cache'
Expand Down Expand Up @@ -615,7 +620,7 @@ def initialize(consoleLogging=True):
NAMING_SPORTS_PATTERN = check_setting_str(CFG, 'General', 'naming_sports_pattern', '%SN - %A-D - %EN')
NAMING_ANIME = check_setting_int(CFG, 'General', 'naming_anime', 3)
NAMING_CUSTOM_SPORTS = bool(check_setting_int(CFG, 'General', 'naming_custom_sports', 0))
NAMING_MULTI_EP = bool(check_setting_int(CFG, 'General', 'naming_multi_ep', 1))
NAMING_MULTI_EP = check_setting_int(CFG, 'General', 'naming_multi_ep', 1)
NAMING_FORCE_FOLDERS = naming.check_force_season_folders()
NAMING_STRIP_YEAR = bool(check_setting_int(CFG, 'General', 'naming_strip_year', 0))

Expand Down Expand Up @@ -1310,6 +1315,7 @@ def save_config():
new_config['General'] = {}
new_config['General']['branch'] = BRANCH
new_config['General']['cur_commit_hash'] = CUR_COMMIT_HASH
new_config['General']['cur_commit_branch'] = CUR_COMMIT_BRANCH
new_config['General']['config_version'] = CONFIG_VERSION
new_config['General']['encryption_version'] = int(ENCRYPTION_VERSION)
new_config['General']['log_dir'] = ACTUAL_LOG_DIR if ACTUAL_LOG_DIR else 'Logs'
Expand Down
8 changes: 6 additions & 2 deletions sickbeard/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ def __init__(self, episodes):
# release group
self.release_group = ""


# version
self.version = -1

def __str__(self):

if self.provider == None:
Expand Down Expand Up @@ -218,7 +220,9 @@ def __init__(self, name, url, date, show):
self.date = date
self.provider = None
self.quality = Quality.UNKNOWN

self.release_group = None
self.version = -1

self.show = show
self.indexer = None
self.indexerid = -1
Expand Down
10 changes: 8 additions & 2 deletions sickbeard/scene_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,11 +256,17 @@ def update_scene_exceptions(indexer_id, scene_exceptions, season=-1):
"""
Given a indexer_id, and a list of all show scene exceptions, update the db.
"""

global exceptionsCache
myDB = db.DBConnection('cache.db')
myDB.action('DELETE FROM scene_exceptions WHERE indexer_id=?', [indexer_id])

logger.log(u"Updating scene exceptions", logger.MESSAGE)

# A change has been made to the scene exception list. Let's clear the cache, to make this visible
if indexer_id in exceptionsCache:
exceptionsCache[indexer_id] = {}
exceptionsCache[indexer_id][season] = scene_exceptions

for cur_exception in scene_exceptions:

if not isinstance(cur_exception, unicode):
Expand Down Expand Up @@ -316,7 +322,7 @@ def _xem_exceptions_fetcher():


def getSceneSeasons(indexer_id):
"""get a list of season numbers that have scene excpetions
"""get a list of season numbers that have scene exceptions
"""
myDB = db.DBConnection('cache.db')
seasons = myDB.select("SELECT DISTINCT season FROM scene_exceptions WHERE indexer_id = ?", [indexer_id])
Expand Down
5 changes: 2 additions & 3 deletions sickbeard/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,9 +586,8 @@ def searchProviders(show, season, episodes, manualSearch=False):
u"Single-ep check result is neededEps: " + str(neededEps) + ", notNeededEps: " + str(notNeededEps),
logger.DEBUG)

if not neededEps:
logger.log(u"All of these episodes were covered by single nzbs, ignoring this multi-ep result",
logger.DEBUG)
if not notNeededEps:
logger.log(u"All of these episodes were covered by single episode results, ignoring this multi-episode result", logger.DEBUG)
continue

# check if these eps are already covered by another multi-result
Expand Down
4 changes: 2 additions & 2 deletions sickbeard/show_name_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,10 @@ def allPossibleShowNames(show, season=-1):
Returns: a list of all the possible show names
"""

showNames = get_scene_exceptions(show.indexerid, season=season)
showNames = get_scene_exceptions(show.indexerid, season=season)[:]
if not showNames: # if we dont have any season specific exceptions fallback to generic exceptions
season = -1
showNames = get_scene_exceptions(show.indexerid, season=season)
showNames = get_scene_exceptions(show.indexerid, season=season)[:]

if season in [-1, 1]:
showNames.append(show.name)
Expand Down
17 changes: 9 additions & 8 deletions sickbeard/versionChecker.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,23 +571,23 @@ def __init__(self):
self._num_commits_behind = 0

def _find_installed_branch(self):
if sickbeard.BRANCH == "":
if sickbeard.CUR_COMMIT_BRANCH == "":
return "master"

return ""
else:
return sickbeard.CUR_COMMIT_BRANCH

def need_update(self):

if self.branch != self._find_installed_branch():
logger.log(u"Branch checkout: " + self._find_installed_branch() + "->" + self.branch, logger.DEBUG)
return True

# need this to run first to set self._newest_commit_hash
try:
self._check_github_for_update()
except Exception, e:
logger.log(u"Unable to contact github, can't check for update: " + repr(e), logger.ERROR)
return False

if self.branch != self._find_installed_branch():
logger.log(u"Branch checkout: " + self._find_installed_branch() + "->" + self.branch, logger.DEBUG)
return True

if not self._cur_commit_hash or self._num_commits_behind > 0:
return True

Expand Down Expand Up @@ -738,6 +738,7 @@ def update(self):
os.renames(old_path, new_path)

sickbeard.CUR_COMMIT_HASH = self._newest_commit_hash
sickbeard.CUR_COMMIT_BRANCH = self.branch

except Exception, e:
logger.log(u"Error while trying to update: " + ex(e), logger.ERROR)
Expand Down
2 changes: 1 addition & 1 deletion sickbeard/webserve.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ def _getEpisode(show, season=None, episode=None, absolute=None):
return "Invalid show paramaters"

if absolute:
epObj = showObj.getEpisode(absolute=int(absolute))
epObj = showObj.getEpisode(absolute_number=int(absolute))
elif season and episode:
epObj = showObj.getEpisode(int(season), int(episode))
else:
Expand Down

0 comments on commit 6eccffc

Please sign in to comment.