Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
筑梦之路
bypy
提交
be7c9a23
B
bypy
项目概览
筑梦之路
/
bypy
与 Fork 源项目一致
从无法访问的项目Fork
通知
4
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
B
bypy
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
be7c9a23
编写于
3月 08, 2018
作者:
H
Hou Tianze
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix #285: list() capped at 1000 files maximum per directory
上级
c1185ea1
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
47 addition
and
12 deletion
+47
-12
bypy/bypy.py
bypy/bypy.py
+15
-9
bypy/const.py
bypy/const.py
+1
-0
bypy/test/configdir/bypy.setting.json
bypy/test/configdir/bypy.setting.json
+1
-1
bypy/test/test.py
bypy/test/test.py
+30
-2
未找到文件。
bypy/bypy.py
浏览文件 @
be7c9a23
...
...
@@ -689,7 +689,7 @@ class ByPy(object):
self
.
pd
(
"206 Partial Content (this is OK), processing action"
)
result
=
act
(
r
,
actargs
)
if
result
==
const
.
ENoError
:
self
.
pd
(
"Request OK
.
"
)
self
.
pd
(
"Request OK"
)
else
:
ec
=
self
.
__get_json_errorcode
(
r
,
act
)
# 6 (sc: 403): No permission to access user data
...
...
@@ -2144,16 +2144,22 @@ To stream a file, you can use the 'mkfifo' trick with omxplayer etc.:
return
const
.
ENoError
def
__walk_remote_dir
(
self
,
remotepath
,
remoterootpath
,
args
=
None
,
skip_remote_only_dirs
=
False
):
pars
=
{
'method'
:
'list'
,
'path'
:
remotepath
,
'by'
:
'name'
,
'order'
:
'asc'
}
# Python parameters are by-reference and mutable, so they are 'out' by default
dirjs
=
[]
filejs
=
[]
result
=
self
.
__get
(
pcsurl
+
'file'
,
pars
,
self
.
__walk_proceed_remote_dir_act
,
(
dirjs
,
filejs
))
listStart
=
0
# https://github.com/houtianze/bypy/issues/285
while
True
:
pars
=
{
'method'
:
'list'
,
'path'
:
remotepath
,
'by'
:
'name'
,
'order'
:
'asc'
,
'limit'
:
'{}-{}'
.
format
(
listStart
,
listStart
+
const
.
MaxListEntries
)}
# Python parameters are by-reference and mutable, so they are 'out' by default
result
=
self
.
__get
(
pcsurl
+
'file'
,
pars
,
self
.
__walk_proceed_remote_dir_act
,
(
dirjs
,
filejs
))
if
len
(
dirjs
)
+
len
(
filejs
)
-
listStart
<
const
.
MaxListEntries
:
break
listStart
+=
const
.
MaxListEntries
yield
[
result
,
remotepath
,
dirjs
,
filejs
,
args
]
if
result
==
const
.
ENoError
:
self
.
pd
(
"Remote dirs: {}"
.
format
(
dirjs
))
...
...
bypy/const.py
浏览文件 @
be7c9a23
...
...
@@ -159,6 +159,7 @@ DPcsUrl = 'https://d.pcs.baidu.com/rest/2.0/pcs/'
MinRapidUploadFileSize
=
256
*
OneK
MaxSliceSize
=
2
*
OneG
MaxSlicePieces
=
1024
MaxListEntries
=
1000
# https://github.com/houtianze/bypy/issues/285
### Auth servers
GaeUrl
=
'https://bypyoauth.appspot.com'
...
...
bypy/test/configdir/bypy.setting.json
浏览文件 @
be7c9a23
{
"lastUpdateCheck"
:
15
16271227
,
"lastUpdateCheck"
:
15
20267575
,
"overwriteRemoteTempDir"
:
true
}
\ No newline at end of file
bypy/test/test.py
浏览文件 @
be7c9a23
...
...
@@ -15,6 +15,7 @@ from __future__ import division
import
sys
import
os
import
shutil
import
tempfile
import
re
import
pprint
import
copy
...
...
@@ -197,10 +198,10 @@ def assertsame(by):
assert
len
(
by
.
result
[
'remote'
])
==
0
assert
len
(
by
.
result
[
'same'
])
>=
5
def
compare
(
by
):
def
compare
(
by
,
left
=
TestDir
,
right
=
TestDir
):
# comparison
banner
(
"Comparing"
)
assert
by
.
compare
(
TestDir
,
TestDir
)
==
const
.
ENoError
assert
by
.
compare
(
left
,
right
)
==
const
.
ENoError
assertsame
(
by
)
mpr
.
empty
()
...
...
@@ -274,6 +275,28 @@ def testshare(by):
assertsingle
(
by
,
filterregex
(
mpr
.
getq
(),
r
"bypy accept /{}/subdir/1M2.bin"
.
format
(
ShareDir
)))
mpr
.
empty
()
def
createmanyfiles
(
dir
,
numFiles
):
shutil
.
rmtree
(
dir
,
ignore_errors
=
True
)
os
.
makedirs
(
dir
)
for
i
in
range
(
0
,
numFiles
):
fname
=
str
(
i
).
zfill
(
4
)
ffname
=
os
.
path
.
join
(
dir
,
fname
)
with
open
(
ffname
,
'w'
)
as
f
:
f
.
write
(
fname
)
def
testmanyfiles
(
by
):
pass
# def testmanyfiles(by):
# numFiles = const.MaxListEntries * 2 + 10
# banner("Test uploading of many ({}) files".format(numFiles))
# with tempfile.TemporaryDirectory(prefix = 'bypytest_') as tmpdir:
# print("Testing temp dir: ", tmpdir)
# createmanyfiles(tmpdir, numFiles)
# by.upload(tmpdir, tmpdir)
# compare(by, tmpdir, tmpdir)
# mpr.empty()
def
cleanup
():
os
.
remove
(
zerofilename
)
#shutil.rmtree(ConfigDir, ignore_errors=True)
...
...
@@ -309,6 +332,11 @@ def main():
by
=
bypy
.
ByPy
(
configdir
=
ConfigDir
,
debug
=
1
,
verbose
=
1
)
if
'refresh'
in
sys
.
argv
:
by
.
refreshtoken
()
if
'many'
in
sys
.
argv
:
testmanyfiles
(
by
)
return
runTests
(
by
)
if
'1'
in
sys
.
argv
:
return
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录