Clients#
Pronotepy currently implements three separate clients:
Client
- for student usersParentClient
- for parent users (contains additional methods for switching between kids:ParentClient.set_child()
)VieScolaireClient
- for vie scolaire users (has access to completely different resources)
All of the clients extend a ClientBase
class, which itself does not do
much, and mainly just provides login and raw communication between pronotepy and the
PRONOTE server.
When you make a new client instance it automatically logs in. The login process can raise a
CryptoError
exception, which usually means that the password was incorrect.
You can check if the client is logged in using the ClientBase.logged_in
attribute.
Example of client initialisation:
import pronotepy
try:
client = pronotepy.Client(
'https://demo.index-education.net/pronote/eleve.html',
username='demonstration',
password='pronotevs',
)
print(client.start_day)
except pronotepy.CryptoError:
exit(1) # the client has failed to log in
if not client.logged_in:
exit(1) # the client has failed to log in
Note
See ent for an example with an ENT / CAS.
- class pronotepy.ClientBase(pronote_url: str, username: str = '', password: str = '', ent: Optional[ENTFunction] = None, mode: str = 'normal', uuid: str = '')#
Base for every PRONOTE client. Provides login.
- Parameters:
- start_day#
The first day of the school year
- Type:
- info#
Provides information about the current client. Name etc…
- Type:
- last_connection#
- Type:
- keep_alive() _KeepAlive #
Returns a context manager to keep the connection alive. When inside the context manager, it sends a “Presence” packet to the server after 5 minutes of inactivity from another thread.
- property periods: List[Period]#
Get all of the periods of the year.
- Returns:
All the periods of the year
- Return type:
List[Period]
- post(function_name: str, onglet: Optional[int] = None, data: Optional[dict] = None) dict #
Preforms a raw post to the PRONOTE server. Adds signature, then passes it to _Communication.post
- classmethod qrcode_login(qr_code: dict, pin: str, uuid: str) T #
Login with QR code
The created client instance will have its username and password attributes set to the credentials for the next login using
token_login()
.
- refresh() None #
Now this is the true jank part of this program. It refreshes the connection if something went wrong. This is the classical procedure if something is broken.
- request_qr_code_data(pin: str) dict #
Requests data for a new login QR code. This data can be then used with
qrcode_login()
.- Parameters:
pin (str) – Four digit pin to use for the QR code
- session_check() bool #
Checks if the session has expired and refreshes it if it had (returns bool signifying if it was expired)
- classmethod token_login(pronote_url: str, username: str, password: str, uuid: str) T #
Login with a password token. Used for logins after
qrcode_login()
.The created client instance will have its username and password attributes set to the credentials for the next login using
token_login()
.
- class pronotepy.Client(pronote_url: str, username: str = '', password: str = '', ent: Optional[Callable] = None, mode: str = 'normal', uuid: str = '')#
Bases:
ClientBase
A PRONOTE client.
- Parameters:
- discussions(only_unread: bool = False) List[Discussion] #
Gets all the discussions in the discussions tab
- generate_timetable_pdf(day: Optional[date] = None, portrait: bool = False, overflow: int = 0, font_size: Tuple[int, int] = (8, 3)) str #
Generate a PDF timetable.
- Parameters:
day (Optional[datetime.date]) – the day for which to create the timetable, the whole week is always generated
portrait (bool) – switches the timetable to portrait mode
overflow (int) –
Controls overflow / formatting of lesson names.
0
: no overflow1
: overflow to the same page, long names printed on the bottom2
: overflow to a separate page
font_size (Tuple[int, int]) – font size restrictions, first element is the preferred font size, and second is the minimum
- get_recipients() List[Recipient] #
Get recipients for new discussion
- Returns:
list of available recipients
- Return type:
List[Recipient]
- get_teaching_staff() List[TeachingStaff] #
Get the teacher list
- Returns:
list of teachers and other staff
- Return type:
List[TeachingStaff]
- homework(date_from: date, date_to: Optional[date] = None) List[Homework] #
Get homework between two given points.
- Parameters:
date_from (datetime) – The first date
date_to (datetime) – The second date. If unspecified to the end of the year.
- Returns:
Homework between two given points
- Return type:
List[Homework]
- information_and_surveys(date_from: Optional[datetime] = None, date_to: Optional[datetime] = None, only_unread: bool = False) List[Information] #
Gets all the information and surveys in the information and surveys tab.
- Parameters:
only_unread (bool) – Return only unread information
date_from (datetime.datetime) – Since datetime (included)
date_to (datetime.datetime) – Until datetime (excluded)
- lessons(date_from: Union[date, datetime], date_to: Optional[Union[date, datetime]] = None) List[Lesson] #
Gets all lessons in a given timespan.
- Parameters:
date_from (Union[datetime.date, datetime.datetime]) – first date
date_to (Union[datetime.date, datetime.datetime]) – second date, if None, then to the end of day_from
- Returns:
List of lessons
- Return type:
List[Lesson]
Get menus between two given points.
- Parameters:
date_from (datetime) – The first date
date_to (datetime) – The second date. If unspecified to the end of the year.
- Returns:
Menu between two given points
- Return type:
List[Menu]
- class pronotepy.ParentClient(pronote_url: str, username: str = '', password: str = '', ent: Optional[Callable] = None, mode: str = 'normal', uuid: str = '')#
Bases:
Client
A parent PRONOTE client.
- Parameters:
- children#
List of sub-clients representing all the children connected to the main parent account.
- Type:
List[ClientInfo]
- post(function_name: str, onglet: Optional[int] = None, data: Optional[dict] = None) dict #
Preforms a raw post to the PRONOTE server.
Adds signature, then passes it to _Communication.post
- set_child(child: Union[str, ClientInfo]) None #
Select a child
- Parameters:
child (Union[str, ClientInfo]) – Name or ClientInfo of a child.
- class pronotepy.VieScolaireClient(pronote_url: str, username: str = '', password: str = '', ent: Optional[Callable] = None, mode: str = 'normal', uuid: str = '')#
Bases:
ClientBase
A PRONOTE client for Vie Scolaire accounts.
- Parameters:
- classes#
List of all classes this account has access to.
- Type:
List[StudentClass]