From 36341a280334909c0d3fb060331f4df1fcdfb1b5 Mon Sep 17 00:00:00 2001 From: BoYanZh Date: Mon, 16 Dec 2024 13:33:39 -0500 Subject: [PATCH] chore: fix pip deps & doc to pipx --- .gitignore | 1 + README.md | 6 +++--- canvassyncer/__main__.py | 13 +++++++------ requirements.txt | 6 +++--- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 98d858f..8093056 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,4 @@ __pycache__ courses/ upload.sh dist.py +venv diff --git a/README.md b/README.md index aad2dfe..bcfd675 100644 --- a/README.md +++ b/README.md @@ -14,13 +14,13 @@ You may use one of the following For Windows users, you can find binary(.exe) file here: . 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 or the search engine to get your `pip`. +If you have not installed `pipx` yet, you may refer to or the search engine to get your `pipx`. ### From Source diff --git a/canvassyncer/__main__.py b/canvassyncer/__main__.py index 4c0fe9b..7bb90fd 100644 --- a/canvassyncer/__main__.py +++ b/canvassyncer/__main__.py @@ -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 @@ -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, ) @@ -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 @@ -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 diff --git a/requirements.txt b/requirements.txt index 65a9751..1bd388b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ -httpx -tqdm -aiofiles +aiofiles==24.1.0 +httpx==0.28.1 +tqdm==4.67.1