Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
11 changes: 11 additions & 0 deletions app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
runtime: python27
api_version: 1
threadsafe: true

handlers:
- url: /.*
script: main.app

libraries:
- name: ssl
version: 2.7.11
6 changes: 6 additions & 0 deletions appengine_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

from google.appengine.ext import vendor

# Add any libraries installed in the "lib" folder.
vendor.add('lib')

1 change: 1 addition & 0 deletions data.csv

Large diffs are not rendered by default.

93 changes: 93 additions & 0 deletions frc_trueskill.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
from trueskill import TrueSkill, Rating, rate
import argparse
import requests
from datetime import datetime
#from pytba import api as tba


class FrcTrueSkill:
def __init__(self):
self.env = TrueSkill(draw_probability=0.02)
self.trueskills = {}
self.events = {}
self.get_previous_matches()
#for team in self.trueskills.keys():
# print team, self.skill(team)

def update(self, red_alliance, red_score, blue_alliance, blue_score):
# Calculate teams per alliance
for alliance in [red_alliance, blue_alliance]:
for team in alliance:
if not team in self.trueskills:
self.trueskills[team] = self.env.Rating()
# Update ratings based on result
if red_score == blue_score: # Tied
if red_score == -1:
return # No result yet
ranks = [0, 0]
elif red_score > blue_score: # Red beat blue
ranks = [0, 1] # Lower is better
else:
ranks = [1, 0]
new_red, new_blue = self.env.rate([[self.trueskills[number] for number in red_alliance],
[self.trueskills[number] for number in blue_alliance]], ranks)
# Store the new values
new_ratings = new_red + new_blue
for rating, team_number in zip(new_ratings, red_alliance + blue_alliance):
self.trueskills[team_number] = rating


def predict(self, red_alliance, blue_alliance):
proba = self.env.quality([[self.trueskills[team] for team in red_alliance],
[self.trueskills[team] for team in blue_alliance]])
return round(proba*100)

def skill(self, team):
return self.env.expose(self.trueskills[team])

def get_previous_matches(self):
started_events = []
all_matches = []
events = requests.get("https://www.thebluealliance.com/api/v2/events/2017")
events = events.json()

for event in events:
if event['event_type'] > 5:
continue
if event['start_date'] < str(datetime.date(datetime.today())):
started_events.append(event["key"])

teams = requests.get("https://www.thebluealliance.com/api/v2/event/"+event['key']+"/teams", headers={"X-TBA-App-Id":"frc-4774:TrueSkill:1.0"})
teams = teams.json()
self.events[event['key']] = teams

for event in started_events:
matches = requests.get("https://www.thebluealliance.com/api/v2/event/"+event+"/matches", headers={"X-TBA-App-Id":"frc-4774:TrueSkill:1.0"})

matches = matches.json()
all_matches += matches
all_matches.sort(key=lambda m: m['time'])

for match in all_matches:
score = match['score_breakdown']
if score is None:
continue

red_stats = score['red']
blue_stats = score['blue']

alliances = match['alliances']
red = alliances['red']
blue = alliances['blue']

if red_stats["rotor3Engaged"]:
red['score'] += 100
if red_stats["kPaRankingPointAchieved"]:
red['score'] += 20

if blue_stats["rotor3Engaged"]:
blue['score'] += 100
if blue_stats["kPaRankingPointAchieved"]:
blue['score'] += 20

self.update(red['teams'], red['score'], blue['teams'], blue['score'])
44 changes: 44 additions & 0 deletions lib/CacheControl-0.12.0.dist-info/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
==============
CacheControl
==============

.. image:: https://img.shields.io/pypi/v/cachecontrol.svg
:target: https://pypi.python.org/pypi/cachecontrol
:alt: Latest Version

.. image:: https://travis-ci.org/ionrock/cachecontrol.png?branch=master
:target: https://travis-ci.org/ionrock/cachecontrol

CacheControl is a port of the caching algorithms in httplib2_ for use with
requests_ session object.

It was written because httplib2's better support for caching is often
mitigated by its lack of threadsafety. The same is true of requests in
terms of caching.


Quickstart
==========

.. code-block:: python

import requests

from cachecontrol import CacheControl


sess = requests.session()
cached_sess = CacheControl(sess)

response = cached_sess.get('http://google.com')

If the URL contains any caching based headers, it will cache the
result in a simple dictionary.

For more info, check out the docs_

.. _docs: http://cachecontrol.readthedocs.org/en/latest/
.. _httplib2: https://github.com/jcgregorio/httplib2
.. _requests: http://docs.python-requests.org/


