Skip to content

Commit

Permalink
Removed status icon.
Browse files Browse the repository at this point in the history
  • Loading branch information
mstead committed May 9, 2013
1 parent 9d1b0cd commit 3588bdb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 73 deletions.
28 changes: 3 additions & 25 deletions bin/prspy
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,9 @@ import time
import gtk
import glib

from prspy.utils import get_yes_no
from prspy import config
from prspy.gui.component import StatusIcon
from prspy.github_util import GithubConnect
from prspy.gui.controllers import MainViewController
from prspy.config import NotConfiguredError, PRSpyConfig, ConfigBuilder
from prspy.config import NotConfiguredError, PRSpyConfig


class PRSpyError(Exception):
Expand All @@ -28,29 +25,10 @@ class PRSpy():
print "An error occurred reading the PRSpy config file:"
print " %s" % e.message
print ""
if get_yes_no("Would you like to (re)configure PRSpy?"):
config = ConfigBuilder().build()
else:
sys.exit(0)


self.status_icon = StatusIcon()
self.status_icon.connect('activate', self._on_activate)
self.status_icon.connect('force_clicked', self._update)
self.status_icon.connect('quit_clicked', self._exit_app)

sys.exit(1)

self.main_view_controller = MainViewController(config)

def _on_activate(self, icon):
self.main_view_controller.show_main_view()
self.status_icon.reset_icon_state()

def _update(self, icon):
self.main_view_controller.refresh_model()

def _exit_app(self, icon):
gtk.main_quit()


if __name__ == "__main__":
Expand All @@ -63,7 +41,7 @@ if __name__ == "__main__":

try:
PRSpy()
gtk.main()
sys.exit(gtk.main() or 0)
except PRSpyError, e:
print e.message
sys.exit(1)
Expand Down
48 changes: 0 additions & 48 deletions src/prspy/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,51 +93,3 @@ def _validate(self, section, option):
if not self.parser.has_option(section, option):
raise ConfigurationError("Missing option for % section: %s" % (section, option))


class ConfigBuilder(object):

def build(self):
auth_token, org_id = self._get_config_values()
parser = ConfigParser.SafeConfigParser()
parser.add_section("github")
parser.set("github", "auth_token", auth_token)
parser.set("github", "org_id", org_id)
parser.write(file(CONFIG_FILE, "w"))
config = PRSpyConfig()
print "PRSpy was properly configured."
print "Launching PRSpy..."
return config

def _get_config_values(self):
print "PRSpy requires an Oauth token to communicate to the github API."
username = get_input("Github Username: ")
password = getpass("Github Password")
key_note = get_input("Short Token Description: ")
auth = "%s:%s" % (username, password)
auth = auth.encode("base64").rstrip()

headers = {
"Authorization": "Basic %s" % auth,
"Content-Type": "application/json",
'User-Agent': "PRSpy"
}

body = '{"scopes":["public_repo", "repo"], "note":"%s"}' % key_note

conn = httplib.HTTPSConnection("api.github.com")
conn.request("POST", "/authorizations", body, headers)
response = conn.getresponse()
if response.status != 201:
print "Could not create github API token."
sys.exit(1)

auth_json = simplejson.loads(response.read())
if not 'token' in auth_json:
print "Unable to create Github API token in response."
sys.exit(1)

api_auth_token = auth_json['token']

org = get_input("Which organization would you like to track? ")
return (api_auth_token, org)

0 comments on commit 3588bdb

Please sign in to comment.