Skip to content
Snippets Groups Projects
Commit 3c55e818 authored by Albin Heimerson's avatar Albin Heimerson
Browse files

print errors

parent 4d48ecb9
No related branches found
No related tags found
No related merge requests found
......@@ -17,17 +17,17 @@ CANVAS_COURSE_CODE = os.environ["CANVAS_COURSE_CODE"]
canvas = Canvas(API_URL, API_TOKEN)
course = canvas.get_course(CANVAS_COURSE_CODE)
# Check if folder exists, otherwise create it
base_folder = next(folder for folder in course.get_folders()
if folder.full_name == CANVAS_BASE_PATH)
pdf_folder = next((folder for folder in course.get_folders()
if folder.full_name == "/".join([CANVAS_BASE_PATH,
CANVAS_FOLDER_NAME])), None)
# Check if folder exists, otherwise create it
if pdf_folder is None:
base_folder = next(folder for folder in course.get_folders()
if folder.full_name == CANVAS_BASE_PATH)
pdf_folder = base_folder.create_folder(CANVAS_FOLDER_NAME)
# Recurse through all subfolder and upload pdfs to corresponding
folders = [(pdf_folder, tuple([""]))]
folders = [(pdf_folder, ())]
while len(folders) > 0:
folder, path = folders.pop()
ospath = os.path.join(GITLAB_FOLDER_NAME, *path)
......@@ -35,11 +35,12 @@ while len(folders) > 0:
for f in os.listdir(ospath):
print("Looking at {}".format(f))
gitlabpath = os.path.join(ospath, f)
canvaspath = "/".join(tuple([CANVAS_BASE_PATH, CANVAS_FOLDER_NAME, *path, f]))
canvaspath = "/".join([CANVAS_BASE_PATH, CANVAS_FOLDER_NAME, *path, f])
if os.path.isdir(gitlabpath):
nfolder = next((folder for folder in course.get_folders()
if folder.full_name == canvaspath), None)
print("{} is folder, found {} on canvas".format(gitlabpath, nfolder.full_name))
print("{} is folder, found {} on canvas".format(gitlabpath, nfolder))
if nfolder is None:
nfolder = folder.create_folder(f)
folders.append((nfolder, tuple([*path, f])))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment