def githubs(request): githubs = cache.get("githubs") if not githubs: githubs = [] try: gh = settings.GITHUB me = github3.user(gh['USERNAME']) consumer = oauth2.Consumer(key="", secret="") client = oauth2.Client(consumer) resp, content = client.request(me.events_urlt.expand(), 'GET') events = json.loads(content) for event in events: git_event = event date = datetime.strptime(event['created_at'], "%Y-%m-%dT%H:%M:%SZ") e_type = event['type'] git_event.update({"repo_url": "http://github.com/%s" % (event['repo']['name'])}) git_event.update({"date": date, "type": "github", "event_type": e_type, "USERNAME": gh['USERNAME']}) githubs.append(git_event) cache.set("githubs", githubs, 60 * 60) except: pass return embeds(githubs)
def __init__(self, methodName='runTest'): super(TestUser, self).__init__(methodName) self.user = github3.user(self.sigm)
def test_user(self): github3.user('login') self.gh.user.assert_called_with('login')
def test_user(self): expect(github3.user(self.sigm)).isinstance(github3.users.User)
def test_user(self): """Show that github3.user proxies to GitHub.""" github3.user('sigmavirus24') self.gh.user.assert_called_once_with('sigmavirus24')
# Dump of all possible events #['CommitCommentEvent', 'CreateEvent', 'DeleteEvent', 'FollowEvent', 'ForkApplyEvent', 'ForkEvent', 'GistEvent', 'GollumEvent', 'IssueCommentEvent', 'IssuesEvent', 'MemberEvent', 'PublicEvent', 'PullRequestEvent', 'PullRequestReviewCommentEvent', 'PushEvent', 'ReleaseEvent', 'StatusEvent', 'TeamAddEvent', 'WatchEvent'] # Valid commit types valid_commits = ['PushEvent', 'CreateEvent'] # Get today's date now = datetime.datetime.now() print 'Time now is now: ' today = get_time_string(now.isoformat().encode('utf-8')) print 'Day now is (UTC): ', today user = gh.user(login) user = auth.user() day_bins = {today:0} # Go through each event for event in user.iter_events(): # If its a valid streak event if event.type in valid_commits: # Only count public events if event.public: # Get the payload payload = event.payload # Get created datetime cur_dt = get_time_string(utc_to_local(event.created_at).isoformat()) # If it's a push event if event.type == valid_commits[0]: # If the commit was to master