Skip to content

Commit

Permalink
Merge pull request #18 from madeddie/debug_log_login
Browse files Browse the repository at this point in the history
Add debug logs for the login method
  • Loading branch information
madeddie authored May 10, 2024
2 parents 2129d19 + 2c749d2 commit 7b61ddb
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions moocfi_cses.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def login(self) -> None:
if login_link:
login_url = urllib.parse.urljoin(res.url, login_link.get("href"))
else:
logging.debug(f"url: {res.url}, status: {res.status_code}\nhtml:\n{res.text}")
raise ValueError("Failed to find login url")

res = self.http_session.get(login_url, headers={"referer": res.url})
Expand All @@ -70,6 +71,7 @@ def login(self) -> None:
action = login_form.get("_action")
login_form.pop("_action")
else:
logging.debug(f"url: {res.url}, status: {res.status_code}\nhtml:\n{res.text}")
raise ValueError("Failed to find login form")

login_form["session[login]"] = self.username
Expand All @@ -82,6 +84,7 @@ def login(self) -> None:
)

if not self.is_logged_in:
logging.debug(f"url: {res.url}, status: {res.status_code}\nhtml:\n{res.text}")
raise ValueError("Login failed")

def http_request(
Expand Down

0 comments on commit 7b61ddb

Please sign in to comment.