Git Product home page Git Product logo

bypy's Introduction

Hi there 👋

Hou Tianze's GitHub Stats

Hou Tianze's Top Languages

bypy's People

Contributors

aflyhorse avatar anjanjanj avatar dlan17 avatar fangdingjun avatar gitter-badger avatar goldenmean58 avatar guibog avatar houtianze avatar hwgao avatar iscb avatar krizex avatar liuycsd avatar mengjie0718 avatar mengskysama avatar renxida avatar saltyang avatar seanlis avatar septs avatar shenchucheng avatar slxu avatar timgates42 avatar wangjiezhe avatar xiyoufang avatar xslidian avatar yuzhichang avatar zhanghongce avatar zxkane avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bypy's Issues

upload syncup 等 subcommand 能 *.mp4 这样么?

试了下好像不行,结果准备这样搞....好长

find  . -maxdepth 1 -type f -name '*.mp4' -print0 | \
  xargs -r0 stat -c "%y %n" | \
  sort | cut -d' ' -f4- | \
  xargs -d "\n" -I{} bypy.py upload {} dest

嗨,哥们,有个问题

你做的这个东西很棒,但是我试了一下,发现一点问题。
首先我发现在首次upload的时候,本地有、云上没有的文件夹,会出一个报错
[02:16:00] Error code: 31066
[02:16:00] Error Description: file does not exist
我觉得这不能算是错嘛,所以我把840行 self.__print_error_json(r) 给注释了,不知道会不会有其他影响;
另外,我发现每次重复upload一个本地夹子,改变了文件没有上传,反而是没有改的文件被覆盖了一遍。所以我找到1417行
if subresult == ENoError and self.__verify_current_file(self.__remote_json, False):
这里应该改成
if subresult == ENoError and self.__verify_current_file(self.__remote_json, False)==0:
还有一处,我在1412行和1413行之间加了一句
self.__current_file_size = getfilesize(lfile)
如果不加的话貌似也有问题。

声明一下我是今天才第一次接触python的语法,此前从没写过,如果是我想错了请忽略上面的话,至少我改过之后在我这里是工作正常的。

其他的地方我还没有测试到。
顺便再说一次,有这个东西简直是太棒了。

你好!

你好,bypy很好用,感谢!

有个问题,bypy.py放入crontab,执行好像有问题,没有办法同步,能否给些建议,谢谢!
我把执行过程记录到bypylog里了.
root@raspberrypi:/home# cat bypylog
Token file: '/root/.bypy.json'
Hash Cache file: '/root/.bypy.pickle'
App root path at Baidu Yun '/apps/bypy'
sys.stdin.encoding = None

sys.stdout.encoding = None

Deletion request '3541667456' OK
Usage 'list' command to confirm
root@raspberrypi:/home#

同步速度可否提高?

我使用的Ubuntu 12.04LTS系统,需要从远端同步大约13GB的文件。使用syncdown经过半小时之后,发现只下载了70MB。根据terminal中的输出,程序每下载1MB都会停止数十秒钟,这个速度太慢了。希望能提高速度。毕竟,同在一个网络中的我的win7系统笔记本上传速度可以达到4MB/s。

这个报错怎么解决呢?

  1. ~ bypy.py cleancache
    Token file: '/home/time/.bypy.json'
    Hash Cache file: '/home/time/.bypy.pickle'
    App root path at Baidu Yun '/apps/bypy'
    sys.stdin.encoding = UTF-8
    sys.stdout.encoding = UTF-8

[13:27:08] Exception occured while getting size of '/home/time/.bypy.pickle'. Exception:
Traceback (most recent call last):
File "/home/time/../bin/bypy.py", line 355, in getfilesize
size = os.path.getsize(path)
File "/usr/lib/python2.7/genericpath.py", line 49, in getsize
return os.stat(filename).st_size
OSError: [Errno 2] No such file or directory: '/home/time/.bypy.pickle'

*** WARNING ***
Hash Cache file '/home/time/.bypy.pickle' is very large (-1B).
This may affect program's performance (high memory consumption).
You can first try to run 'bypy.py cleancache' to slim the file.
But if the file size won't reduce (this warning persists), you may consider deleting / moving the Hash Cache file '/home/time/.bypy.pickle'
*** WARNING ***

SSL certificate verify failed

