What get-sentral does

Sample Sentral Dashboard

get-sentral is a package that allows you to fetch your timetable and other data from Sentral. Because it is pure Python, it can be run on microcontrollers running MicroPython or CircuitPython and that have Wi-Fi, including:


Using get_timetable()


get_timetable() returns a tree of Python objects, defined in objects.py. The root of the tree is a Sentral object.

Sentral {Custom}

This is simply a container for the other objects.

.days {list}

A list of SchoolDay objects.

SchoolDay {Custom}

A container for all Periods in a day

.date {Date}

The date of the day.

.day / .dy {int}

The day of the month in 1 .. 31, 1 .. 30, 1 .. 29 or 1 .. 28, depending on the month and weather it is a leap year.

.month / .mth {int}

The month in 1 .. 12.

.year / .yr {int}

The year in 0 .. ∞.

.hour / .hr {int}

The hour in 0 .. 23.

.minute / .mnt {int}

The minute in 0 .. 59.

.classes {list}

A list of Period and EmptyPeriod objects.

EmptyPeriod

An empty period, which is a period with no class.

.period {str}

The name/number of the period.

Period

A period with a class.

.period {str}

The name/number of the period.

.subject {str}

The subject name of the period.

.room {str}

The room of the period.

.teacher {str}

The teacher of the period.

.colour {Colour}

The background colour of the period.

.red / .r {int}

The red component of the colour.

.green / .g {int}

The green component of the colour.

.blue / .b {int}

The blue component of the colour.

.hex {str}

The hex code of the colour in the format #123ABC.

.rgb {tuple}

The RGB components of the colour in the format (0, 128, 255).

.notices {list}

A list of Notice objects.

Notice

A notice.

.title {str}

The title of the notice.

.content {str}

The content of the notice.

.teacher {str}

The teacher who sent the notice.

.date {Date}

The date of the notice.

.day / .dy {int}

The day of the month in 1 .. 31, 1 .. 30, 1 .. 29 or 1 .. 28, depending on the month and weather it is a leap year.

.month / .mth {int}

The month in 1 .. 12.

.year / .yr {int}

The year in 0 .. ∞.

.hour / .hr {int}

The hour in 0 .. 23.

.minute / .mnt {int}

The minute in 0 .. 59.

.events {list}

A list of Event objects.

Event

An event.

.title {str}

The title of the event.

.type_ {str}

The type of event. Is either "event" or "assessment".

.teacher {str}

The teacher who sent the event.

.date {Date}

The date of the event.

.day / .dy {int}

The day of the month in 1 .. 31, 1 .. 30, 1 .. 29 or 1 .. 28, depending on the month and weather it is a leap year.

.month / .mth {int}

The month in 1 .. 12.

.year / .yr {int}

The year in 0 .. ∞.

.hour / .hr {int}

The hour in 0 .. 23.

.minute / .mnt {int}

The minute in 0 .. 59.

.user {User}

A class to hold the details of the user who is logged in.

.name {str}

The name of the user.

.school {str}

The school of the user.

.number {int}

The Student ID of the user. As seen on your library card.

.barcode {str}

The barcode of the user. As seen on your library card. This is a C39 barcode generated by the TextBarcodeGenerator python library, also by J-J-B-J.

.journal {str}

The user's daily journal entry for today.

.reports {list[Report]}

The user's reports.

Report

A report file.

.name {str}

The year of the report. May also include other info depending on your school.

.url {str}

The URL at wwhich you can access the report.

.date {Date}

The date and time of the report release.

.day / .dy {int}

The day of the month in 1 .. 31, 1 .. 30, 1 .. 29 or 1 .. 28, depending on the month and weather it is a leap year.

.month / .mth {int}

The month in 1 .. 12.

.year / .yr {int}

The year in 0 .. ∞.

.hour / .hr {int}

The hour in 0 .. 23.

.minute / .mnt {int}

The minute in 0 .. 59.



Installation

Download

Github
  1. Download the latest source code.
  2. Unzip the file.
Github CLI
N.B. Make sure you have the GitHub CLI installed.
  1. Open a new terminal window/tab.
  2. Change into the Downloads directory with cd Downloads
  3. Run gh repo clone J-J-B-J/get-sentral to download the files.
