Skip to content

Commit

Permalink
tons of update, v1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
LeeTeng2001 committed Nov 29, 2022
1 parent 2e60b9a commit 8400370
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
Empty file added README.md
Empty file.
2 changes: 0 additions & 2 deletions Update.txt

This file was deleted.

17 changes: 15 additions & 2 deletions CanvasAPI.py → canvas_api.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
from canvasapi import Canvas, exceptions
from typing import Callable
import os


def download_canvas(secret_token, course_num, save_to_path, print_output, sync_on: bool, canvas_struct: bool):
def download_canvas(secret_token: str, course_num: int, save_to_path: str,
print_output: Callable[[str], None], sync_on: bool, canvas_struct: bool) -> None:
"""
Download files from canvas
Args:
secret_token: token to access canvas api
course_num: course number to download from
save_to_path: which folder to save to
print_output: output function (eg: terminal or qt output)
sync_on:
canvas_struct:
"""
try:
canvas = Canvas("https://oc.sjtu.edu.cn/", secret_token) # Init
course = canvas.get_course(course_num)
except exceptions.InvalidAccessToken:
print_output("FAILED. Check your secret token!")
print_output("下载失败,请检查你的口令牌")
return
except exceptions.ResourceDoesNotExist:
print_output("FAILED. Check your course number!")
Expand Down
Empty file added utils.py
Empty file.

0 comments on commit 8400370

Please sign in to comment.