From 094a83bb248d4ea736bf50d94b67273ea5ec1b67 Mon Sep 17 00:00:00 2001
From: Hsury
Date: Sat, 9 Nov 2019 00:34:00 +0800
Subject: [PATCH] =?UTF-8?q?=E6=8E=A5=E5=85=A5Travis=20CI?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.travis.yml | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++
README.md | 7 ++++---
bilibili.py | 2 +-
drive.py | 5 ++++-
icon.ico | Bin 0 -> 62285 bytes
5 files changed, 62 insertions(+), 5 deletions(-)
create mode 100644 .travis.yml
create mode 100644 icon.ico
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..c6fe3ef
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,53 @@
+if: 'tag IS blank'
+env:
+ global:
+ - TRAVIS_TAG=v1.3
+jobs:
+ include:
+ -
+ name: 'Python 3.7.5 on Linux (AMD64)'
+ os: linux
+ dist: bionic
+ arch: amd64
+ language: python
+ python: 3.7.5
+ env: RELEASE_FILENAME=bilidrive-$TRAVIS_TAG-linux-amd64.tar.gz
+ -
+ name: 'Python 3.7.5 on Linux (ARM64)'
+ os: linux
+ dist: bionic
+ arch: arm64
+ language: python
+ python: 3.7.5
+ env: ['PATH=~/.ruby/bin:$PATH', GEM_HOME=~/.ruby, RELEASE_FILENAME=bilidrive-$TRAVIS_TAG-linux-arm64.tar.gz]
+ -
+ name: 'Python 3.7.4 on macOS (AMD64)'
+ os: osx
+ osx_image: xcode11.2
+ arch: amd64
+ language: shell
+ env: RELEASE_FILENAME=bilidrive-$TRAVIS_TAG-macos-amd64.zip
+ -
+ name: 'Python 3.7.5 on Windows (AMD64)'
+ os: windows
+ arch: amd64
+ language: shell
+ env: ['PATH=/c/Python37:/c/Python37/Scripts:$PATH', RELEASE_FILENAME=bilidrive-$TRAVIS_TAG-windows-amd64.zip]
+ before_install: 'choco install python --version 3.7.5'
+install:
+ - 'if [ "$TRAVIS_OS_NAME" = "windows" ]; then python -m pip install -U pip; else pip3 install -U pip; fi'
+ - 'pip3 install -r requirements.txt'
+ - 'pip3 install pyinstaller'
+script:
+ - 'if [ "$TRAVIS_OS_NAME" = "windows" ]; then python drive.py -h; else python3 drive.py -h; fi'
+ - 'pyinstaller -F -n BiliDrive -i icon.ico drive.py'
+ - 'mkdir -p release/BiliDrive'
+ - 'cp {dist/*,LICENSE,README.md} release/BiliDrive'
+ - 'cd release'
+ - 'if [ "$TRAVIS_OS_NAME" = "windows" ]; then 7z a -tzip $RELEASE_FILENAME BiliDrive; elif [ "$TRAVIS_OS_NAME" = "osx" ]; then zip -r $RELEASE_FILENAME BiliDrive; else tar -czvf $RELEASE_FILENAME BiliDrive; fi'
+deploy:
+ provider: releases
+ api_key: $GITHUB_OAUTH_TOKEN
+ file: $RELEASE_FILENAME
+ overwrite: true
+ skip_cleanup: true
diff --git a/README.md b/README.md
index c23d42f..8a29db2 100644
--- a/README.md
+++ b/README.md
@@ -5,7 +5,8 @@
- BiliDrive -
- + +
@@ -58,7 +59,7 @@ file: 待上传的文件路径 ``` drive.py download [-h] [-f] [-t THREAD] meta [file] -meta: META地址(通常以`bdrive://`开头) +meta: META地址(通常以bdrive://开头) file: 另存为新的文件名, 不指定则保存为上传时的文件名 -f: 覆盖已有文件 @@ -72,7 +73,7 @@ file: 另存为新的文件名, 不指定则保存为上传时的文件名 ``` drive.py info [-h] meta -meta: META地址(通常以`bdrive://`开头) +meta: META地址(通常以bdrive://开头) ``` ### 查看历史记录 diff --git a/bilibili.py b/bilibili.py index d217fab..a1b06a6 100644 --- a/bilibili.py +++ b/bilibili.py @@ -35,7 +35,7 @@ def __init__(self): def _log(message): print(f"[{time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))}] {message}") - def _requests(self, method, url, decode_level=2, retry=10, timeout=15, **kwargs): + def _requests(self, method, url, decode_level=2, retry=0, timeout=10, **kwargs): if method in ["get", "post"]: for _ in range(retry + 1): try: diff --git a/drive.py b/drive.py index d9fa0b7..faac0e0 100644 --- a/drive.py +++ b/drive.py @@ -220,6 +220,9 @@ def write_history(first_4mb_sha1, meta_dict, url): if not os.path.exists(file_name): log(f"{file_name}不存在") return None + if os.path.isdir(file_name): + log("不支持上传文件夹") + return None log(f"上传: {os.path.basename(file_name)} ({os.path.getsize(file_name) / 1024 / 1024:.2f} MB)") first_4mb_sha1 = calc_sha1(read_in_chunks(file_name, chunk_size=4 * 1024 * 1024, chunk_number=1), hexdigest=True) history = read_history() @@ -372,7 +375,7 @@ def is_overwrite(file_name): if __name__ == "__main__": signal.signal(signal.SIGINT, lambda signum, frame: os.kill(os.getpid(), 9)) - parser = argparse.ArgumentParser(description="BiliDrive", epilog="By Hsury, 2019/11/3") + parser = argparse.ArgumentParser(description="BiliDrive", epilog="By Hsury, 2019/11/9") subparsers = parser.add_subparsers() history_parser = subparsers.add_parser("history", help="view upload history") history_parser.set_defaults(func=history_handle) diff --git a/icon.ico b/icon.ico new file mode 100644 index 0000000000000000000000000000000000000000..e9eb24843e831691f4e7e2fedfb41ea0970058c8 GIT binary patch literal 62285 zcmeFa1wd8H^Ekfu(wzblQc}_i5=x_D0Ty6@2uKMCiqddFKolkH06|bd5Je>=1w}5#v4d>5I?zz2D!3y?Zuh&&=%Xp4~k&djP-yD!|1>3qwNCg$1Aj06p1<7PF$Ox3sCLXIGfca!+gSLu_-sH{qhaWLs@V)RcyfH_^`BcGV5e
z@XbxSk*vn}>b0Q)vO4=WhaYgReOL6p&Mm(OqqR3}C^qHbScM0f!YQ71x&-xeSr1CQ
z+Q;nlbl6f{#@4Ogm( %w(E$(Y7&Z5^GBW5|bDWqsh2b1FafOT@cr3
z5|yfeCbp=EiXw;$S}9?SMc|2mY>!n?aSx~8ciua2-{ao*9xl=8z|7&?<=u1sd+xpG
zod5g(^Zgf&N6Pke^?oS-7Cg%~vQgH;82?qU7cA40N%t82E5PYp*oM>F&PR;4_lLRAX#8OizNLdlIUH`xnOdf08!z*@5DQ>PDxU
z0zp)VHpv9=!!(wAkk|i98UH8g{8jfa4*cT4FAn_T!2c}=7B-+3G?(CfAFsjmQz44J
z2LO0|DR}w{UXKdC6=_1#p%q^a8p4^)Vu(ZI(BbgEfAME=#dcc%sHW)_>h1tPfJPseZYJKA{|6aZ!&Nh(>4oRiCRdme@S
zcKxYIE6h;R{sc3W%vparQY2EbJ*PaBkM<|#pba4AOFIH3{v=53VwX3AD|%Q-yn
zWt`U^VHf@@=F#)uZ}2YHG$)3dx~boF