Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Python Module for the CHALLONGE API

License

NotificationsYou must be signed in to change notification settings

ZEDGR/pychallonge

Repository files navigation

image

Pychallonge provides python bindings for theCHALLONGE!API.The pychallonge module was created byRuss Amos

pychal

Pychal was a fork of pychallonge. The pychal module has been merged intothe pychallonge. If you are still using pychal you have to migrate topychallonge because it is not longer maintained

Requirements

  • iso8601
  • tzlocal
  • pytz
  • requests

Python version support

  • 2.7
  • 3.4+

Installation

For the stable version

pip install pychallonge

For latest development

pip install -e git+http://github.com/ZEDGR/pychallonge#egg=pychallonge

Usage

importchallonge# Tell pychallonge about your [CHALLONGE! API credentials](http://api.challonge.com/v1).challonge.set_credentials("your_challonge_username","your_api_key")# Retrieve a tournament by its id (or its url).tournament=challonge.tournaments.show(3272)# Tournaments, matches, and participants are all represented as normal Python dicts.print(tournament["id"])# 3272print(tournament["name"])# My Awesome Tournamentprint(tournament["started_at"])# None# Retrieve the participants for a given tournament.participants=challonge.participants.index(tournament["id"])print(len(participants))# 13# Start the tournament and retrieve the updated information to see the effects# of the change.challonge.tournaments.start(tournament["id"])tournament=challonge.tournaments.show(tournament["id"])print(tournament["started_at"])# 2011-07-31 16:16:02-04:00

Seechallonge.com for full APIdocumentation.

API Issues

The Challonge API has some issues with the attachments endpoints. Thecreate andupdate endpoints are not working correctly. When you tryto upload an attachment with asset(file) the API returns 500 internalserver error. The same happens with asset + description. This issuehas been reported to Challonge.

Another issue is the check in process has strange behaviour.When you undo check in a participant the field 'checked_in' remains Truebut in the website the participant is correctly not checked in.That's why the module does not have any tests on this.

Fixed by pychallonge: In the datetime fields the api returns randomtimezone offsets, pychallonge convert those to your machine's localtime. Also you can set any timezone you want withset_timezone function.

Running the unit tests

Pychallonge comes with a set of unit tests. The tests are notcomprehensive, but do utilize each method and verify basicfunctionality.

In order to test behavior of the python bindings, API calls must be madeto CHALLONGE!, which requires a username and api key. To run the testswith your credentials, setCHALLONGE_USER andCHALLONGE_KEYappropriately in your environment.

$ git clone http://github.com/ZEDGR/pychalllonge pychallonge$ CHALLONGE_USER=my_user CHALLONGE_KEY=my_api_key python pychal/tests.py...............................----------------------------------------------------------------------Ran 31 tests in 98.176sOK

Note that several tournaments are created, published, started, andcompleted over the course of the unit tests. These should be cleaned upby the end, but if any of the tests fail they may not be cleaned up. Aslong as the basic functions work, you can clean up errant tournaments asfollows.

importchallongechallonge.set_credentials("my_user","my_api_key")fortinchallonge.tournaments.index():ift["name"].startswith("pychal"):challonge.tournaments.destroy(t["id"])

[8]ページ先頭

©2009-2025 Movatter.jp