1 change: 1 addition & 0 deletions lib/CacheControl-0.12.0.dist-info/INSTALLER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pip
72 changes: 72 additions & 0 deletions lib/CacheControl-0.12.0.dist-info/METADATA
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
Metadata-Version: 2.0
Name: CacheControl
Version: 0.12.0
Summary: httplib2 caching for requests
Home-page: https://github.com/ionrock/cachecontrol
Author: Eric Larson
Author-email: eric@ionrock.org
License: UNKNOWN
Keywords: requests http caching web
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Web Environment
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.2
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Topic :: Internet :: WWW/HTTP
Requires-Dist: msgpack-python
Requires-Dist: requests
Provides-Extra: filecache
Requires-Dist: lockfile (>=0.9); extra == 'filecache'
Provides-Extra: redis
Requires-Dist: redis (>=2.10.5); extra == 'redis'

==============
CacheControl
==============

.. image:: https://img.shields.io/pypi/v/cachecontrol.svg
:target: https://pypi.python.org/pypi/cachecontrol
:alt: Latest Version

.. image:: https://travis-ci.org/ionrock/cachecontrol.png?branch=master
:target: https://travis-ci.org/ionrock/cachecontrol

CacheControl is a port of the caching algorithms in httplib2_ for use with
requests_ session object.

It was written because httplib2's better support for caching is often
mitigated by its lack of threadsafety. The same is true of requests in
terms of caching.


Quickstart
==========

.. code-block:: python

import requests

from cachecontrol import CacheControl


sess = requests.session()
cached_sess = CacheControl(sess)

response = cached_sess.get('http://google.com')

If the URL contains any caching based headers, it will cache the
result in a simple dictionary.

For more info, check out the docs_

.. _docs: http://cachecontrol.readthedocs.org/en/latest/
.. _httplib2: https://github.com/jcgregorio/httplib2
.. _requests: http://docs.python-requests.org/


35 changes: 35 additions & 0 deletions lib/CacheControl-0.12.0.dist-info/RECORD
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
CacheControl-0.12.0.dist-info/DESCRIPTION.rst,sha256=9f1LMZ8i_6tLyhk3I00_KAdeM7gPdsrWul9NaDDqQjU,1089
CacheControl-0.12.0.dist-info/METADATA,sha256=HSUSOtwEsJIFt_4_Bv3fSvzy2cYjmD9aEqxNIxr4uXY,2101
CacheControl-0.12.0.dist-info/RECORD,,
CacheControl-0.12.0.dist-info/WHEEL,sha256=AXucK5-TNISW1dQAdsyH02xCRCCE1VKjhXIOWMW_lxI,93
CacheControl-0.12.0.dist-info/entry_points.txt,sha256=HjCekaRCv8kfNqP5WehMR29IWxIA5VrhoOeKrCykCLc,56
CacheControl-0.12.0.dist-info/metadata.json,sha256=wXgWs27hhwp8rXDmYVb8L3hpv1MGyJ-wVsRnrSWFweE,1276
CacheControl-0.12.0.dist-info/top_level.txt,sha256=vGYWzpbe3h6gkakV4f7iCK2x3KyK3oMkV5pe5v25-d4,13
cachecontrol/__init__.py,sha256=_vVg9t514CfdnOGsjPgKgNf67hZvjBP3CnoeMqAEmp0,302
cachecontrol/_cmd.py,sha256=4ZzN7zdguKR-5F7vV1zX-5ftB65bLSk9UxVuXf0LLj4,1267
cachecontrol/adapter.py,sha256=khZLeNepwf-ZS_Ty0toq0-kxX2WnNOS0dLb5X4YpbX8,4596
cachecontrol/cache.py,sha256=xtl-V-pr9KSt9VvFDRCB9yrHPEvqvbk-5M1vAInZb5k,790
cachecontrol/compat.py,sha256=pjkcico64y8_Tf9gVzVasNG7l0PQOnhiH4gIlmybExE,653
cachecontrol/controller.py,sha256=xrzntX2YEjzsoax7GYleBpEuR9fAkgnBPThlDpoS3g0,13012
cachecontrol/filewrapper.py,sha256=_K8cStmXqD33m15PfsQ8rlpo6FfXjVbKmjvLXyICRgI,2531
cachecontrol/heuristics.py,sha256=WtJrVsyWjpP9WoUiDVdTZZRNBCz5ZVptaQpYnqofDQU,4141
cachecontrol/serialize.py,sha256=u1FAW57qi_RKKQwzmw_XbWGw24rYrF6aVM6PISN4ctE,5959
cachecontrol/wrapper.py,sha256=Kqyu_3TW_54XDudha4-HF21vyEOAJ4ZnRXFysTiLmXA,498
cachecontrol/caches/__init__.py,sha256=-gHNKYvaeD0kOk5M74eOrsSgIKUtC6i6GfbmugGweEo,86
cachecontrol/caches/file_cache.py,sha256=wugGlRqWI8jOQMRNXTco7MTRfyoiFS9Elru5XgDx9GA,3955
cachecontrol/caches/redis_cache.py,sha256=JQaeGYUovYuAxtQyHyvsi7sn73dOwQthfsVc9zzSF6k,983
../../bin/doesitcache,sha256=lGJzJb8Zt3MyuTAHUUdSlUaWwPddvDXTSFaOeceNb3E,220
CacheControl-0.12.0.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
cachecontrol/__pycache__/serialize.cpython-35.pyc,,
cachecontrol/__pycache__/cache.cpython-35.pyc,,
cachecontrol/__pycache__/_cmd.cpython-35.pyc,,
cachecontrol/__pycache__/adapter.cpython-35.pyc,,
cachecontrol/__pycache__/__init__.cpython-35.pyc,,
cachecontrol/__pycache__/heuristics.cpython-35.pyc,,
cachecontrol/caches/__pycache__/redis_cache.cpython-35.pyc,,
cachecontrol/__pycache__/wrapper.cpython-35.pyc,,
cachecontrol/caches/__pycache__/file_cache.cpython-35.pyc,,
cachecontrol/__pycache__/filewrapper.cpython-35.pyc,,
cachecontrol/__pycache__/controller.cpython-35.pyc,,
cachecontrol/caches/__pycache__/__init__.cpython-35.pyc,,
cachecontrol/__pycache__/compat.cpython-35.pyc,,
5 changes: 5 additions & 0 deletions lib/CacheControl-0.12.0.dist-info/WHEEL
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Wheel-Version: 1.0
Generator: bdist_wheel (0.29.0)
Root-Is-Purelib: true
Tag: cp35-none-any

