complete dualis async

This commit is contained in:
2024-04-09 00:16:59 +02:00
parent 211ec18887
commit 490ee7f02f
5 changed files with 114 additions and 63 deletions

View File

@ -39,6 +39,7 @@ def celery_requests(self):
return response, s
# noinspection DuplicatedCode
async def checkUser_celery():
req = celery_requests.apply_async()
response = req[0]
@ -55,6 +56,7 @@ async def checkUser_celery():
return token, cookie
# noinspection DuplicatedCode
def checkUser_normal():
"""
Erhält von Dualis den Token und Cookie für User.
@ -81,6 +83,7 @@ def checkUser_normal():
return token, cookie
# noinspection DuplicatedCode
async def checkUser_async():
"""
Erhält von Dualis den Token und Cookie für User.
@ -88,6 +91,7 @@ async def checkUser_async():
:param password:
:return (Token, Session):
"""
# noinspection DuplicatedCode
async with httpx.AsyncClient() as s:
content = (f'usrname={fmail}&pass={fpw}&ARGUMENTS=clino%2Cusrname%2Cpass%2Cmenuno%2Cmenu_type%2Cbrowser'
f'%2Cplatform&APPNAME=CampusNet&PRGNAME=LOGINCHECK')
@ -104,6 +108,7 @@ async def checkUser_async():
return token, cookie
# noinspection DuplicatedCode
def getSem_normal(token: int, cookie: str):
"""
Liefert die Liste aller auf Dualis verfügbaren Semester.
@ -127,6 +132,7 @@ def getSem_normal(token: int, cookie: str):
return optlist
# noinspection DuplicatedCode
async def getSem_async(token, cookie):
"""
Liefert die Liste aller auf Dualis verfügbaren Semester.
@ -155,6 +161,7 @@ async def getSem_celery(token, cookie):
pass
# noinspection DuplicatedCode
async def getResults_async(token, cookie, resl):
headers["Cookie"] = "cnsc=" + cookie
async with httpx.AsyncClient() as s:
@ -185,7 +192,7 @@ async def getResults_async(token, cookie, resl):
i[e] = extrakurse[i[e]]
return vorlist[:-1]
# noinspection DuplicatedCode
async def getPruefung_async(s, url):
response = await s.get("https://dualis.dhbw.de" + url, headers=headers)
html = BeautifulSoup(response.content.decode("utf-8"), 'lxml')
@ -252,14 +259,14 @@ async def tests():
end = time.perf_counter()
normaltimeloop = end - start
fetchDUALIS.logOut(n[0], n[1])
await fetchDUALIS.logOut(n[0], n[1])
start = time.perf_counter()
a = await async_normal()
end = time.perf_counter()
asynctimeloop = end - start
fetchDUALIS.logOut(a[0], a[1])
await fetchDUALIS.logOut(a[0], a[1])
if a[2] == n[2]:
normaltime += normaltimeloop
asynctime += asynctimeloop