ucfopen / canvasapi

Python API wrapper for Instructure's Canvas LMS. Easily manage courses, users, gradebooks, and more.
https://pypi.python.org/pypi/canvasapi
MIT License
560 stars 174 forks source link

Create folder fails without warning #415

Open AbeHandler opened 4 years ago

AbeHandler commented 4 years ago

Describe the bug

I am using the API to create folders. Calls to course.create_folder intermittently fail, without errors

To Reproduce

Steps to reproduce the behavior, starting from a course with no files or folders, do the following

    course = canvas.get_course(my_course_id)
    for week in range(1, 17):
        print("[*] {}".format(week))
        parent = "/week{}/".format(week)
        course.create_folder(name='quiz_files', parent_folder_path=parent)
        course.create_folder(name='assignment_files', parent_folder_path=parent)
        course.create_folder(name='other_files', parent_folder_path=parent)

Expected behavior

I would expect to see 16 folders called week1, week2 ... week17, each with 3 subfolders called quiz_files, assignment_files and other_files. If I click each week1 folder etc in the web interface only some weekN folders have all of the 3 subdirectories. If the directories do not exist, I would expect to get an error message.

Environment information

bennettscience commented 4 years ago

The Canvas endpoint returns a folder when it is successful. Have you tried adding any flow control checks that each folder was successfully created before trying to add a subfolder?