From 157b6966f2416d3283a9e854cc144a2caebceebe Mon Sep 17 00:00:00 2001 From: Anton Relin Date: Wed, 21 Oct 2020 12:03:23 -0600 Subject: [PATCH 1/2] Updated canvas_export python script to check for whether or not a given course has a course code, meaning that it is still accessible. This prevents the script from erroring out if a course is no longer accessible to the script. Added a requirements.txt to a bit more easily download the single dependenancy. --- canvas-export.py | 10 +++++++--- requirements.txt | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 requirements.txt diff --git a/canvas-export.py b/canvas-export.py index 9610b14..f65e6cb 100644 --- a/canvas-export.py +++ b/canvas-export.py @@ -157,10 +157,14 @@ def main(): if args.list: for course in all_courses: - print('%s\t%s' % (course['course_code'], course['name'])) + if('course_code' in course): + print('%s\t%s' % (course['course_code'], course['name'])) return - ids_to_code = {course['id']: course['course_code'] for course in all_courses} + ids_to_code = {} + for course in all_courses: + if 'name' in course: + ids_to_code[course['id']] = course['course_code'] courses_to_export = None @@ -189,4 +193,4 @@ def main(): print('Download complete') if __name__ == "__main__": - main() \ No newline at end of file + main() diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..989b995 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +requests==2.24.0 From 071fb4acd6ce2584872446959e53a298e4303002 Mon Sep 17 00:00:00 2001 From: Anton Relin Date: Wed, 21 Oct 2020 12:05:07 -0600 Subject: [PATCH 2/2] Updated README.md to include information about installing the required dependency. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 079de21..92516d0 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ A Python-based command-line utility to export a user's courses to their local filesystem. ## Dependencies -User must have Python 3 installed +User must have Python 3 installed and must have the package `requests` installed. `requests` can be installed via pip by running `pip install` in the root directory of this project. ## Usage This tool relies on two environmental variables: `CANVAS_ACCESS_TOKEN` and