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:
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 (
. , , )
.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
.
Downloads
directory with cd Downloads
gh repo clone J-J-B-J/get-sentral
to download the files.File > Clone Repository
J-J-B-J/get-sentral
into the URL or username/repository
box.Choose...
to choose where to save the repo.get-sentral
and the path to your Downloads
folder.cd Downloads/get-sentral
to enter the get-sentral directory.python3 setup.py sdist bdist_wheel
to install the package.
python
instead of python3
above.
cd dist
to enter the package directory.find . -type f -name "*.tar.gz"
to find the name of the package.pip3 install [FILE_NAME]
to install the package.
./SentralTimetable-0.2.tar.gz
, then run pip3 install SentralTimetable-0.2.tar.gz
pip
instead of pip3
above.
This page presumes you've installed the package and set the variables. See Installation and Variables.
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.
/examples
directorycd Downloads/get-sentral/examples
python3 Print\ Data.py
or python3 Set\ Journal.py
to run the program.
python
instead of python3
above.
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 ")
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:
USERNAME
- Your usernamePASSWORD
- Your passwordURL
- Your school's sentral url
https://
and ends with /portal/dashboard
DEBUG
- Weather or not to debug the programTIMEOUT
- The time to give the website to load before raising an errorYou 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.
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= )
Set environment variables using one of the following:
The environment variables are as follows:
"USER_NAME"
"PASSWORD"
"URL"
"DEBUG"
- Set to "True"
or "False"
"TIMEOUT"
- Set to an integer that has been formatted as a string, e.g. "15"
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")
This method uses a .json file to store a dictionary of credentials.
Sentral_Details.json
{}
"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
{
"USERNAME": "andy.griffiths1",
"PASSWORD": "TerryIsAnIdiot",
"URL": "https://yarravalleygrammar.sentral.com.au/portal/dashboard",
"DEBUG": false,
"TIMEOUT":
}
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.
Method | Changable from within program? | Stored permanently? | Hidden when committed? |
---|---|---|---|
Parameters | ✅ | ❌ | ❌ |
Environment Variables | ✅ | ✅1 | ✅2 |
.json file | ❌ | ✅ | ✅3 |
input() | ❌ | ❌ | ✅ |
.gitignore
.