Skip to content

Commit

Permalink
Console now pauses even when exceptions are raised.
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardopietre committed Mar 15, 2021
1 parent 127f3da commit a7d259c
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions MoodleScraperChanges.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,24 +208,29 @@ def clean_extra(text):


if __name__ == "__main__":
configs = config_dict()

database = configs["database"]
courses_file = configs["courses_file"]
url = configs["url"]
try:
configs = config_dict()

courses = courses_from_file(courses_file)
database = configs["database"]
courses_file = configs["courses_file"]
url = configs["url"]

cookies = { "MoodleSession" : moodle_session() }
scraper = MoodleScraper(url=url, database_file=database, cookies=cookies)
courses = courses_from_file(courses_file)

log = scraper.scraper(courses)
cookies = { "MoodleSession" : moodle_session() }
scraper = MoodleScraper(url=url, database_file=database, cookies=cookies)

if scraper.found:
print(log)
pyperclip.copy(f"As seguintes alterações no Moodle foram encontradas:\n\n{log}")
else:
print("Nothing new found.")
pyperclip.copy("Nothing new found.")
log = scraper.scraper(courses)

input("\nPress ENTER to exit.")
if scraper.found:
print(log)
pyperclip.copy(f"As seguintes alterações no Moodle foram encontradas:\n\n{log}")
else:
print("Nothing new found.")
pyperclip.copy("Nothing new found.")
except Exception as error:
print("\nError:\n")
print(error)

input("\n\nPress ENTER to exit.")

0 comments on commit a7d259c

Please sign in to comment.