Skip to content

Commit f57dcb5

Browse files
authored
Merge pull request #98 from Zohair-coder/sso
More bandaid
2 parents 3cdf085 + c16d281 commit f57dcb5

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ profile_output.pstat
99
callgrind.out.profile
1010
.venv
1111
test.py
12+
test_bruteforce.py
1213
test.txt

.vscode/settings.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"python.testing.pytestArgs": [
3+
"src"
4+
],
5+
"python.testing.unittestEnabled": false,
6+
"python.testing.pytestEnabled": true
7+
}

src/scrape.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ def scrape(
1919

2020
is_logged_into_drexel_connect = False
2121
failiure_count = 0
22+
reset_period = 1 # seconds
2223
while not is_logged_into_drexel_connect:
24+
reset_period *= 2
2325
try:
2426
session = login.login_with_drexel_connect(session)
2527
if "shib_idp_session" in session.cookies:
@@ -28,12 +30,17 @@ def scrape(
2830
except Exception:
2931
print("Error logging in to Drexel Connect: ")
3032
print(traceback.format_exc())
31-
print("Trying again...")
33+
print(f"Trying again in {reset_period} seconds...")
3234

3335
failiure_count += 1
34-
if failiure_count > 5:
35-
raise Exception("Failed to log in to Drexel Connect after 5 attempts")
36-
time.sleep(1)
36+
if failiure_count > 8:
37+
raise Exception(
38+
"Failed to log in to Drexel Connect after {} attempts".format(
39+
failiure_count
40+
)
41+
)
42+
43+
time.sleep(reset_period)
3744

3845
data: dict[str, dict[str, Any]] = {}
3946

0 commit comments

Comments
 (0)