Uploading file 'README.md'
remote path is '/apps/bypy/README.md'
'README.md' is small and being non-slicing uploaded.
POST https://c.pcs.baidu.com/rest/2.0/pcs/file
actargs: /apps/bypy/README.md
Params: {u'path': u'/apps/bypy/README.md', u'ondup': u'overwrite', u'method': u'upload'}
[18:44:49] Error accessing 'https://c.pcs.baidu.com/rest/2.0/pcs/file'
[18:44:49] Exception: [Errno 1] _ssl.c:504: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
Traceback (most recent call last):
File "./bypy.py", line 810, in __request_work
params = parsnew, timeout = self.__timeout, *_kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 88, in post
return request('post', url, data=data, *_kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 44, in request
return session.request(method=method, url=url, *_kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 383, in request
resp = self.send(prep, *_send_kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 486, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/adapters.py", line 385, in send
raise SSLError(e)
SSLError: [Errno 1] _ssl.c:504: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

无法syncdown

~/c/temp ❯❯❯ bypy list /opt/QIpmsg
Token file: '/home/scinart/.bypy.json'
Hash Cache file: '/home/scinart/.bypy.pickle'
App root path at Baidu Yun '/apps/bypy'
sys.stdin.encoding = UTF-8
sys.stdout.encoding = UTF-8
----

/apps/bypy/opt/QIpmsg ($t $f $s $m $d):
F QIpmsg 15772794 2014-05-24, 00:49:38 ec44a344571e0350a3dfb34a8a73f435
~/c/temp ❯❯❯ bypy syncdown /opt/QIpmsg
Token file: '/home/scinart/.bypy.json'
Hash Cache file: '/home/scinart/.bypy.pickle'
App root path at Baidu Yun '/apps/bypy'
sys.stdin.encoding = UTF-8
sys.stdout.encoding = UTF-8
----

^CSignal 2 received, Abort
Frame:
<frame object at 0x7f547e5da3f0>
~/c/temp ❯❯❯                         

相信我最后是5次超时。类似这种。

<E> [13:00:52] Waiting 10 seconds before retrying...
<E> [13:01:02] Request Try #2 / 5
<E> [13:02:02] Waiting 20 seconds before retrying...
<E> [13:02:22] Request Try #3 / 5
<E> [13:03:22] Waiting 30 seconds before retrying...
<E> [13:03:52] Request Try #4 / 5
<E> [13:04:52] Waiting 40 seconds before retrying...
<E> [13:05:32] Request Try #5 / 5
<E> [13:06:32] Maximum number (5) of tries failed.

bypy list 列出了所有文件(共一个),为什么syncdown不能工作呢?

Problem to download large files

I just tried 2 files: 1 is a very small text file and 1 large video file (>300M).

The text file is downloaded without any problem:

bypy -v -d downfile test.txt
...
<D> Downloading '/apps/bypy/test.txt' as 'test.txt'
<D> Checking if we already have the copy locally
<D> GET https://d.pcs.baidu.com/rest/2.0/pcs/file
<D> actargs: /apps/bypy/test.txt
<D> Params: {u'path': u'/apps/bypy/test.txt', u'method': u'download'}
<D> HTTP Status Code: 200
<D> Request OK, processing action
<D> Request all goes fine
'test.txt' <== '/apps/bypy/test.txt' OK
Not saving Hash Cache since 'dirty' is 'False' and 'force_saving' is 'False'

But the large file cannot be downloaded:

<D> Downloading '/apps/bypy/VIDEO_TSVTS_04_1.VOB' as 'VIDEO_TSVTS_04_1.VOB'
<D> Checking if we already have the copy locally
<D> GET https://d.pcs.baidu.com/rest/2.0/pcs/file
<D> actargs: /apps/bypy/VIDEO_TSVTS_04_1.VOB
<D> Params: {u'path': u'/apps/bypy/VIDEO_TSVTS_04_1.VOB', u'method': u'download'}
<D> HTTP Status Code: 200
<D> Request OK, processing action

The process just stuck here. I checked the local folder and the file was created with size 1048576 bytes. I waited for 5 hours and there is no progress.

If I ctrl-c the process:

^CSignal 2 received, Abort
Frame:
<frame object at 0x607688>
Not saving Hash Cache since 'dirty' is 'False' and 'force_saving' is 'False'

百度網盤上的資料夾未刪除

使用 syncup 同步時, 如果 local 的資料夾及檔案已經刪除.. 百度網盤上的資料夾並不會刪除, 但檔案有刪除. 我是使用類似下面的指令:

./bypy.py syncup /test /test true

关于读权限的问题

上传(以及syncup)一个目录的时候,有些文件没有读权限,能否直接跳过这个文件而不是Permission Denied 然后就停下来呢?

授权回车后无反应

./bypy.py list -d

Token file: '/home/****/.bypy.json'
Hash Cache file: '/home/****/.bypy.pickle'
App root path at Baidu Yun '/apps/bypy'
sys.stdin.encoding = UTF-8
sys.stdout.encoding = UTF-8
----

<E> [14:59:02] Error while loading baidu pcs token:
<E> [14:59:02] Traceback (most recent call last):
  File "./bypy.py", line 905, in __load_local_json
    with open(TokenFilePath, 'rb') as infile:
IOError: [Errno 2] No such file or directory: u'/home/chao/.bypy.json'

Please visit:
https://openapi.baidu.com/oauth/2.0/authorize?scope=basic+netdisk&redirect_uri=oob&response_type=code&client_id=********************
And authorize this app
Paste the Authorization Code here and then press [Enter] within 10 minutes.
ff********************2
<D> auth_code: ff********************2
<D> GET http://bypyoauth.appspot.com/auth
<D> actargs: None
<D> Params: {u'code': 'ff********************2', u'redirect_uri': u'oob'}

openwrt 上跑该脚本 unicode出错

不知为何unicode还是有问题,能否帮忙检查下

OS:openwrt

ENV:
LANG='zh_CN.UTF-8'
LANGUAGE='zh_CN.UTF-8'
LC_ALL='zh_CN.UTF-8'
PYTHONIOENCODING='UTF-8'
TERM='linux'

root@CentiFLY:/mnt/sda3/Downloads# python bypy.py downfile test/测试3d.mp4 -d
Token file: '/root/.bypy.json'
Hash Cache file: '/root/.bypy.pickle'
App root path at Baidu Yun '/apps/bypy'
sys.stdin.encoding = UTF-8

sys.stdout.encoding = UTF-8

Token loaded:
Downloading '/apps/bypy/test/测试3d.mp4' as '测试3d.mp4'
Getting info of remote file '/apps/bypy/test/测试3d.mp4' for later verification
__get_file_info(): rdir : /apps/bypy/test | rfile: 测试3d.mp4
GET https://pcs.baidu.com/rest/2.0/pcs/file
actargs: (u'/apps/bypy/test/\u6d4b\u8bd53d.mp4', {})
Params: {u'path': u'/apps/bypy/test', u'order': u'asc', u'method': u'list', u'by': u'name'}
HTTP Status Code: 200
Request OK, processing action
Request all goes fine
Checking if we already have the copy locally
[21:58:29] Exception occurred:
Traceback (most recent call last):
File "bypy.py", line 2463, in main
result = getattr(by, args.command[0])(*uargs)
File "bypy.py", line 1662, in downfile
result = self.__downfile(pcsrpath, localfile)
File "bypy.py", line 1599, in __downfile
if os.path.isfile(localfile):
File "/usr/lib/python2.7/genericpath.py", line 29, in isfile
st = os.stat(path)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128)

Suggestion

看起来你似乎还要继续改进,提个小小的建议,不知道把3千行的文件模块化怎样, 或者说应该这样,比如core的部分,直接接触api,每个功能,用core,然后客户端,用每个功能。否则,一来不便于他人阅读,二来以后行数越多,越难处理,若以后有时间,可以考虑.

强制从HTTPS下载

用网络工具看,好像文件下载走的是HTTP,这样感觉不是很安全,能不能强制走HTTPS?也许是API的问题。谢谢

bypy 執行錯誤

#712#( 04/19/14@15:20 )( hepha@arch ):~aur/bypy@master✗✗✗

./bypy.py list -v -d
Token file: '/home/hepha/.bypy.json'
Hash Cache file: '/home/hepha/.bypy.pickle'
App root path at Baidu Yun '/apps/bypy'
sys.stdin.encoding = UTF-8
sys.stdout.encoding = UTF-8
Verbose level = 1

Debug = 1

Loading Hash Cache File '/home/hepha/.bypy.pickle'...
Hash Cache File not found, no caching
Token loaded:
{u'access_token': u'21.a6208a4bd2657aa2ac331a361f0520f5.2592000.1400481859.641515757-1572671', u'expires_in': 2592000, u'session_secret': u'8223015a91c64de81769f4e8d701fd52', u'scope': u'basic netdisk', u'session_key': u'9mnRJfB07STfD0TsOhqxGTB8Q01ERGNnBO7iMngwRX2APMXapC+oG7Uvb3O51RP5fFQCpvkdbkmopz79wwNFlHQbT47ueXxA', u'refresh_token': u'22.310ff3ffff464f4147add9800d4dcd2c.315360000.1713249859.641515757-1572671'}
GET https://pcs.baidu.com/rest/2.0/pcs/file
actargs: (u'/apps/bypy', u'$t $f $s $m $d')
Params: {u'path': u'/apps/bypy', u'order': u'asc', u'method': u'list', u'by': u'name'}
HTTP Status Code: 200
Request OK, processing action
/apps/bypy ($t $f $s $m $d):
Request all goes fine
Not saving Hash Cache since 'dirty' is 'False' and 'force_saving' is 'False'

使用syncup 和 syncdown

写了一个定期备份的脚本,
然后将备份的数据同步到云端
bypy syncup 有什么参数可以只增量更新吗 ?
bypy syncdown 是不是也应该有一个参数只down 增量吧

可不可以有ignore命令

整个文件夹下,有一个无用的隐藏文件夹不想上传

可不可以做成像.gitignore一样的模式,不同步某些文件/文件夹

认证失败。(已使用代理)

auth_code: 11cd4ef6581ed58b996fa3919743a543
Authorizing, please be patient, it may take upto 60.0 seconds...
GET https://bypyoauth.appspot.com/auth
actargs: None
Params: {u'code': '11cd4ef6581ed58b996fa3919743a543', u'redirect_uri': u'oob'}
HTTP Status Code: 200
Request OK, processing action
[06:19:46] Error accessing 'https://bypyoauth.appspot.com/auth'
[06:19:46] Exception: 'dict' object is not callable
Traceback (most recent call last):
File "./bypy.py", line 823, in __request_work
result = act(r, actargs)
File "./bypy.py", line 951, in __server_auth_act
return self.__store_json(r)
File "./bypy.py", line 948, in __store_json
return self.__store_json_only(r.json())
TypeError: 'dict' object is not callable

[06:19:46] Function: __server_auth_act
[06:19:46] Website parameters: {u'code': '11cd4ef6581ed58b996fa3919743a543', u'redirect_uri': u'oob'}
[06:19:46] HTTP Status Code: 200
[06:19:46] Error parsing JSON Error Code from:
{"expires_in":2592000,"refresh_token":"xxx","access_token":"xxx","session_secret":"xxx","session_key":"xxx","scope":"basic netdisk"}

[06:19:46] Exception: Traceback (most recent call last):
File "./bypy.py", line 765, in __print_error_json
dj = r.json()
TypeError: 'dict' object is not callable

[06:19:46] Website returned: {"expires_in":2592000,"refresh_token":"xxx","access_token":"xxx","session_secret":"xxx","session_key":"xxx","scope":"basic netdisk"}

[06:19:46] Fatal Exception.
Quitting...

Not saving Hash Cache since 'dirty' is 'False' and 'force_saving' is 'False'

程序不认UTF8编码,只认UTF-8编码

在Centos 6.5 X86_64下设置LANG=en_US.UTF-8后python local.getdefaultlocale取得的什是UTF8而不是UTF-8,所以系统提示“You MUST set system locale to 'UTF-8' to support unicode file names.”
centos下python版本为2.6.6

请问 如果有些文件传一半断了,那第二次运行时该如何操作?

难道是先 bypy.py compare dest src , 然后肉眼看下哪些不同,然后再次运行 bypy.py upload srt dest 这样去覆盖?(因为默认是覆盖)但是我有好多断掉的,有点麻烦(我觉得大概自己来一串linux命令 用各种 grep xargs cut 等拼成单行命令... 或者写个shell script可以做到,还没试出来)

有没有upload 来个什么参数,能发现hash不同就自动覆盖的?

md5不匹配?

下载几个大小均超过1G的压缩包, 下载完成时的md5计算结果与调试信息中提供的均不相同, 但是解压缩文件时提示无校验错误.
另外中途断开再续传似乎几乎每次都会损坏.

shebang line 建议改下?

#!/usr/bin/python

->

#!/usr/bin/env python

我是用的 virtualenv 的2.7 , 系统只有2.6 没权限装软件 ...

centos上出错

报错信息:
[root@syshack bypy]# ./bypy.py -v -d
Traceback (most recent call last):
File "./bypy.py", line 2502, in
main()
File "./bypy.py", line 2473, in main
perr("Exception occurred:")
File "./bypy.py", line 227, in perr
return plog(' ', msg, showtime, showdate, prefix, suffix)
File "./bypy.py", line 222, in plog
pr("{}{}".format(tag, msg))
ValueError: zero length field name in format

环境:centos 6.3 python 2.6.6

無法使用bypy.py

我是用wget下載".gitignore"、"LICENSE"、"README.md"、"bypy.py"、"bypygui.pyw"
這五個檔案到/usr/share/bypy目錄底下,執行python ./bypy.py出現以下結果

File "./bypy.py", line 6

^
SyntaxError: invalid syntax

試過dos2unix bypy.py,也試過用WINDOWS下載後丟到這個資料夾,一樣都會出現這個問題

错误讯息怪怪的

我执行下面的指令将 local 的档案同步到百度云网盘..

./bypy.py -v -e -f syncup /tmp/test/ /test/ true

但是出现如下的讯息:

[16:39:01] file md5 not found, you should use upload api to upload the whole file.

'/tmp/test/test.flac' >>==> '/apps/bypy/test/test.flac' OK.
[============= ] 65% (20.0MB/30.562MB) ETA: 48s '/tmp/test/test.flac' >>==> '/apps/bypy/test/test.flac' OK.
[====================] 100% (30.562MB/30.562MB) ETA: Combining the following MD5 slices:
ad334e921794eac127b8fab7a0fd879f
4c32fa8d0725f867a176ce8667424c78
[16:41:50] Local file and remote file hashes DON'T match
[16:41:50] '/tmp/test/test.flac' =C=> '/apps/bypy/test/test.flac' FAILED.
Saving Hash Cache...
Hash Cache saved.

从讯息来看, 档案应该有上传到网盘.. 实际上我直接连到百度去看, 确实有这个档案。而且下载回来比对档案的内容也正确.. 但是同步时, 为什么会出现下面这二行讯息呢?看起来是档案没有上传成功.. 是不是某个地方弄错了?

[16:41:50] Local file and remote file hashes DON'T match
[16:41:50] '/tmp/test/test.flac' =C=> '/apps/bypy/test/test.flac' FAILED.

__downchunks_act() 的问题

这个函数里有以下语句:
pos = f.tell()
pprgr(pos, rsize, start_time)
if pos - offset == self.__dl_chunk_size:
return ENoError
else:
return EFileWrite
因为每个文件最后的数据块长度一般都不会是chunk size,这样每个文件都会返回EFileWrite,导致__downchunks里的验证逻辑被跳过。是个bug吗?

用bypy upload XXX XXX -v上传文件时且为rapid upload时,若远程无相应文件,则log有冗余信息。

<I> [19:37:58] file does not exist
<E> [19:37:58] Error accessing 'https://pcs.baidu.com/rest/2.0/pcs/file'
None

<E> [19:37:58] Function: __get_file_info_act
<E> [19:37:58] Website parameters: {u'path': u'/apps/bypy/XXX/XXX/XXX/XXX/', u'order': u'asc', u'method': u'list', u'by': u'name'}
RapidUpload: 'XXXXXXXXXXXXXXXXXXXXXX' =R=> 'XXXXXXXXXXXXX' OK.

如果不是Rapid Upload的话,那么这些<I><E>都没有。
我认为这个<E>不应该出现,请问houtianze能否确认这个bug。

在 centos 上面 遇到问题了

[root@cent64 ~]# ./bypy.py -v
Traceback (most recent call last):
File "./bypy.py", line 2503, in
main()
File "./bypy.py", line 2474, in main
perr("Exception occurred:")
File "./bypy.py", line 228, in perr
return plog(' ', msg, showtime, showdate, prefix, suffix)
File "./bypy.py", line 223, in plog
pr("{}{}".format(tag, msg))
ValueError: zero length field name in format

不管带不带 命令, 都报这个错误

31079错误有办法解决么?

[11:17:30] Error code: 31079
[11:17:30] Error Description: file md5 not found, you should use upload api to upload the whole file.

貌似授权被墙

Authorizing, please be patient, it may take upto 60.0 seconds...
[07:20:56] Maximum number (1) of tries failed.
I think you are WALLed, trying OpenShift server to auth...
[07:21:01] Exception occurred:
Traceback (most recent call last):
File "./bypy.py", line 2583, in main
result = getattr(by, args.command[0])(*uargs)
TypeError: help() takes exactly 2 arguments (1 given)

Abort

授权不了,需要手动越墙么?

Authorizing, please be patient, it may take upto 60.0 seconds...
[09:23:38] Maximum number (1) of tries failed.
I think you are WALLed, trying OpenShift server to auth...
[09:23:54] Fatal Exception.
Quitting...

syncdown 的 speed 值是错的

类似下面这样.. 几GB/s 甚至是几十GB/s. 呵呵,我的网速不可能有这种速度。

[======= ] 38% (13.0MB/34.046MB) ETA: (Speed: 6.870GB/s, Elapsed: 0.002)

下载文件夹,同步文件夹速度较慢

我在使用的过程中发现用 downdir 指令下载整个文件夹时,速度不稳定。在下载一个文件夹时,整个文件夹一共25个文件,总共34G。
第一第二个文件下载速度很快,但是在第四个文件之后,速度奇慢,下面是ifstat的结果

       eth0       
 KB/s in  KB/s out
  262.18      5.37
    3.16      0.28
    0.06      0.13
    0.06      0.13
    0.06      0.13
    0.06      0.13
    0.06      0.13
    0.06      0.13
    0.12      0.17
  186.50      3.92
   78.83      1.60
    0.06      0.13
    0.06      0.13
    0.06      0.13
    0.08      0.13
    0.06      0.13
    0.75      0.13
    0.66      0.13
  265.57      5.39
    0.06      0.13
    0.37      0.13
    0.06      0.13
    0.06      0.13
    0.06      0.13
    0.37      0.13
    0.06      0.13
  215.63      4.44
   49.70      1.07
    0.06      0.13
    0.06      0.13
    0.06      0.13
    0.06      0.13
    0.06      0.13
    0.06      0.13
   88.91      2.13
  176.42      3.39
    0.06      0.13
    0.12      0.17
    0.06      0.13
    0.06      0.13
    0.06      0.13
    0.06      0.13
    0.06      0.13
   20.46      0.86

可以看到后续的下载速度十分不稳定。查阅了源码__downfile_act部分后发现你可能是使用python来作为原生的下载工具,不知我有没有看错-_-||。
建议如果采用 aria2 或者 wget的话,对于下载部分的稳定性应该能有所提升。

如何list云端其他目录的文件

如何list 其它云端目录的文件

还有部分命令,opensuse 下面,好像,不能用

xx@linux-m13:/disk1/yunpay/bypy-master> bypy.py help
UTF-8
Token file: '/home/xx/.bypy.json'
Hash Cache file: '/home/xx/.bypy.pickle'
App root path at Baidu Yun '/apps/bypy'
sys.stdin.encoding = UTF-8

sys.stdout.encoding = UTF-8

[13:22:35] Exception occurred:
Traceback (most recent call last):
File "/home/xx/bin/bypy/bypy.py", line 2584, in main
result = getattr(by, args.command[0])(*uargs)
TypeError: help() takes exactly 2 arguments (1 given)

bypy.py upload
[13:23:59] Error code: 31061
Error Description: file already exists

能不能有重试功能

好像经常运行几个小时发现程序挂了,大部分是socket receive timeout exception。能不能有自动重试的功能,因为一般都是离线操作的,不能随时盯着。谢谢!

error

File "/root/下载/bypy-master/bypy.py", line 2503, in
main()
File "/root/下载/bypy-master/bypy.py", line 2474, in main
perr("Exception occurred:")
File "/root/下载/bypy-master/bypy.py", line 228, in perr
return plog(' ', msg, showtime, showdate, prefix, suffix)
File "/root/下载/bypy-master/bypy.py", line 223, in plog
pr("{}{}".format(tag, msg))

ValueError: zero length field name in format

使用自己的appid出错

Token file: '/root/.bypy.json'
Hash Cache file: '/root/.bypy.pickle'
App root path at Baidu Yun '/apps/wifiap'
sys.stdin.encoding = UTF-8

sys.stdout.encoding = UTF-8

[12:58:00] Error while loading baidu pcs token:
[12:58:00] Traceback (most recent call last):
File "bypy.py", line 908, in __load_local_json
with open(TokenFilePath, 'rb') as infile:
IOError: [Errno 2] No such file or directory: u'/root/.bypy.json'

GET https://openapi.baidu.com/oauth/2.0/device/code
actargs: None
Params: {u'scope': u'basic netdisk', u'response_type': u'device_code', u'client_id': u'xxx'}
HTTP Status Code: 200
Request OK, processing action
Please visit:
https://openapi.baidu.com/device within 1800 seconds
Input the CODE: zt6u37jq
and Authorize this little app.
Press [Enter] when you've finished
GET https://openapi.baidu.com/oauth/2.0token
actargs: None
Params: {u'code': u'40dc1674e79fa253706a6ed834d573db', u'client_secret': u'xxxxxxxx', u'grant_type': u'device_token', u'client_id': u'xxxxxx'}
HTTP Status Code: 200
Request OK, processing action
[12:58:20] Error accessing 'https://openapi.baidu.com/oauth/2.0token'
[12:58:20] Exception: No JSON object could be decoded
Traceback (most recent call last):
File "bypy.py", line 817, in **request_work
result = act(r, actargs)
File "bypy.py", line 974, in __get_token_act
return self.__store_json(r)
File "bypy.py", line 935, in __store_json
return self.__store_json_only(r.json())
File "/usr/local/lib/python2.7/dist-packages/requests/models.py", line 741, in json
return json.loads(self.text, kwargs)
File "/usr/lib/python2.7/json/__init
.py", line 326, in loads
return _default_decoder.decode(s)
File "/usr/lib/python2.7/json/decoder.py", line 365, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python2.7/json/decoder.py", line 383, in raw_decode
raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

[12:58:20] Function: **get_token_act
[12:58:20] Website parameters: {u'code': u'40dc1674e79fa253706a6ed834d573db', u'client_secret': u'xxxxxx', u'grant_type': u'device_token', u'client_id': u'xxxxxxx'}
[12:58:20] HTTP Status Code: 200
[12:58:20] Error parsing JSON Error Code from
[12:58:20] Exception: Traceback (most recent call last):
File "bypy.py", line 759, in __print_error_json
dj = r.json()
File "/usr/local/lib/python2.7/dist-packages/requests/models.py", line 741, in json
return json.loads(self.text, kwargs)
File "/usr/lib/python2.7/json/__init
.py", line 326, in loads
return _default_decoder.decode(s)
File "/usr/lib/python2.7/json/decoder.py", line 365, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python2.7/json/decoder.py", line 383, in raw_decode
raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

无法使用

Authorizing, please be patient, it may take upto 60.0 seconds...
Successfully authorized
/apps/bypy ($t $f $s $m $d):
ygc@ygc-OptiPlex-9010:~/downloads/bypy-master$ ./bypy.py list
Token file: '/home/ygc/.bypy.json'
Hash Cache file: '/home/ygc/.bypy.pickle'
App root path at Baidu Yun '/apps/bypy'
sys.stdin.encoding = UTF-8

sys.stdout.encoding = UTF-8

/apps/bypy ($t $f $s $m $d):

所有命令都出不来东西。

我的运行环境是:
ygc@ygc-OptiPlex-9010:/downloads/bypy-master$ python --version
Python 2.7.6
ygc@ygc-OptiPlex-9010:
/downloads/bypy-master$ uname -a
Linux ygc-OptiPlex-9010 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

不支持断点续传

同步的时候中断后,再同步出现错误

[16:59:13] Exception occurred:
Traceback (most recent call last):
File "bypy.py", line 2400, in main
result = getattr(by, args.command[0])(*uargs)
File "bypy.py", line 1601, in downfile
result = self.__downfile(pcsrpath, localfile)
File "bypy.py", line 1554, in __downfile
if ENoError == self.__verify_current_file(self.__remote_json, False):
AttributeError: 'ByPy' object has no attribute '_ByPy__remote_json'

Abort

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.