Skip to content

Commit bbf6fc2

Browse files
authored
code: add quick-start scripts (#113)
1 parent 663aac5 commit bbf6fc2

File tree

4 files changed

+52
-11
lines changed

4 files changed

+52
-11
lines changed

README.md

+4-8
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ For legacy version, refer to [legacy](https://github.com/skyzh/canvas_grab/tree/
1212

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

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

3332
```bash
34-
pip3 install -r requirements.txt
35-
./main.py
33+
./canvas_grab.sh
3634
```
3735

3836
For Windows users:
3937
```powershell
40-
pip install -r requirements.txt
41-
pip install -r requirements.windows.txt
42-
python main.py
38+
.\canvas_grab.ps1
4339
```
4440

4541
## Configure
4642

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

5147
## Common Issues
5248

canvas_grab.ps1

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/pwsh
2+
$ErrorActionPreference = "Stop"
3+
4+
echo "Check Python installation..."
5+
python3 --version
6+
7+
echo "Check virtual environment..."
8+
9+
if (-Not(Test-Path -Path venv)) {
10+
echo "Create virtual environment..."
11+
python3 -m venv venv
12+
echo "Activate virtual environment..."
13+
. ./venv/bin/Activate.ps1
14+
echo "Install dependencies with SJTUG mirror..."
15+
python -m pip install --upgrade pip -i https://mirrors.sjtug.sjtu.edu.cn/pypi/web/simple
16+
python -m pip install -r requirements.txt -i https://mirrors.sjtug.sjtu.edu.cn/pypi/web/simple
17+
python -m pip install -r requirements.windows.txt -i https://mirrors.sjtug.sjtu.edu.cn/pypi/web/simple
18+
} else {
19+
echo "Activate virtual environment..."
20+
. ./venv/bin/Activate.ps1
21+
}
22+
23+
python main.py $@

canvas_grab.sh

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
set -e
3+
4+
echo "Check Python installation..."
5+
python3 --version
6+
7+
echo "Check virtual environment..."
8+
9+
if [ ! -d "venv" ]; then
10+
echo "Create virtual environment..."
11+
python3 -m venv venv
12+
echo "Activate virtual environment..."
13+
. venv/bin/activate
14+
echo "Install dependencies with SJTUG mirror..."
15+
python -m pip install --upgrade pip -i https://mirrors.sjtug.sjtu.edu.cn/pypi/web/simple
16+
python -m pip install -r requirements.txt -i https://mirrors.sjtug.sjtu.edu.cn/pypi/web/simple
17+
else
18+
echo "Activate virtual environment..."
19+
. venv/bin/activate
20+
fi
21+
22+
python main.py $@

canvas_grab/config/__init__.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ def to_config(self):
2424
}
2525

2626
def from_config(self, config):
27-
self.endpoint.from_config(config['endpoint'])
28-
self.course_filter.from_config(config['course_filter'])
29-
self.organize_mode.from_config(config['organize_mode'])
3027
self.download_folder = config.get(
3128
'download_folder', self.download_folder)
29+
self.endpoint.from_config(config['endpoint'])
30+
self.organize_mode.from_config(config['organize_mode'])
31+
self.course_filter.from_config(config['course_filter'])
3232

3333
def interact(self):
3434
self.endpoint.interact()

0 commit comments

Comments
 (0)