Skip to content

Commit

Permalink
Fix pronote.py
Browse files Browse the repository at this point in the history
Evaluations: added fields
fix> updated
Hanging logins
fix> added timeout section
  • Loading branch information
vingerha committed Oct 26, 2022
1 parent e38f518 commit d13e31e
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions app/pronote.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,24 @@
import math
# import ent // removed with pronotepy v2.4.0 covering more CAS
from pronotepy.ent import *
import requests
from requests.adapters import TimeoutSauce

#Hardcoded (to be improved)
lessonDays=15
homeworkDays=15


class MyTimeout(TimeoutSauce):
def __init__(self, *args, **kwargs):
if kwargs['connect'] is None:
kwargs['connect'] = 5 # change here for different connection timeout
if kwargs['read'] is None:
kwargs['read'] = 5 # change here for different read timeout
super(MyTimeout, self).__init__(*args, **kwargs)

requests.adapters.TimeoutSauce = MyTimeout

class Pronote:
def __init__(self):

Expand Down Expand Up @@ -186,7 +199,9 @@ def getData(self,prefix_url,username,password,cas,GradeAverage,parent,fullname):
'evalDate': eval.date.strftime("%Y/%m/%d"),
'acqId': acq.order,
'acqName': acq.name,
'acqAbbreviation': acq.abbreviation,
'acqLevel': acq.level,
'acqDomain': acq.domain,
'acqCoefficient': acq.coefficient,
})
evalList = jsondata
Expand All @@ -198,6 +213,7 @@ def getData(self,prefix_url,username,password,cas,GradeAverage,parent,fullname):
logging.error("Evaluations list is empty")
else:
logging.info("Skipping Averages---------------------------------------------------")


#absences
logging.info("Collecting Absences---------------------------------------------------")
Expand Down Expand Up @@ -298,8 +314,7 @@ def getData(self,prefix_url,username,password,cas,GradeAverage,parent,fullname):

else:
logging.error("Homework list is empty")



def addPeriod(self,period):
self.periodList.append(period)

Expand Down Expand Up @@ -440,9 +455,11 @@ def __init__(self, studentname, eval):
self.evalDate = None
self.acquisitionId = None
self.acquisitionName = None
self.acquisitionAbbreviation = None
self.acquisitionLevel = None
self.acquisitionDomain = None
self.acquisitionCoefficient = None

self.pid = eval["pid"]
self.periodName = eval["periodName"]
self.periodStart = eval["periodStart"]
Expand All @@ -458,7 +475,9 @@ def __init__(self, studentname, eval):
self.evalDate = eval["evalDate"]
self.acquisitionId = eval["acqId"]
self.acquisitionName = eval["acqName"]
self.acquisitionAbbreviation = eval["acqAbbreviation"]
self.acquisitionLevel = eval["acqLevel"]
self.acquisitionDomain = eval["acqDomain"]
self.acquisitionCoefficient = eval["acqCoefficient"]

# Store measure to database
Expand All @@ -467,10 +486,10 @@ def store(self,db):
dbTable = "evaluations"

if dbTable:
logging.debug("Store evaluations %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s",self.pid,self.periodName,self.periodStart,self.periodEnd,self.studentname,self.eid,self.evalName,self.evalDomain,self.evalTeacher,self.evalCoefficient,self.evalDescription,self.evalSubject,self.evalDate,self.acquisitionId,self.acquisitionName,self.acquisitionLevel,self.acquisitionCoefficient)
eval_query = f"INSERT OR REPLACE INTO evaluations VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
logging.debug("Store evaluations %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s",self.pid,self.periodName,self.periodStart,self.periodEnd,self.studentname,self.eid,self.evalName,self.evalDomain,self.evalTeacher,self.evalCoefficient,self.evalDescription,self.evalSubject,self.evalDate,self.acquisitionId,self.acquisitionName,self.acquisitionAbbreviation,self.acquisitionLevel,self.acquisitionDomain,self.acquisitionCoefficient)
eval_query = f"INSERT OR REPLACE INTO evaluations VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
db.cur.execute(eval_query, [self.pid,self.periodName,self.periodStart,self.periodEnd,self.studentname,self.eid,self.evalName,self.evalDomain,self.evalTeacher,\
self.evalCoefficient,self.evalDescription,self.evalSubject,self.evalDate,self.acquisitionId,self.acquisitionName,self.acquisitionLevel,self.acquisitionCoefficient])
self.evalCoefficient,self.evalDescription,self.evalSubject,self.evalDate,self.acquisitionId,self.acquisitionName,self.acquisitionAbbreviation,self.acquisitionLevel,self.acquisitionDomain,self.acquisitionCoefficient])

class Lesson:

Expand Down

0 comments on commit d13e31e

Please sign in to comment.