Skip to content

Commit

Permalink
Adding vendored uritemplate, background queue for getting data from g…
Browse files Browse the repository at this point in the history
…ithub
  • Loading branch information
GladeDiviney committed Mar 25, 2016
1 parent c26f4b9 commit d15863d
Show file tree
Hide file tree
Showing 55 changed files with 4,794 additions and 33 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ Combines data from ZenHub.io and GitHub to make some interesting charts.
## Deployment

1. Create a new application in Google App Engine
2. Copy the ID into .gaeid
2. Copy the application ID into `.gaeid`
3. From the root folder run `dev/update`
3 changes: 3 additions & 0 deletions app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ handlers:
- url: /.*
script: zenchart.app

builtins:
- deferred: on

libraries:
- name: jinja2
version: latest
67 changes: 67 additions & 0 deletions github.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
from urllib2 import Request, urlopen, URLError
import base64, json
import datetime, time
import logging
from model import Issue
# Get vendored uritemplate module
from google.appengine.ext import vendor
vendor.add('lib')
import uritemplate

githubUrl = 'https://api.github.com/repos'

def getJson(repo, url):
if githubUrl not in url:
url = githubUrl + '/' + repo.name + url
logging.info('github GET ' + url)
request = Request(url)
encoded = base64.b64encode('%s:%s' % (repo.auth.githubUser, repo.auth.githubToken))
request.add_header('Authorization', 'Basic ' + encoded)
return json.load(urlopen(request))

def getAllPages(repo, url):
pageSize = 50
pageNumber = 0
items = []
more = True
if '?' not in url:
url += '?'
else:
url += '&'
while more:
fetchUrl = url + 'per_page=%d&page=%d' % (pageSize, pageNumber)
page = getJson(repo, fetchUrl)
items.extend(page)
pageNumber += 1
more = len(page) == pageSize
return items

def syncIssues(repo):
# Determine the most recently updated issue
latest = None
for issue in repo.issues():
if not latest or latest < issue.github['']:
logging.info("???")

def getIssueEvents(repo, issue):
events = getAllPages(repo, issue.github['events_url'])
logging.info('Found %d events for #%s' % (len(events),issue.number))
issue.github['events'] = events

def getAllIssues(repo):
# Update the repo with content
repo.data = getJson(repo, '')
repo.put()

logging.info(uritemplate.expand(repo.data['issues_url'], {}))

issueUrl = uritemplate.expand(repo.data['issues_url'], {})
issueUrl += '?state=all'
issues = getAllPages(repo, issueUrl)
for issueData in issues:
issue = Issue(repo = repo.key, github = issueData, number = issueData['number'])
getIssueEvents(repo, issue)
issue.upsert()

#logging.info(json.dumps(repo.data, indent=2))

17 changes: 14 additions & 3 deletions html/repo.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
{% extends "base.html" %}
{% block body %}
<h1><a href="/">Home</a> >> {{ repo.name }}<h1>

<h1><a href="/">Home</a> &rarr; {{ repo.name }}</h1>
{% if issues %}
<ul>
{% for issue in issues %}
<li>{{ issue.number }} - {{ issue.github['state'] }} - {{ issue.github['events']|length }} events</li>
{% endfor %}
</ul>
{% else %}
<p>No issues</p>
{% endif %}
<form action="{{ repo.url() + '/sync' }}" method="post">
<div><input type="submit" value="Sync this repo"></div>
</form>

<form action="{{ repo.url() + '/delete' }}" method="post">
<div><input type="submit" value="Delete this repo"></div>
<form>
</form>
{% endblock %}
54 changes: 54 additions & 0 deletions lib/simplejson-3.8.2.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
Metadata-Version: 1.1
Name: simplejson
Version: 3.8.2
Summary: Simple, fast, extensible JSON encoder/decoder for Python
Home-page: http://github.com/simplejson/simplejson
Author: Bob Ippolito
Author-email: [email protected]
License: MIT License
Description: simplejson is a simple, fast, complete, correct and extensible
JSON <http://json.org> encoder and decoder for Python 2.5+
and Python 3.3+. It is pure Python code with no dependencies,
but includes an optional C extension for a serious speed boost.

The latest documentation for simplejson can be read online here:
http://simplejson.readthedocs.org/

simplejson is the externally maintained development version of the
json library included with Python 2.6 and Python 3.0, but maintains
backwards compatibility with Python 2.5.

The encoder can be specialized to provide serialization in any kind of
situation, without any special support by the objects to be serialized
(somewhat like pickle). This is best done with the ``default`` kwarg
to dumps.

The decoder can handle incoming JSON strings of any specified encoding
(UTF-8 by default). It can also be specialized to post-process JSON
objects with the ``object_hook`` or ``object_pairs_hook`` kwargs. This
is particularly useful for implementing protocols such as JSON-RPC
that have a richer type system than JSON itself.

For those of you that have legacy systems to maintain, there is a
very old fork of simplejson in the `python2.2`_ branch that supports
Python 2.2. This is based off of a very old version of simplejson,
is not maintained, and should only be used as a last resort.

.. _python2.2: https://github.com/simplejson/simplejson/tree/python2.2

