Skip to content

Commit

Permalink
接入Travis CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Hsury committed Nov 8, 2019
1 parent 6387925 commit 094a83b
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 5 deletions.
53 changes: 53 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
<h1 align="center">- BiliDrive -</h1>

<p align="center">
<img src="https://img.shields.io/badge/version-2019.11.3-green.svg?longCache=true&style=for-the-badge">
<img src="https://img.shields.io/badge/version-2019.11.9-green.svg?longCache=true&style=for-the-badge">
<img src="https://img.shields.io/travis/com/Hsury/BiliDrive?style=for-the-badge">
<img src="https://img.shields.io/badge/license-SATA-blue.svg?longCache=true&style=for-the-badge">
</p>

Expand Down Expand Up @@ -58,7 +59,7 @@ file: 待上传的文件路径
```
drive.py download [-h] [-f] [-t THREAD] meta [file]
meta: META地址(通常以`bdrive://`开头)
meta: META地址(通常以bdrive://开头)
file: 另存为新的文件名, 不指定则保存为上传时的文件名
-f: 覆盖已有文件
Expand All @@ -72,7 +73,7 @@ file: 另存为新的文件名, 不指定则保存为上传时的文件名
```
drive.py info [-h] meta
meta: META地址(通常以`bdrive://`开头)
meta: META地址(通常以bdrive://开头)
```

### 查看历史记录
Expand Down
2 changes: 1 addition & 1 deletion bilibili.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 4 additions & 1 deletion drive.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down
Binary file added icon.ico
Binary file not shown.

0 comments on commit 094a83b

Please sign in to comment.