Skip to content

Commit

Permalink
chore: fix pip deps & doc to pipx
Browse files Browse the repository at this point in the history
  • Loading branch information
BoYanZh committed Dec 16, 2024
1 parent 0c863fb commit 36341a2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ __pycache__
courses/
upload.sh
dist.py
venv
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ You may use one of the following

For Windows users, you can find binary(.exe) file here: <https://github.com/BoYanZh/Canvas-Syncer/releases>. Unzip it and double click `canvassyncer.exe` file to run, or calling it in shell.

### Through `pip`
### Through `pipx`

```bash
pip3 install -U canvassyncer
pipx install -U canvassyncer
```

If you have not installed `pip` yet, you may refer to <https://pip.pypa.io/en/stable/installing/> or the search engine to get your `pip`.
If you have not installed `pipx` yet, you may refer to <https://pipx.pypa.io/stable/> or the search engine to get your `pipx`.

### From Source

Expand Down
13 changes: 7 additions & 6 deletions canvassyncer/__main__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import argparse
import asyncio
import json
import mimetypes
import ntpath
import os
import platform
import re
import time
import traceback
import platform
from datetime import datetime, timezone
import mimetypes

import aiofiles
import httpx
from tqdm import tqdm
Expand All @@ -21,12 +22,12 @@


class AsyncSemClient:
def __init__(self, connectionCount, token, proxies):
def __init__(self, connectionCount, token, proxy):
self.sem = asyncio.Semaphore(connectionCount)
self.client = httpx.AsyncClient(
timeout=5,
headers={"Authorization": f"Bearer {token}"},
proxies=proxies,
proxy=proxy,
transport=httpx.AsyncHTTPTransport(retries=3),
follow_redirects=True,
)
Expand Down Expand Up @@ -96,7 +97,7 @@ class CanvasSyncer:
def __init__(self, config):
self.config = config
self.client = AsyncSemClient(
config["connection_count"], config["token"], config.get("proxies")
config["connection_count"], config["token"], config.get("proxy")
)
self.downloadSize = 0
self.laterDownloadSize = 0
Expand Down Expand Up @@ -516,7 +517,7 @@ def getConfig():
exit(1)
config = json.load(open(configPath, mode="r", encoding="utf-8"))
config["y"] = args.y
config["proxies"] = args.proxy
config["proxy"] = args.proxy
config["no_subfolder"] = args.no_subfolder
config["connection_count"] = args.connection
config["no_keep_older_version"] = args.no_keep_older_version
Expand Down
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
httpx
tqdm
aiofiles
aiofiles==24.1.0
httpx==0.28.1
tqdm==4.67.1

0 comments on commit 36341a2

Please sign in to comment.