ScottyLabs / course-api

The new version of the Scheduling API, now with prerequisites, course descriptions, and more!
https://scottylabs.org/course-api/
MIT License
21 stars 14 forks source link

Improve error message for invalid semester #56

Closed edwdryer closed 6 years ago

edwdryer commented 6 years ago
screen shot 2018-04-22 at 7 01 24 pm
edwdryer commented 6 years ago

You get a "Check your internet connection" error, ideally it would tell you that the semester is invalid.

skrulcik commented 6 years ago

Thanks for the report and reproduction example!

Here is what the new error message should look like on the S18 input:

Python 3.6.0 (default, Dec 24 2016, 08:01:42)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cmu_course_api
>>> data = cmu_course_api.get_course_data('S18')
Requesting the HTML page from the network...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/private/tmp/Scott/course-api/cmu_course_api/aggregate.py", line 103, in get_course_data
    schedules = parse_schedules(semester)
  File "/private/tmp/Scott/course-api/cmu_course_api/parse_schedules.py", line 363, in parse_schedules
    page = get_page(quarter)
  File "/private/tmp/Scott/course-api/cmu_course_api/parse_schedules.py", line 65, in get_page
    (quarter, set(QUARTERS.keys())))
ValueError: quarter S18 is invalid, it must be one of {'M2', 'M1', 'F', 'S'}
>>> data = cmu_course_api.get_course_data('S')
Requesting the HTML page from the network...
Done.
Fixing errors on page...
Done.
Finding table rows on page...
Done.
Parsing rows...
Done.
running on 4 threads
Getting description for 48026...
Getting description for 48051...
Getting description for 48105...
Getting description for 48125...
Getting description for 48126...

The updated package is on PyPi as version 1.5.2