Platform: any
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: License :: OSI Approved :: Academic Free License (AFL)
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.5
Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Software Development :: Libraries :: Python Modules
51 changes: 51 additions & 0 deletions lib/simplejson-3.8.2.egg-info/SOURCES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
CHANGES.txt
LICENSE.txt
MANIFEST.in
README.rst
conf.py
index.rst
setup.cfg
setup.py
scripts/artifacts.py
scripts/make_docs.py
simplejson/__init__.py
simplejson/_speedups.c
simplejson/compat.py
simplejson/decoder.py
simplejson/encoder.py
simplejson/ordered_dict.py
simplejson/scanner.py
simplejson/tool.py
simplejson.egg-info/PKG-INFO
simplejson.egg-info/SOURCES.txt
simplejson.egg-info/dependency_links.txt
simplejson.egg-info/top_level.txt
simplejson/tests/__init__.py
simplejson/tests/test_bigint_as_string.py
simplejson/tests/test_bitsize_int_as_string.py
simplejson/tests/test_check_circular.py
simplejson/tests/test_decimal.py
simplejson/tests/test_decode.py
simplejson/tests/test_default.py
simplejson/tests/test_dump.py
simplejson/tests/test_encode_basestring_ascii.py
simplejson/tests/test_encode_for_html.py
simplejson/tests/test_errors.py
simplejson/tests/test_fail.py
simplejson/tests/test_float.py
simplejson/tests/test_for_json.py
simplejson/tests/test_indent.py
simplejson/tests/test_item_sort_key.py
simplejson/tests/test_iterable.py
simplejson/tests/test_namedtuple.py
simplejson/tests/test_pass1.py
simplejson/tests/test_pass2.py
simplejson/tests/test_pass3.py
simplejson/tests/test_recursion.py
simplejson/tests/test_scanstring.py
simplejson/tests/test_separators.py
simplejson/tests/test_speedups.py
simplejson/tests/test_subclass.py
simplejson/tests/test_tool.py
simplejson/tests/test_tuple.py
simplejson/tests/test_unicode.py
1 change: 1 addition & 0 deletions lib/simplejson-3.8.2.egg-info/dependency_links.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

78 changes: 78 additions & 0 deletions lib/simplejson-3.8.2.egg-info/installed-files.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
../simplejson/compat.py
../simplejson/scanner.py
../simplejson/ordered_dict.py
../simplejson/encoder.py
../simplejson/decoder.py
../simplejson/__init__.py
../simplejson/tool.py
../simplejson/tests/test_pass1.py
../simplejson/tests/test_speedups.py
../simplejson/tests/test_encode_for_html.py
../simplejson/tests/test_separators.py
../simplejson/tests/test_indent.py
../simplejson/tests/test_iterable.py
../simplejson/tests/test_decimal.py
../simplejson/tests/test_item_sort_key.py
../simplejson/tests/test_pass2.py
../simplejson/tests/test_unicode.py
../simplejson/tests/test_scanstring.py
../simplejson/tests/test_for_json.py
../simplejson/tests/test_check_circular.py
../simplejson/tests/test_default.py
../simplejson/tests/test_subclass.py
../simplejson/tests/test_errors.py
../simplejson/tests/test_dump.py
../simplejson/tests/test_tool.py
../simplejson/tests/test_bitsize_int_as_string.py
../simplejson/tests/test_recursion.py
../simplejson/tests/test_bigint_as_string.py
../simplejson/tests/__init__.py
../simplejson/tests/test_namedtuple.py
../simplejson/tests/test_decode.py
../simplejson/tests/test_encode_basestring_ascii.py
../simplejson/tests/test_fail.py
../simplejson/tests/test_float.py
../simplejson/tests/test_pass3.py
../simplejson/tests/test_tuple.py
../simplejson/compat.pyc
../simplejson/scanner.pyc
../simplejson/ordered_dict.pyc
../simplejson/encoder.pyc
../simplejson/decoder.pyc
../simplejson/__init__.pyc
../simplejson/tool.pyc
../simplejson/tests/test_pass1.pyc
../simplejson/tests/test_speedups.pyc
../simplejson/tests/test_encode_for_html.pyc
../simplejson/tests/test_separators.pyc
../simplejson/tests/test_indent.pyc
../simplejson/tests/test_iterable.pyc
../simplejson/tests/test_decimal.pyc
../simplejson/tests/test_item_sort_key.pyc
../simplejson/tests/test_pass2.pyc
../simplejson/tests/test_unicode.pyc
../simplejson/tests/test_scanstring.pyc
../simplejson/tests/test_for_json.pyc
../simplejson/tests/test_check_circular.pyc
../simplejson/tests/test_default.pyc
../simplejson/tests/test_subclass.pyc
../simplejson/tests/test_errors.pyc
../simplejson/tests/test_dump.pyc
../simplejson/tests/test_tool.pyc
../simplejson/tests/test_bitsize_int_as_string.pyc
../simplejson/tests/test_recursion.pyc
../simplejson/tests/test_bigint_as_string.pyc
../simplejson/tests/__init__.pyc
../simplejson/tests/test_namedtuple.pyc
../simplejson/tests/test_decode.pyc
../simplejson/tests/test_encode_basestring_ascii.pyc
../simplejson/tests/test_fail.pyc
../simplejson/tests/test_float.pyc
../simplejson/tests/test_pass3.pyc
../simplejson/tests/test_tuple.pyc
../simplejson/_speedups.so
./
PKG-INFO
SOURCES.txt
top_level.txt
dependency_links.txt
1 change: 1 addition & 0 deletions lib/simplejson-3.8.2.egg-info/top_level.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
simplejson
Loading

0 comments on commit d15863d

Please sign in to comment.