Giter Site home page Giter Site logo

clanvas's People

Contributors

rowdyrotifer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

clanvas's Issues

Add clanvas directory which will contain rcfile and future files for caches, history, etc.

Currently, if we want to add command history, or any sort of cache that persists longer than a session, we would need to choose more arbitrary files / locations to put them in. Instead, let's start by making this a configurable directory.

Check for an environment variable called CLANVASHOME, if it is set, then use that value.

Otherwise / by default set this value to a .clanvas folder in the user's home directory.

In order to consolidate the growing number of files, move ~/.clanvasrc to clanvas_data_directory/rcfile.

On startup, if this directory does not exist, create it. Also on startup, if the rcfile does not exist, create it (but leave it empty).

Assignment uploads: check file extension on the client side

In the Canvas API, assignments have an allowed_extensions attribute. These extensions should be checked when running the ua command, and an appropriate error message should be displayed instead of going through with the upload.

Interestingly enough, it seems that the API happily accepts and submits uploads of the wrong file type currently, whereas in my experience, the website doesn't. We still shouldn't allow it though.

Add present working course command

In the Clanvas shell, the default prompt adds functionality parallel to what most shells have with the cd (change directory) command. Clanvas has a cc (change class) command, which then implicitly passes that course to all the command that require a course to be specified (for example, lg (list grades) can be called after a cc call, or one can use the -c option to specify a course explicitly or a course other than the current one).

Add a pwc (present working class) command (analogous to the pwd (present working directory) command) that outputs information about the class that is currently selected with cc.

Now, there is a bit more information about courses than there is about directories, so I imagine the command would be a bit more complex than the pwd command, here is how I imagine some example output:

Command: pwc

EECS455-13682

Command: pwc -l

Name: Applied Graph Theory (100/10395)
Course code: EECS 455
Term: Fall 2018
Course id: 13682

If no course has been selected, something like the following would make sense.

Command: pwc

No course selected. Use cc to select a course.

Using old version of cmd2 breaks in Python 3.10

Due to the old version of cmd2 used, clanvas no longer works in Python 3.10:

>>> import cmd2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/michael/.local/lib/python3.10/site-packages/cmd2/__init__.py", line 13, in <module>
    from .cmd2 import Cmd, Statement, EmptyStatement, categorize
  File "/home/michael/.local/lib/python3.10/site-packages/cmd2/cmd2.py", line 48, in <module>
    from . import utils
  File "/home/michael/.local/lib/python3.10/site-packages/cmd2/utils.py", line 73, in <module>
    default_values: collections.Iterable = ()):
AttributeError: module 'collections' has no attribute 'Iterable'

In Python 3.10, Iterable was moved to collections.abc.

Several possible solutions:

  1. Copy cmd2 directly into here (as using a specific version) and make the change manually / maintain independent version
  2. Update clanvas to newer versions of cmd2
  3. Don't support Python 3.10

I could probably do 1 if that's what you want to do.

Program does not work immediately after install

I tried installing clanvas on Ubuntu WSL (Python 3.10) and Windows (Python 3.11), and neither works after install.

Here is the output when I try to run:

Ubuntu WSL

$ clanvas [school url redacted]

Traceback (most recent call last):
  File "/home/mason/.local/bin/clanvas", line 5, in <module>
    from clanvas.clanvas import main
  File "/home/mason/.local/lib/python3.10/site-packages/clanvas/clanvas.py", line 11, in <module>
    import cmd2
  File "/home/mason/.local/lib/python3.10/site-packages/cmd2/__init__.py", line 13, in <module>
    from .cmd2 import Cmd, Statement, EmptyStatement, categorize
  File "/home/mason/.local/lib/python3.10/site-packages/cmd2/cmd2.py", line 48, in <module>
    from . import utils
  File "/home/mason/.local/lib/python3.10/site-packages/cmd2/utils.py", line 73, in <module>
    default_values: collections.Iterable = ()):
AttributeError: module 'collections' has no attribute 'Iterable'

Windows

