perslev / canvassync Goto Github PK
View Code? Open in Web Editor NEWSynchronise modules, assignments and files located on a Canvas by Instructure web server to your local computer.
License: MIT License
Synchronise modules, assignments and files located on a Canvas by Instructure web server to your local computer.
License: MIT License
line 174 and 176 in the file ("~\Anaconda3\Lib\site-packages\CanvasSync\Settings\user_prompter.py") seems to be not working on python 3.6, it appears to have the same problem later on.
for line 174, suggest to amend as follow.
courses = [course[u'name']for course in courses for name in course if name ==u'name']
The terminal windows exits itself after pressing enter during the initial set up on windows
First of all: CanvasSync IS REALLY GREAT!!! I love it!
I set up CanvasSync on a folder that syncs with my OneDrive Cloud.
But OneDrive does not allow folder and file names that begin or end with a space, begin with two full stops, end with one full stop, or contain any of these characters: \ / : * ? " < > |
However, some profs made folders ending with a space. Therefore, could you please add a type of file-/folder-name-filter that automatically replaces not allowed characters?
CanvasSync - Current settings
-----------------------------
Standard settings
[*] Sync path: $HOME/Documents/canvas
[*] Canvas domain: https://csufullerton.instructure.com
[*] Authentication token: $TOKEN
[*] Courses to be synced: $CLASSES
Advanced settings
[*] Sync module items: Files & HTML pages & External URLs
[*] Sync assignments: True
[*] Download linked files: True
[*] Avoid item duplicates: True
These settings will be saved
Please enter a password to encrypt the settings file:
Password:
Traceback (most recent call last):
File "/usr/lib/python-exec/python3.9/canvas", line 33, in <module>
sys.exit(load_entry_point('CanvasSync==0.2.4', 'console_scripts', 'canvas')())
File "/usr/lib/python3.9/site-packages/bin/canvas.py", line 187, in entry
run_canvas_sync()
File "/usr/lib/python3.9/site-packages/bin/canvas.py", line 132, in run_canvas_sync
main_menu(settings)
File "/usr/lib/python3.9/site-packages/bin/canvas.py", line 149, in main_menu
settings.show(quit=False)
File "/usr/lib/python3.9/site-packages/CanvasSync/settings/settings.py", line 280, in show
valid_token = self.load_settings("")
File "/usr/lib/python3.9/site-packages/CanvasSync/settings/settings.py", line 111, in load_settings
self.set_settings()
File "/usr/lib/python3.9/site-packages/CanvasSync/settings/settings.py", line 157, in set_settings
self.write_settings()
File "/usr/lib/python3.9/site-packages/CanvasSync/settings/settings.py", line 214, in write_settings
out_file.write(encrypt(settings))
File "/usr/lib/python3.9/site-packages/CanvasSync/settings/cryptography.py", line 45, in encrypt
hashed_password = bcrypt.hashpw(getpass.getpass(), bcrypt.gensalt())
File "/usr/lib/python3.9/site-packages/bcrypt/__init__.py", line 80, in hashpw
raise TypeError("Unicode-objects must be encoded before hashing")
TypeError: Unicode-objects must be encoded before hashing
Please fix this settings encrypting password issue
I'm not sure what the problem is, it's from the latest version.
Traceback (most recent call last):
File "C:\Python37\Scripts\canvas-script.py", line 11, in <module>
load_entry_point('CanvasSync==0.2.4', 'console_scripts', 'canvas')()
File "c:\python37\lib\site-packages\bin\canvas.py", line 187, in entry
run_canvas_sync()
File "c:\python37\lib\site-packages\bin\canvas.py", line 132, in run_canvas_sync
main_menu(settings)
File "c:\python37\lib\site-packages\bin\canvas.py", line 150, in main_menu
main_menu(settings)
File "c:\python37\lib\site-packages\bin\canvas.py", line 147, in main_menu
main_menu(settings)
File "c:\python37\lib\site-packages\bin\canvas.py", line 154, in main_menu
do_sync(settings, "")
File "c:\python37\lib\site-packages\bin\canvas.py", line 170, in do_sync
synchronizer.sync()
File "c:\python37\lib\site-packages\CanvasSync\entities\synchronizer.py", line 126, in sync
course.sync()
File "c:\python37\lib\site-packages\CanvasSync\entities\course.py", line 163, in sync
child.sync()
File "c:\python37\lib\site-packages\CanvasSync\entities\module.py", line 169, in sync
child.sync()
File "c:\python37\lib\site-packages\CanvasSync\entities\page.py", line 172, in sync
was_downloaded = self.download()
File "c:\python37\lib\site-packages\CanvasSync\entities\page.py", line 144, in download
out_file.write(body)
TypeError: write() argument must be str, not None
The site admin for my institution has set up the entire domain to use the native language here (swedish). This not only translates the ui, but also the api error messages.
so the validate_domain helper function fails due to the message comparason being in another language.
{"status":"unauthenticated","errors":[{"message":"user authorization required"}]}
turns into
{"status":"inte autentiserad","errors":[{"message":"auktorisering av användare krävs"}]}
How about checking against response.status_code == 401
instead?
One of the dependency PyCrypto (https://pypi.python.org/pypi/pycrypto) is dead, and should switch to pycryptodome, which is mostly compatible.
In "Other Files", it seems that CanvasSync is only syncing the first ten files per subfolder...
Traceback (most recent call last):
File "/usr/local/bin/canvas", line 8, in
sys.exit(entry())
File "/Library/Python/2.7/site-packages/bin/canvas.py", line 187, in entry
run_canvas_sync()
File "/Library/Python/2.7/site-packages/bin/canvas.py", line 132, in run_canvas_sync
main_menu(settings)
File "/Library/Python/2.7/site-packages/bin/canvas.py", line 154, in main_menu
do_sync(settings, "")
File "/Library/Python/2.7/site-packages/bin/canvas.py", line 170, in do_sync
synchronizer.sync()
File "/Library/Python/2.7/site-packages/CanvasSync/entities/synchronizer.py", line 126, in sync
course.sync()
File "/Library/Python/2.7/site-packages/CanvasSync/entities/course.py", line 163, in sync
child.sync()
File "/Library/Python/2.7/site-packages/CanvasSync/entities/folder.py", line 141, in sync
item.sync()
File "/Library/Python/2.7/site-packages/CanvasSync/entities/folder.py", line 141, in sync
item.sync()
File "/Library/Python/2.7/site-packages/CanvasSync/entities/folder.py", line 141, in sync
item.sync()
File "/Library/Python/2.7/site-packages/CanvasSync/entities/folder.py", line 141, in sync
item.sync()
File "/Library/Python/2.7/site-packages/CanvasSync/entities/file.py", line 117, in sync
was_downloaded = self.download()
File "/Library/Python/2.7/site-packages/CanvasSync/entities/file.py", line 72, in download
self.print_status(u"DOWNLOADING", color=u"blue")
File "/Library/Python/2.7/site-packages/CanvasSync/entities/file.py", line 100, in print_status
print(ANSI.format(u"[%s]" % status, formatting=color) + str(self)[len(status) + 2:])
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 75: ordinal not in range(128)
Whenever I try to synchronize I get this error. I have tried on both Windows and Linux. I am using default settings.
[SYNCED] | Course: 23-24Y_SA-HIST-AMER-US.1
Traceback (most recent call last):
File "/home/kdj/.local/bin/canvas", line 8, in <module>
sys.exit(entry())
File "/home/kdj/.local/lib/python3.8/site-packages/bin/canvas.py", line 187, in entry
run_canvas_sync()
File "/home/kdj/.local/lib/python3.8/site-packages/bin/canvas.py", line 132, in run_canvas_sync
main_menu(settings)
File "/home/kdj/.local/lib/python3.8/site-packages/bin/canvas.py", line 147, in main_menu
main_menu(settings)
File "/home/kdj/.local/lib/python3.8/site-packages/bin/canvas.py", line 154, in main_menu
do_sync(settings, "")
File "/home/kdj/.local/lib/python3.8/site-packages/bin/canvas.py", line 170, in do_sync
synchronizer.sync()
File "/home/kdj/.local/lib/python3.8/site-packages/CanvasSync/entities/synchronizer.py", line 126, in sync
course.sync()
File "/home/kdj/.local/lib/python3.8/site-packages/CanvasSync/entities/course.py", line 160, in sync
self.add_files_folder()
File "/home/kdj/.local/lib/python3.8/site-packages/CanvasSync/entities/course.py", line 116, in add_files_folder
main_folder[u"name"] = u"Other Files"
TypeError: 'NoneType' object does not support item assignment
As a teacher it could be nice if there was a way to sync with a local folder, such that my changes gets automatically updated.
I just recently noticed that if a file is updated in the Canvas site and the name does not change, CanvasSync will not download the new version. Is there a way for the program to update these documents?
Thanks!!
When running CanvasSync, some users get the following error:
Traceback (most recent call last):
File "/usr/local/bin/canvas.py", line 177, in <module>
run_canvas_sync()
File "/usr/local/bin/canvas.py", line 120, in run_canvas_sync
main_menu(settings)
File "/usr/local/bin/canvas.py", line 135, in main_menu
main_menu(settings)
File "/usr/local/bin/canvas.py", line 142, in main_menu
do_sync(settings, "")
File "/usr/local/bin/canvas.py", line 158, in do_sync
synchronizer.sync()
File "/usr/local/lib/python3.7/site-packages/CanvasSync/CanvasEntities/synchronizer.py", line 123, in sync
course.sync()
File "/usr/local/lib/python3.7/site-packages/CanvasSync/CanvasEntities/course.py", line 169, in sync
child.sync()
File "/usr/local/lib/python3.7/site-packages/CanvasSync/CanvasEntities/folder.py", line 142, in sync
self.add_files()
File "/usr/local/lib/python3.7/site-packages/CanvasSync/CanvasEntities/folder.py", line 90, in add_files
if file[u"id"] in self.black_list:
TypeError: string indices must be integers
This is caused by CanvasSync/CanvasSync/CanvasEntities/folder.py line 86 (files = self.api.get_files_in_folder(self.id)
) and/or line 98 (folders = self.api.get_folders_in_folder(self.id)
) returning 'unauthorized' as the status.
As far as I can tell, mailto links in canvas pages are treated as linked files, CanvasSync tries to download with that link and fails.
Here's an example of the canvas page html: <p><a href="mailto:*****@***.**">*****@***.**</a></p>
This is a pretty low impact bug in the mailto:...
case (only results in a long list of failed file downloads). Might be a little bit worse if a file://
link is used (Didn't test, I'm not sure how the library would deal with a real local file present somewhere).
Fix should just be checking the URL scheme, and only going for the HTTP / HTTPS links.
First things first - I love CanvasSync and really appreciate the work put in to make such a great time-saving tool. Cheers!
The are a number of single courses at my uni which are run for different majors and as such, a single course may have numerous course codes associated with it. Instructors will often delimit these with forward slashes (ie "courseCode1/courseCode2/courseName") - as such there are a number of my courses which seem to be skipped even if I've selected them for syncing; each of these skipped courses has a forward slash in the name.
I've attempted to look at the source code and I've noticed a couple places where "/" is supposed to be removed in order to ensure it doesn't mess with the creation of directories, however I'm not sure why in my case instead of the course name string being cleansed, these units are just being skipped.
Please let me know if you need more info. Thanks!
I was trying to setup CanvasSync and it returned Invalid domain for my universities canvas site: https://canvas.elte.hu/api/v1/courses
.
This site returns the "authorization needed" text in hungarian so the script thinks it's an invalid Canvas domain.
There is one course in particular that I would like to download but for some reason when I did a full sync it skipped it. Then, I tried to download just that particular course content and it skipped it as well.
Hi, after entering encryption password it runs for a few seconds and I get this error:
Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.12/bin/canvas", line 8, in <module> sys.exit(entry()) ^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/bin/canvas.py", line 186, in entry run_canvas_sync() File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/bin/canvas.py", line 132, in run_canvas_sync main_menu(settings) File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/bin/canvas.py", line 146, in main_menu settings.set_settings() File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/CanvasSync/settings/settings.py", line 157, in set_settings self.write_settings() File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/CanvasSync/settings/settings.py", line 214, in write_settings out_file.write(encrypt(settings)) ^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/CanvasSync/settings/cryptography.py", line 48, in encrypt pass_file.write(hashed_password) TypeError: a bytes-like object is required, not 'str'
Traceback (most recent call last):
File "C:\Python37\Scripts\canvas.py", line 191, in <module>
run_canvas_sync()
File "C:\Python37\Scripts\canvas.py", line 134, in run_canvas_sync
main_menu(settings)
File "C:\Python37\Scripts\canvas.py", line 152, in main_menu
main_menu(settings)
File "C:\Python37\Scripts\canvas.py", line 152, in main_menu
main_menu(settings)
File "C:\Python37\Scripts\canvas.py", line 149, in main_menu
main_menu(settings)
File "C:\Python37\Scripts\canvas.py", line 156, in main_menu
do_sync(settings, "")
File "C:\Python37\Scripts\canvas.py", line 172, in do_sync
synchronizer.sync()
File "c:\python37\lib\site-packages\CanvasSync\CanvasEntities\synchronizer.py", line 123, in sync
course.sync()
File "c:\python37\lib\site-packages\CanvasSync\CanvasEntities\course.py", line 169, in sync
child.sync()
File "c:\python37\lib\site-packages\CanvasSync\CanvasEntities\module.py", line 175, in sync
child.sync()
File "c:\python37\lib\site-packages\CanvasSync\CanvasEntities\page.py", line 176, in sync
was_downloaded = self.download()
File "c:\python37\lib\site-packages\CanvasSync\CanvasEntities\page.py", line 140, in download
if self.download_linked_files(body):
File "c:\python37\lib\site-packages\CanvasSync\CanvasEntities\page.py", line 85, in download_linked_files
canvas_file_urls = re.findall(r'data-api-endpoint=\"(.*?)\"', html_body)
File "c:\python37\lib\re.py", line 223, in findall
return _compile(pattern, flags).findall(string)
TypeError: expected string or bytes-like object
Sync does not finish due to this error. Most likely due to file being not available for download and no url is provided.
[SYNCED] | Module: Canvas Notes
Traceback (most recent call last):
File "/Users/dsalzman/.local/share/virtualenvs/Kaitlyn_Skoirchet-S2BqCVsg/bin/canvas", line 8, in
sys.exit(entry())
File "/Users/dsalzman/.local/share/virtualenvs/Kaitlyn_Skoirchet-S2BqCVsg/lib/python3.8/site-packages/bin/canvas.py", line 187, in entry
run_canvas_sync()
File "/Users/dsalzman/.local/share/virtualenvs/Kaitlyn_Skoirchet-S2BqCVsg/lib/python3.8/site-packages/bin/canvas.py", line 132, in run_canvas_sync
main_menu(settings)
File "/Users/dsalzman/.local/share/virtualenvs/Kaitlyn_Skoirchet-S2BqCVsg/lib/python3.8/site-packages/bin/canvas.py", line 147, in main_menu
main_menu(settings)
File "/Users/dsalzman/.local/share/virtualenvs/Kaitlyn_Skoirchet-S2BqCVsg/lib/python3.8/site-packages/bin/canvas.py", line 154, in main_menu
do_sync(settings, "")
File "/Users/dsalzman/.local/share/virtualenvs/Kaitlyn_Skoirchet-S2BqCVsg/lib/python3.8/site-packages/bin/canvas.py", line 170, in do_sync
synchronizer.sync()
File "/Users/dsalzman/.local/share/virtualenvs/Kaitlyn_Skoirchet-S2BqCVsg/lib/python3.8/site-packages/CanvasSync/entities/synchronizer.py", line 126, in sync
course.sync()
File "/Users/dsalzman/.local/share/virtualenvs/Kaitlyn_Skoirchet-S2BqCVsg/lib/python3.8/site-packages/CanvasSync/entities/course.py", line 163, in sync
child.sync()
File "/Users/dsalzman/.local/share/virtualenvs/Kaitlyn_Skoirchet-S2BqCVsg/lib/python3.8/site-packages/CanvasSync/entities/module.py", line 166, in sync
self.add_items()
File "/Users/dsalzman/.local/share/virtualenvs/Kaitlyn_Skoirchet-S2BqCVsg/lib/python3.8/site-packages/CanvasSync/entities/module.py", line 144, in add_items
self.add_sub_header(folder[0], position + 1, folder[1:])
File "/Users/dsalzman/.local/share/virtualenvs/Kaitlyn_Skoirchet-S2BqCVsg/lib/python3.8/site-packages/CanvasSync/entities/module.py", line 84, in add_sub_header
sub_folder = SubHeader(folder_info, folder_position, parent=self, items=folder_items)
File "/Users/dsalzman/.local/share/virtualenvs/Kaitlyn_Skoirchet-S2BqCVsg/lib/python3.8/site-packages/CanvasSync/entities/sub_header.py", line 52, in init
Module.init(self,
File "/Users/dsalzman/.local/share/virtualenvs/Kaitlyn_Skoirchet-S2BqCVsg/lib/python3.8/site-packages/CanvasSync/entities/module.py", line 52, in init
CanvasEntity.init(self,
File "/Users/dsalzman/.local/share/virtualenvs/Kaitlyn_Skoirchet-S2BqCVsg/lib/python3.8/site-packages/CanvasSync/entities/canvas_entity.py", line 107, in init
self._make_folder()
File "/Users/dsalzman/.local/share/virtualenvs/Kaitlyn_Skoirchet-S2BqCVsg/lib/python3.8/site-packages/CanvasSync/entities/canvas_entity.py", line 204, in _make_folder
os.mkdir(self.sync_path)
OSError: [Errno 63] File name too long: "/Users/dsalzman/git/Kaitlyn_Skoirchet/BUSN 38105 81,02,01 Advanced Negotiations/1 - Canvas Notes/1 - Ordinarily the Canvas site would be complete for the entire ... However, there was a lot of editing, so I'm sure that there will be some mistakes! (Please let me know if you find one!) And, I will adjust the assignments if necessary to reflect the reality of online learning/"
This is a first time setup.
You must specify at least the following settings in order to run CanvasSync:
[*] Sync path: /Users/<me>/Documents/canvas sync
[*] Canvas domain: https://<my school domain>.instructure.com
[*] Authentication token: <my token>
[*] Courses to be synced: Not set
Traceback (most recent call last):
File "//anaconda3/bin/canvas", line 10, in <module>
sys.exit(entry())
File "//anaconda3/lib/python3.7/site-packages/bin/canvas.py", line 187, in entry
run_canvas_sync()
File "//anaconda3/lib/python3.7/site-packages/bin/canvas.py", line 132, in run_canvas_sync
main_menu(settings)
File "//anaconda3/lib/python3.7/site-packages/bin/canvas.py", line 146, in main_menu
settings.set_settings()
File "//anaconda3/lib/python3.7/site-packages/CanvasSync/settings/settings.py", line 152, in set_settings
self._set_settings()
File "//anaconda3/lib/python3.7/site-packages/CanvasSync/settings/settings.py", line 180, in _set_settings
self.courses_to_sync = user_prompter.ask_for_courses(self, api=self.api)
File "//anaconda3/lib/python3.7/site-packages/CanvasSync/settings/user_prompter.py", line 171, in ask_for_courses
courses = [name[u"course_code"].split(";")[-1] for name in courses]
File "//anaconda3/lib/python3.7/site-packages/CanvasSync/settings/user_prompter.py", line 171, in <listcomp>
courses = [name[u"course_code"].split(";")[-1] for name in courses]
I currently have two Canvas accounts for two different departments where I am currently taking courses.
Currently, CanvasSync only allows for one "setting" or account, so I have to choose one of the two when using the program. I was wondering if it was possible to set more than one account for syncing.
Thank you!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.