Skip to content

Commit

Permalink
新增传入上传至网盘路径的参数 (#9)
Browse files Browse the repository at this point in the history
* 增加第二参数上传路径 修改config文件的读取位置

新增第二参数(上传路径),可通过shell调用上传至不同文件夹。修改config读取位置,便于在上级文件夹内调用main

* 新增传入上传至网盘路径的参数

增加检测传入第二参数,如果存在则修改ROOT_Path

* 更新readme,加入指定目录上传
  • Loading branch information
NagisaCo authored May 21, 2021
1 parent e01a8ca commit 08d05a4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ python3 main.py /www/wwwroot/download/
```shell
python3 main.py /www/lixiaoen.jpg
```

> 指定上传目录
```shell
python3 main.py /www/lixiaoen.jpg /Backup
```
## 更新
```shell
cd ~/aliyundrive-uploader
Expand Down
14 changes: 13 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,19 @@ def upload_file(path, filepath):
print_error('请配置好config.json后重试')
raise e
# 命令行参数上传
if len(sys.argv) == 2:
if len(sys.argv) == 3:
ROOT_PATH=sys.argv[2].replace('/', os.sep).replace('\\\\', os.sep).rstrip(os.sep) + os.sep
abspath=os.path.abspath(sys.argv[1])
if os.path.isdir(sys.argv[1]):
# 目录上传
FILE_PATH = abspath
file_list = get_all_file_relative(FILE_PATH)
else:
# 单文件上传
FILE_PATH = os.path.dirname(abspath)
file_list = [os.path.basename(abspath)]
common.DATA['tasks'] = {}
elif len(sys.argv) == 2:
abspath=os.path.abspath(sys.argv[1])
if os.path.isdir(abspath):
# 目录上传
Expand Down

0 comments on commit 08d05a4

Please sign in to comment.