3 changes: 3 additions & 0 deletions lib/CacheControl-0.12.0.dist-info/entry_points.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[console_scripts]
doesitcache = cachecontrol._cmd:main

1 change: 1 addition & 0 deletions lib/CacheControl-0.12.0.dist-info/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"classifiers": ["Development Status :: 4 - Beta", "Environment :: Web Environment", "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Topic :: Internet :: WWW/HTTP"], "extensions": {"python.commands": {"wrap_console": {"doesitcache": "cachecontrol._cmd:main"}}, "python.details": {"contacts": [{"email": "eric@ionrock.org", "name": "Eric Larson", "role": "author"}], "document_names": {"description": "DESCRIPTION.rst"}, "project_urls": {"Home": "https://github.com/ionrock/cachecontrol"}}, "python.exports": {"console_scripts": {"doesitcache": "cachecontrol._cmd:main"}}}, "extras": ["filecache", "redis"], "generator": "bdist_wheel (0.29.0)", "keywords": ["requests", "http", "caching", "web"], "metadata_version": "2.0", "name": "CacheControl", "run_requires": [{"extra": "filecache", "requires": ["lockfile (>=0.9)"]}, {"requires": ["msgpack-python", "requests"]}, {"extra": "redis", "requires": ["redis (>=2.10.5)"]}], "summary": "httplib2 caching for requests", "version": "0.12.0"}
1 change: 1 addition & 0 deletions lib/CacheControl-0.12.0.dist-info/top_level.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cachecontrol
46 changes: 46 additions & 0 deletions lib/Flask-0.12.dist-info/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
Flask
-----

Flask is a microframework for Python based on Werkzeug, Jinja 2 and good
intentions. And before you ask: It's BSD licensed!

Flask is Fun
````````````

Save in a hello.py:

.. code:: python

from flask import Flask
app = Flask(__name__)

@app.route("/")
def hello():
return "Hello World!"

if __name__ == "__main__":
app.run()

And Easy to Setup
`````````````````

And run it:

.. code:: bash

$ pip install Flask
$ python hello.py
* Running on http://localhost:5000/

Ready for production? `Read this first <http://flask.pocoo.org/docs/deploying/>`.

Links
`````

* `website <http://flask.pocoo.org/>`_
* `documentation <http://flask.pocoo.org/docs/>`_
* `development version
<http://github.com/pallets/flask/zipball/master#egg=Flask-dev>`_



1 change: 1 addition & 0 deletions lib/Flask-0.12.dist-info/INSTALLER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pip
33 changes: 33 additions & 0 deletions lib/Flask-0.12.dist-info/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Copyright (c) 2015 by Armin Ronacher and contributors. See AUTHORS
for more details.

Some rights reserved.

Redistribution and use in source and binary forms of the software as well
as documentation, with or without modification, are permitted provided
that the following conditions are met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.

* The names of the contributors may not be used to endorse or
promote products derived from this software without specific
prior written permission.

THIS SOFTWARE AND DOCUMENTATION IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE AND DOCUMENTATION, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
Loading