From 4d41d881eb1a2cfbb5414366a981148990749e2b Mon Sep 17 00:00:00 2001 From: echel0n Date: Sun, 16 Nov 2014 02:58:20 -0800 Subject: [PATCH] Fix for pyGitHub module not found issue. Added in bugtracker class --- sickbeard/__init__.py | 11 ++++++++++- sickbeard/bug_tracker.py | 5 +++++ sickbeard/versionChecker.py | 11 +++-------- sickbeard/webserve.py | 1 + 4 files changed, 19 insertions(+), 9 deletions(-) create mode 100644 sickbeard/bug_tracker.py diff --git a/sickbeard/__init__.py b/sickbeard/__init__.py index e71cf276..1bbae452 100755 --- a/sickbeard/__init__.py +++ b/sickbeard/__init__.py @@ -30,6 +30,8 @@ from threading import Lock import sys import os.path sys.path.append(os.path.abspath('../lib')) + +from github import Github from sickbeard import providers, metadata, config, webserveInit from sickbeard.providers.generic import GenericProvider from providers import ezrss, tvtorrents, btn, newznab, womble, thepiratebay, torrentleech, kat, iptorrents, \ @@ -78,6 +80,10 @@ NO_RESIZE = False # system events events = None +# github +gh = None + +# schedualers dailySearchScheduler = None backlogSearchScheduler = None showUpdateScheduler = None @@ -510,7 +516,7 @@ def initialize(consoleLogging=True): USE_FAILED_DOWNLOADS, DELETE_FAILED, ANON_REDIRECT, LOCALHOST_IP, TMDB_API_KEY, DEBUG, PROXY_SETTING, PROXY_INDEXERS, \ AUTOPOSTPROCESSER_FREQUENCY, DEFAULT_AUTOPOSTPROCESSER_FREQUENCY, MIN_AUTOPOSTPROCESSER_FREQUENCY, \ ANIME_DEFAULT, NAMING_ANIME, ANIMESUPPORT, USE_ANIDB, ANIDB_USERNAME, ANIDB_PASSWORD, ANIDB_USE_MYLIST, \ - ANIME_SPLIT_HOME, SCENE_DEFAULT, PLAY_VIDEOS, BACKLOG_DAYS, GIT_ORG, GIT_REPO + ANIME_SPLIT_HOME, SCENE_DEFAULT, PLAY_VIDEOS, BACKLOG_DAYS, GIT_ORG, GIT_REPO, gh if __INITIALIZED__: return False @@ -1107,6 +1113,9 @@ def initialize(consoleLogging=True): tmp_provider.set_config(cur_metadata_config) metadata_provider_dict[tmp_provider.name] = tmp_provider + # github + gh = Github().get_organization(GIT_ORG).get_repo(GIT_REPO) + # initialize schedulers # updaters update_now = datetime.timedelta(minutes=0) diff --git a/sickbeard/bug_tracker.py b/sickbeard/bug_tracker.py new file mode 100644 index 00000000..0c4f303e --- /dev/null +++ b/sickbeard/bug_tracker.py @@ -0,0 +1,5 @@ +import sickbeard + +class BugTracker: + def submit_bug(self, title, error): + return sickbeard.gh.create_issue(title, error, labels=[sickbeard.gh().get_label(sickbeard.BRANCH)]) \ No newline at end of file diff --git a/sickbeard/versionChecker.py b/sickbeard/versionChecker.py index 47eb0e51..52168161 100644 --- a/sickbeard/versionChecker.py +++ b/sickbeard/versionChecker.py @@ -28,14 +28,12 @@ import stat import traceback import sickbeard -from github import Github from sickbeard import helpers, notifiers from sickbeard import ui from sickbeard import logger from sickbeard.exceptions import ex from sickbeard import encodingKludge as ek - class CheckVersion(): """ Version check class meant to run as a thread object with the sr scheduler. @@ -617,11 +615,9 @@ class SourceUpdateManager(UpdateManager): self._num_commits_behind = 0 self._newest_commit_hash = None - gh = Github().get_organization(self.github_org).get_repo(self.github_repo) - # try to get newest commit hash and commits behind directly by comparing branch and current commit if self._cur_commit_hash: - branch_compared = gh.compare(base=self.branch, head=self._cur_commit_hash) + branch_compared = sickbeard.gh.compare(base=self.branch, head=self._cur_commit_hash) if 'base_commit' in branch_compared: self._newest_commit_hash = branch_compared['base_commit']['sha'] @@ -632,7 +628,7 @@ class SourceUpdateManager(UpdateManager): # fall back and iterate over last 100 (items per page in gh_api) commits if not self._newest_commit_hash: - for curCommit in gh.get_commits(): + for curCommit in sickbeard.gh.get_commits(): if not self._newest_commit_hash: self._newest_commit_hash = curCommit['sha'] if not self._cur_commit_hash: @@ -764,5 +760,4 @@ class SourceUpdateManager(UpdateManager): return True def list_remote_branches(self): - gh = Github().get_organization(self.github_org).get_repo(self.github_repo) - return [x.name for x in gh.get_branches() if x] \ No newline at end of file + return [x.name for x in sickbeard.gh.get_branches() if x] diff --git a/sickbeard/webserve.py b/sickbeard/webserve.py index f5ae6304..d56d755e 100644 --- a/sickbeard/webserve.py +++ b/sickbeard/webserve.py @@ -82,6 +82,7 @@ from lib import adba from Cheetah.Template import Template from tornado.web import RequestHandler, HTTPError, asynchronous +from bug_tracker import BugTracker def authenticated(handler_class): def wrap_execute(handler_execute):