From de8adb24d0a73ed965a1a17dfe6cb0c2bdedc340 Mon Sep 17 00:00:00 2001 From: echel0n Date: Thu, 7 Aug 2014 22:44:06 -0700 Subject: [PATCH 1/4] Fix for AttributeError in SourceUpdateManager --- sickbeard/versionChecker.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sickbeard/versionChecker.py b/sickbeard/versionChecker.py index b9161ab4..3b172485 100644 --- a/sickbeard/versionChecker.py +++ b/sickbeard/versionChecker.py @@ -557,6 +557,10 @@ class GitUpdateManager(UpdateManager): class SourceUpdateManager(UpdateManager): def __init__(self): + self._cur_commit_hash = None + self._newest_commit_hash = None + self._num_commits_behind = 0 + self.github_repo_user = self.get_github_repo_user() self.github_repo = self.get_github_repo() @@ -564,10 +568,6 @@ class SourceUpdateManager(UpdateManager): if sickbeard.BRANCH == '': self.branch = self._find_installed_branch() - self._cur_commit_hash = None - self._newest_commit_hash = None - self._num_commits_behind = 0 - def _find_installed_version(self): installed_path = os.path.dirname(os.path.normpath(os.path.abspath(__file__))) self._cur_commit_hash = self.hash_dir(installed_path) @@ -784,4 +784,4 @@ class SourceUpdateManager(UpdateManager): # split+join normalizes paths on Windows (note the imports) dir_hash[os.path.join(*os.path.split(root))] = self._mktree(f_hash, d_hash) - return dir_hash[path] \ No newline at end of file + return dir_hash[path] From 922df4c160b4be966c4e8161c785ba479c4ce353 Mon Sep 17 00:00:00 2001 From: echel0n Date: Thu, 7 Aug 2014 22:58:41 -0700 Subject: [PATCH 2/4] Fix for NoneType errors --- sickbeard/versionChecker.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sickbeard/versionChecker.py b/sickbeard/versionChecker.py index 3b172485..2f29d574 100644 --- a/sickbeard/versionChecker.py +++ b/sickbeard/versionChecker.py @@ -430,7 +430,9 @@ class GitUpdateManager(UpdateManager): branch = branch_info.strip().replace('refs/heads/', '', 1) if branch: return branch - + + return "" + def _check_github_for_update(self): """ Uses git commands to check if there is a newer version that the provided @@ -581,6 +583,8 @@ class SourceUpdateManager(UpdateManager): for branch in gh.branches(): if 'commit' in branch and self._cur_commit_hash and branch.commit['sha'] == self._cur_commit_hash: return branch.name + + return "" def need_update(self): From f9ababe7cbf54dd822f121138a62b3cdfac92c89 Mon Sep 17 00:00:00 2001 From: echel0n Date: Thu, 7 Aug 2014 23:21:30 -0700 Subject: [PATCH 3/4] Fix for updating issues --- sickbeard/versionChecker.py | 38 ++++--------------------------------- 1 file changed, 4 insertions(+), 34 deletions(-) diff --git a/sickbeard/versionChecker.py b/sickbeard/versionChecker.py index 2f29d574..b9495feb 100644 --- a/sickbeard/versionChecker.py +++ b/sickbeard/versionChecker.py @@ -579,13 +579,11 @@ class SourceUpdateManager(UpdateManager): sickbeard.CUR_COMMIT_HASH = str(self._cur_commit_hash) def _find_installed_branch(self): - gh = github.GitHub(self.github_repo_user, self.github_repo, self.branch) - for branch in gh.branches(): - if 'commit' in branch and self._cur_commit_hash and branch.commit['sha'] == self._cur_commit_hash: - return branch.name - + if sickbeard.BRANCH == "": + return "master" + return "" - + def need_update(self): if self.branch != self._find_installed_branch(): @@ -761,31 +759,3 @@ class SourceUpdateManager(UpdateManager): def list_remote_branches(self): gh = github.GitHub(self.github_repo_user, self.github_repo, self.branch) return [x.name for x in gh.branches()] - - def _lstree(self, files, dirs): - """Make git ls-tree like output.""" - for f, sha1 in files: - yield "100644 blob {}\t{}\0".format(sha1, f) - - for d, sha1 in dirs: - yield "040000 tree {}\t{}\0".format(sha1, d) - - def _mktree(self, files, dirs): - mkt = subprocess.Popen(["git", "mktree", "-z"], stdin=subprocess.PIPE, stdout=subprocess.PIPE) - return mkt.communicate("".join(self._lstree(files, dirs)))[0].strip() - - def hash_file(self, path): - """Write file at path to Git index, return its SHA1 as a string.""" - return subprocess.check_output(["git", "hash-object", "-w", "--", path]).strip() - - def hash_dir(self, path): - """Write directory at path to Git index, return its SHA1 as a string.""" - dir_hash = {} - - for root, dirs, files in os.walk(path, topdown=False): - f_hash = ((f, self.hash_file(os.path.join(root, f))) for f in files) - d_hash = ((d, dir_hash[os.path.join(root, d)]) for d in dirs) - # split+join normalizes paths on Windows (note the imports) - dir_hash[os.path.join(*os.path.split(root))] = self._mktree(f_hash, d_hash) - - return dir_hash[path] From 1bf47900dfbcd2f626b346892118c322a3d6de77 Mon Sep 17 00:00:00 2001 From: echel0n Date: Thu, 7 Aug 2014 23:30:56 -0700 Subject: [PATCH 4/4] More fixes for source code updating --- sickbeard/versionChecker.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sickbeard/versionChecker.py b/sickbeard/versionChecker.py index b9495feb..a4b32e90 100644 --- a/sickbeard/versionChecker.py +++ b/sickbeard/versionChecker.py @@ -559,10 +559,6 @@ class GitUpdateManager(UpdateManager): class SourceUpdateManager(UpdateManager): def __init__(self): - self._cur_commit_hash = None - self._newest_commit_hash = None - self._num_commits_behind = 0 - self.github_repo_user = self.get_github_repo_user() self.github_repo = self.get_github_repo() @@ -570,6 +566,10 @@ class SourceUpdateManager(UpdateManager): if sickbeard.BRANCH == '': self.branch = self._find_installed_branch() + self._cur_commit_hash = None + self._newest_commit_hash = None + self._num_commits_behind = 0 + def _find_installed_version(self): installed_path = os.path.dirname(os.path.normpath(os.path.abspath(__file__))) self._cur_commit_hash = self.hash_dir(installed_path)