-
Notifications
You must be signed in to change notification settings - Fork 4
Getting Started
You'll need to have Python version 2.7 or 3 along with the corresponding version of the Pip package manager installed on your system.
You can install the python requests module before you do anything else. This is easy to do with pip
:
For Python 2.7: pip install requests
For Python 3: pip3 install requests
If your $PYTHONPATH isn't working for whatever reason, you can have pip install to the current directory by appending --target=./
to the commands above.
Before you can use PyEdsby, you need to first import the class.
For Python 2.7, you'll first need to create an empty file named __init__.py
in the same directory as edsby.py and your main python file. Once you've done that, you can import PyEdsby like so:
from edsby import Edsby
You can also place the class file in a subdirectory. Say, for example, you keep all your imports in a subdirectory named lib/
:
from lib.edsby import Edsby
In Python 3 (which PyEdsby should be able to run under), you can disregard the above. Importing the class is a simple matter of:
from .edsby import Edsby
The final option you have available is to simply paste the class definition inside of your python file. It's much messier, but it would work if you needed it for your specific use case.
Instantiating and using PyEdsby is very simple. Here's a short example:
# PyEdsby requires the python-requests and JSON modules.
# This import is also at the top of the PyEdsby class file.
import requests, json
# You'll need to import the PyEdsby class to actually use it, silly:)
from edsby import Edsby
"""
Create an instance of PyEdsby
You'll need to provide the hostname of your Edsby instance here (e.g. sdhc.edsby.com)
You'll also have to supply your username and password.
Note: Yes, this means you have to include your credentials in cleartext. Edsby has no kind of credential
provisioning or IAM available, so we have to open a session in the same way that the browser does, by POSTing
your credentials to the login endpoint.
"""
edsby = Edsby(host='your_host.edsby.com', username='your_username', password='your_password')
# To start off with something easy, let's print all of your class averages.
print json.dumps( edsby.getAllClassAverages() )
For a more in-depth example, check out example.py, or the other examples available.