Skip to content

Commit

Permalink
code: add quick-start scripts (skyzh#113)
Browse files Browse the repository at this point in the history
  • Loading branch information
skyzh authored Feb 20, 2021
1 parent 663aac5 commit bbf6fc2
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 11 deletions.
12 changes: 4 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ For legacy version, refer to [legacy](https://github.com/skyzh/canvas_grab/tree/

1. Install Python
2. Download https://github.com/skyzh/canvas_grab/archive/master.zip or `git clone https://github.com/skyzh/canvas_grab`
3. `pip install -r requirements.txt`, and `pip install -r requirements.windows.txt` if using Windows
4. Run `python main.py`
3. Run `./canvas_grab.sh` (Linux, macOS) or `.\canvas_grab.ps1` (Windows) in Terminal.
5. Get your API key at Canvas profile and you're ready to go!

See `Build and Run from Source` for more details.
Expand All @@ -31,22 +30,19 @@ First of all, please install Python 3.8+, and download source code.
For macOS or Linux users:

```bash
pip3 install -r requirements.txt
./main.py
./canvas_grab.sh
```

For Windows users:
```powershell
pip install -r requirements.txt
pip install -r requirements.windows.txt
python main.py
.\canvas_grab.ps1
```

## Configure

The setup wizard will automatically create a configuration for you.
You can change `config.toml` to fit your needs. If you need to
re-configure, run `./main.py configure` or `python main.py configure`.
re-configure, run `./canvas_grab.sh configure`.

## Common Issues

Expand Down
23 changes: 23 additions & 0 deletions canvas_grab.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/pwsh
$ErrorActionPreference = "Stop"

echo "Check Python installation..."
python3 --version

echo "Check virtual environment..."

if (-Not(Test-Path -Path venv)) {
echo "Create virtual environment..."
python3 -m venv venv
echo "Activate virtual environment..."
. ./venv/bin/Activate.ps1
echo "Install dependencies with SJTUG mirror..."
python -m pip install --upgrade pip -i https://mirrors.sjtug.sjtu.edu.cn/pypi/web/simple
python -m pip install -r requirements.txt -i https://mirrors.sjtug.sjtu.edu.cn/pypi/web/simple
python -m pip install -r requirements.windows.txt -i https://mirrors.sjtug.sjtu.edu.cn/pypi/web/simple
} else {
echo "Activate virtual environment..."
. ./venv/bin/Activate.ps1
}

python main.py $@
22 changes: 22 additions & 0 deletions canvas_grab.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
set -e

echo "Check Python installation..."
python3 --version

echo "Check virtual environment..."

if [ ! -d "venv" ]; then
echo "Create virtual environment..."
python3 -m venv venv
echo "Activate virtual environment..."
. venv/bin/activate
echo "Install dependencies with SJTUG mirror..."
python -m pip install --upgrade pip -i https://mirrors.sjtug.sjtu.edu.cn/pypi/web/simple
python -m pip install -r requirements.txt -i https://mirrors.sjtug.sjtu.edu.cn/pypi/web/simple
else
echo "Activate virtual environment..."
. venv/bin/activate
fi

python main.py $@
6 changes: 3 additions & 3 deletions canvas_grab/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ def to_config(self):
}

def from_config(self, config):
self.endpoint.from_config(config['endpoint'])
self.course_filter.from_config(config['course_filter'])
self.organize_mode.from_config(config['organize_mode'])
self.download_folder = config.get(
'download_folder', self.download_folder)
self.endpoint.from_config(config['endpoint'])
self.organize_mode.from_config(config['organize_mode'])
self.course_filter.from_config(config['course_filter'])

def interact(self):
self.endpoint.interact()
Expand Down

0 comments on commit bbf6fc2

Please sign in to comment.