diff --git a/extbuild/fundrive-lanzou/pyproject.toml b/extbuild/fundrive-lanzou/pyproject.toml index 6858b5d..6c331a4 100644 --- a/extbuild/fundrive-lanzou/pyproject.toml +++ b/extbuild/fundrive-lanzou/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "fundrive-lanzou" -version = "1.2.62" +version = "1.2.63" description = "fundrive" readme = "README.md" requires-python = ">=3.8" diff --git a/logs/all.log b/logs/all.log index 386fbf2..cf3a4ad 100644 --- a/logs/all.log +++ b/logs/all.log @@ -1,3 +1,6 @@ 2024-12-15 19:11:53.733 |INFO | funbuild.core.core : core: 86 | funbuild | - fundrive build 2024-12-15 19:11:53.745 |INFO | funbuild.core.core : core: 74 | funbuild | - fundrive pull 2024-12-15 19:12:09.127 |INFO | funbuild.core.core : core: 78 | funbuild | - fundrive push +2024-12-15 19:18:48.283 |INFO | funbuild.core.core : core: 86 | funbuild | - fundrive build +2024-12-15 19:18:48.284 |INFO | funbuild.core.core : core: 74 | funbuild | - fundrive pull +2024-12-15 19:19:02.131 |INFO | funbuild.core.core : core: 78 | funbuild | - fundrive push diff --git a/logs/funbuild.log b/logs/funbuild.log index 386fbf2..cf3a4ad 100644 --- a/logs/funbuild.log +++ b/logs/funbuild.log @@ -1,3 +1,6 @@ 2024-12-15 19:11:53.733 |INFO | funbuild.core.core : core: 86 | funbuild | - fundrive build 2024-12-15 19:11:53.745 |INFO | funbuild.core.core : core: 74 | funbuild | - fundrive pull 2024-12-15 19:12:09.127 |INFO | funbuild.core.core : core: 78 | funbuild | - fundrive push +2024-12-15 19:18:48.283 |INFO | funbuild.core.core : core: 86 | funbuild | - fundrive build +2024-12-15 19:18:48.284 |INFO | funbuild.core.core : core: 74 | funbuild | - fundrive pull +2024-12-15 19:19:02.131 |INFO | funbuild.core.core : core: 78 | funbuild | - fundrive push diff --git a/pyproject.toml b/pyproject.toml index 97fbec0..7585f21 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "fundrive" -version = "1.2.62" +version = "1.2.63" description = "fundrive" readme = "README.md" requires-python = ">=3.8" diff --git a/src/fundrive/drives/wenshushu/drive.py b/src/fundrive/drives/wenshushu/drive.py index e45bd34..f354334 100644 --- a/src/fundrive/drives/wenshushu/drive.py +++ b/src/fundrive/drives/wenshushu/drive.py @@ -4,14 +4,17 @@ import os import subprocess import time +import traceback from concurrent.futures import ThreadPoolExecutor import orjson import requests +from fundrive.core import BaseDrive as BaseDrive2 from funget import simple_download +from funutil import getLogger from tqdm import tqdm -from fundrive.core import BaseDrive as BaseDrive2 +logger = getLogger("fundrive") class BaseDrive: @@ -36,7 +39,7 @@ def storage(self): rest_space = int(rsp["data"]["rest_space"]) send_space = int(rsp["data"]["send_space"]) storage_space = rest_space + send_space - print( + logger.info( "当前已用空间:{}GB,剩余空间:{}GB,总空间:{}GB".format( round(send_space / 1024**3, 2), round(rest_space / 1024**3, 2), @@ -182,8 +185,8 @@ def copysend(self, boxid, taskid, preid): json={"bid": boxid, "tid": taskid, "ufileid": preid}, ) rsp = r.json() - print(f"个人管理链接:{rsp['data']['mgr_url']}") - print(f"公共链接:{rsp['data']['public_url']}") + logger.info(f"个人管理链接:{rsp['data']['mgr_url']}") + logger.info(f"公共链接:{rsp['data']['public_url']}") def sha1_str(self, s): cm = hashlib.sha1(s.encode()).hexdigest() @@ -198,6 +201,8 @@ def calc_file_hash(self, hash_type, block=None): hash_code = hashlib.md5(block).hexdigest() elif hash_type == "SHA1": hash_code = hashlib.sha1(block).hexdigest() + else: + raise NotImplementedError return hash_code def get_cipherheader(self, epochtime, token, data): @@ -206,7 +211,7 @@ def get_cipherheader(self, epochtime, token, data): from Cryptodome.Cipher import DES from Cryptodome.Util import Padding except Exception as e: - print(e) + logger.info(f"error: {e} traceback: {traceback.format_exc()}") subprocess.check_call(["pip", "install", "pycryptodomex"]) import base58 from Cryptodome.Cipher import DES @@ -267,7 +272,7 @@ def fast(self): hash_codes += self.calc_file_hash("MD5", block) payload["hash"]["cm"] = self.sha1_str(hash_codes) elif can_fast and ufile: - print(f"文件{name}可以被秒传!") + logger.info(f"文件{name}可以被秒传!") self.get_process(upId) self.copysend(boxid, taskid, preid) @@ -338,10 +343,10 @@ def mgrtask(self, tid): days, remainder = divmod(int(float(expire)), 3600 * 24) hours, remainder = divmod(remainder, 3600) minutes, seconds = divmod(remainder, 60) - print(f"文件过期时间:{days}天{hours}时{minutes}分{seconds}秒") + logger.info(f"文件过期时间:{days}天{hours}时{minutes}分{seconds}秒") file_size = rsp["data"]["file_size"] - print(f"文件大小:{round(int(file_size) / 1024 ** 2, 2)}MB") + logger.info(f"文件大小:{round(int(file_size) / 1024 ** 2, 2)}MB") return rsp["data"]["boxid"], rsp["data"]["ufileid"] # pid def sign_url(self, fid): @@ -401,8 +406,10 @@ def upload_file( uploader = Uploader(drive=self.drive, file_path=file_path) try: uploader.upload() + return True except Exception as e: - print(e) + logger.info(f"error: {e} traceback: {traceback.format_exc()}") + return False def download_file( self, share_url=None, dir_path="./cache", overwrite=False, *args, **kwargs @@ -412,5 +419,7 @@ def download_file( ) try: downloader.download() + return True except Exception as e: - print(e) + logger.info(f"error: {e} traceback: {traceback.format_exc()}") + return False diff --git a/uv.lock b/uv.lock index ce68423..e070ecc 100644 --- a/uv.lock +++ b/uv.lock @@ -344,7 +344,7 @@ wheels = [ [[package]] name = "fundrive" -version = "1.2.62" +version = "1.2.63" source = { virtual = "." } dependencies = [ { name = "funget" }, @@ -384,7 +384,7 @@ requires-dist = [ [[package]] name = "fundrive-lanzou" -version = "1.2.62" +version = "1.2.63" source = { virtual = "extbuild/fundrive-lanzou" } dependencies = [ { name = "fundrive" },