$ clanvas [school url redacted]

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "D:\Users\Mason Francis\OneDrive\Coding\clanvas-test\venv\Scripts\clanvas.exe\__main__.py", line 4, in <module>
  File "D:\Users\Mason Francis\OneDrive\Coding\clanvas-test\venv\Lib\site-packages\clanvas\clanvas.py", line 2, in <module>
    import readline
  File "D:\Users\Mason Francis\OneDrive\Coding\clanvas-test\venv\Lib\site-packages\readline.py", line 34, in <module>
    rl = Readline()
         ^^^^^^^^^^
  File "D:\Users\Mason Francis\OneDrive\Coding\clanvas-test\venv\Lib\site-packages\pyreadline\rlmain.py", line 422, in __init__
    BaseReadline.__init__(self)
  File "D:\Users\Mason Francis\OneDrive\Coding\clanvas-test\venv\Lib\site-packages\pyreadline\rlmain.py", line 62, in __init__
    mode.init_editing_mode(None)
  File "D:\Users\Mason Francis\OneDrive\Coding\clanvas-test\venv\Lib\site-packages\pyreadline\modes\emacs.py", line 633, in init_editing_mode
    self._bind_key('space',       self.self_insert)
  File "D:\Users\Mason Francis\OneDrive\Coding\clanvas-test\venv\Lib\site-packages\pyreadline\modes\basemode.py", line 162, in _bind_key
    if not callable(func):
           ^^^^^^^^^^^^^^
  File "D:\Users\Mason Francis\OneDrive\Coding\clanvas-test\venv\Lib\site-packages\pyreadline\py3k_compat.py", line 8, in callable
    return isinstance(x, collections.Callable)
                         ^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'collections' has no attribute 'Callable'

Few random cmd2 recommendations

I just took a quick look at the clanvas source code and have a few recommendations regarding the use of cmd2 that you may benefit from:

  • Consider loading your resource file via the startup_script optional argument to the cmd2.Cmd initializer
  • Consider also specifying a persistent readline history file in the initializer as well
  • For commands which use one of the argparse decorators, consider using ACArgumentParser from cmd2 instead of argparse.ArgumentParser - it has several benefits when it comes to automatic tab completion
  • As of cmd2 0.9.5, you no longer need to init colorama in your app code, because that is done by cmd2

Handle courses without names

Courses seem to sometimes not have names assigned to them.

From a few cases I've seen, it seems like sometimes courses are used for things that aren't really courses. So let's default to an empty string if there is no name attribute in a Course.

46473249_488838704969612_3241604078207238144_n

Make .clanvasrc file location configurable.

Currently, the .clanvasrc file is hardcoded to the user's home directory (~/.clanvasrc)

It would be nice if there were ways to specify alternate locations for those with custom configurations.

Add a function that resolves the path of the rcfile by using an approach with a series of fallbacks:

  1. Check if the user specifies a flag called --rc-file, if they do, use that option's value.
  2. If they do not specify that flag, then check an environment variable called CLANVASRCPATH, if they do, use that option's value.
  3. If they do not specify that environment variable, then simply use the current value: join(expanduser('~'), '.clanvasrc')

Use argparse. ArgumentParser to read the command-line arguments, and os.environ to read environment variables.

Add more informative tab completion for courses, assignments, and announcements

Currently, tab completion for commands such as change class (cc), upload assignment (ua), and concatenate (output) announcement (catann) all work with ID numbers, but the tab completion results are hard to make sense of because you need to have just listed the announcements or assignments to know what each ID corresponds to.

Cmd2 has a capability to display more than just the completion string on tab-complete. See for example the following behavior of the example located at cmd2/examples/tab_autocompletion.py.

(Cmd) media movies delete SW_EP

MOVIE_ID  Title
SW_EP1    Star Wars: Episode I - The Phantom Menace
SW_EP02   Star Wars: Episode II - Attack of the Clones
SW_EP03   Star Wars: Episode III - Revenge of the Sith
SW_EP04   Star Wars: Episode IV - A New Hope
SW_EP05   Star Wars: Episode V - The Empire Strikes Back
SW_EP06   Star Wars: Episode VI - Return of the Jedi
(Cmd) media movies delete SW_EP

Both this example as well as Clanvas leverage the argpase_completer that is a part of cmd2, the CompletionItem class in that file definitely must be relevant to the behavior we're trying to achieve.

For courses, assignments, and announcements, we want to show the full course names, assignment titles, and announcement titles.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.