Github Desktop
N.B. Make sure you have the GitHub Desktop installed.
  1. Open GitHub Desktop.
  2. In the menu bar, click on File > Clone Repository
  3. Click on the URL tab.
  4. Enter J-J-B-J/get-sentral into the URL or username/repository box.
  5. Click Choose... to choose where to save the repo.
  6. Set the clone name to get-sentral and the path to your Downloads folder.
  7. Click select.
  8. Click clone.

Build & Install

N.B. If you plan to use this as a library, then do this step. If you plan to use it as a standalone program or on a micropython device, then skip this step.
  1. Open a new terminal window/tab.
  2. Run cd Downloads/get-sentral to enter the get-sentral directory.
  3. Run python3 setup.py sdist bdist_wheel to install the package.
    N.B. If you use Python 2, use python instead of python3 above.
  4. Run cd dist to enter the package directory.
  5. Run find . -type f -name "*.tar.gz" to find the name of the package.
  6. Run pip3 install [FILE_NAME] to install the package.
    N.B. FILE_NAME should be the result of the previous step's command. So, if you got ./SentralTimetable-0.2.tar.gz, then run pip3 install SentralTimetable-0.2.tar.gz
    N.B. If you use Python 2, use pip instead of pip3 above.

Usage

This page presumes you've installed the package and set the variables. See Installation and Variables.

Standalone

This mode makes the program get your timetable and print out all the details, neatly formatted. This method is NOT RECOMMENDED if you plan to use this program as a library or in a project. Really the only time you should be using this mode is for testing.

Code editor
  1. Open the get-sentral directory in your favourite code editor, like PyCharm.
    N.B. If you use a JetBrains product, the project is already set up for you.
  2. Run one of the files in the /examples directory
Terminal
  1. Open a new terminal tab/window.
  2. Run cd Downloads/get-sentral/examples
  3. Run python3 Print\ Data.py or python3 Set\ Journal.py to run the program.
    N.B. If you use Python 2, use python instead of python3 above.

In an external Python program

To use this mode, use:

import SentralTimetable
SentralTimetable.get_timetable()

Using get_timetable() returns the data as a Sentral() object. See the top of this page for details on this object, or see objects.py.

You can also use the following code to set the daily journal:

import SentralTimetable
SentralTimetable.set_journal("Hello! this is my daily journal entry for   ")


Variables

This page presumes you've installed the package. See Installation.

The get-sentral program requires you to set some variables in order to get your timetable.

These include:

You can set all of these variables in a number of different ways, or you can mix and match. Please note that for some configurations of the program you may want to not use some settings. See the 'Advantages & Disadvantages' section at the end to compare the mathods.

Parameters

This is the simplest way of setting the variables. Simply pass them into the function, like so:

SentralTimetable.get_timetable(usr="andy.griffiths1", pwd="TerryIsAnIdiot", url="https://yarravalleygrammar.sentral.com.au/portal/dashboard", debug=False, timeout=5)

Environment Variables

Set environment variables using one of the following:

The environment variables are as follows:

For example, use the following code before calling get_timetable():

os.putenv("USER_NAME", "andy.griffiths1")
os.putenv("PASSWORD", "TerryIsAnIdiot")
os.putenv("URL", "https://yarravalleygrammar.sentral.com.au/portal/dashboard")
os.putenv("DEBUG", "False")
os.putenv("TIMEOUT", "15")

.json file

This method uses a .json file to store a dictionary of credentials.

  1. Create a new file in the project directory called Sentral_Details.json
  2. Create a ditionary in the file using {}
  3. Fill the dictionary with the following keys and values:
    • "USERNAME" - Your school username
    • "PASSWORD" - Your school password
    • "URL" - Your school's sentral url
    • "DEBUG" - Weather or not to debug the program - set to true or false
    • "TIMEOUT" - Time to give the page to load before raising an error - set to an integer such as 15
    For example, set the contents of the .json file to:

    {
        "USERNAME": "andy.griffiths1",
        "PASSWORD": "TerryIsAnIdiot",
        "URL": "https://yarravalleygrammar.sentral.com.au/portal/dashboard",
        "DEBUG": false,
        "TIMEOUT": 15
    }

input()

If you do not enter the credentials in one of the above methods, the program will automatically ask for the credentials using the input() function.


Advantages & Disadvantages

Method Changable from within program? Stored permanently? Hidden when committed?
Parameters
Environment Variables 1 2
.json file 3
input()

1: Only when using an environment or project file or similar.
2: Only when set from outside the program.
3: Only when added to the .gitignore.