Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
喜羊羊3508
Dak
提交
bad93415
D
Dak
项目概览
喜羊羊3508
/
Dak
8 个月 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Dak
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
bad93415
编写于
9月 22, 2020
作者:
😸
😸
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
generate-index-diffs: use subprocess module instead of `os.system`, `os.popen`
上级
be42136d
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
32 addition
and
36 deletion
+32
-36
dak/generate_index_diffs.py
dak/generate_index_diffs.py
+32
-36
未找到文件。
dak/generate_index_diffs.py
浏览文件 @
bad93415
...
...
@@ -39,6 +39,8 @@ import tempfile
import
time
import
apt_pkg
import
daklib.daksubprocess
from
daklib
import
utils
from
daklib.dbconn
import
Archive
,
Component
,
DBConn
,
Suite
,
get_suite
,
get_suite_architectures
#from daklib.regexes import re_includeinpdiff
...
...
@@ -85,41 +87,47 @@ def smartstat(file):
def
smartlink
(
f
,
t
):
def
call_decompressor
(
cmd
,
inpath
,
outpath
):
return
daklib
.
daksubprocess
.
check_call
(
cmd
,
stdin
=
open
(
inpath
,
"rb"
),
stdout
=
open
(
outpath
,
"wb"
),
)
if
os
.
path
.
isfile
(
f
):
os
.
link
(
f
,
t
)
elif
os
.
path
.
isfile
(
"%s.gz"
%
(
f
)):
os
.
system
(
"gzip -d < %s.gz > %s"
%
(
f
,
t
)
)
call_decompressor
([
'gzip'
,
'-d'
],
'{}.gz'
.
format
(
f
),
t
)
elif
os
.
path
.
isfile
(
"%s.bz2"
%
(
f
)):
os
.
system
(
"bzip2 -d < %s.bz2 > %s"
%
(
f
,
t
)
)
call_decompressor
([
'bzip2'
,
'-d'
],
'{}.bz2'
.
format
(
f
),
t
)
elif
os
.
path
.
isfile
(
"%s.xz"
%
(
f
)):
os
.
system
(
"xz -d < %s.xz > %s"
%
(
f
,
t
)
)
call_decompressor
([
'xz'
,
'-d'
],
'{}.xz'
.
format
(
f
),
t
)
else
:
print
(
"missing: %s"
%
(
f
))
raise
IOError
(
f
)
def
smartopen
(
file
):
def
call_decompressor
(
cmd
,
inpath
):
fh
=
tempfile
.
TemporaryFile
(
"w+t"
)
daklib
.
daksubprocess
.
check_call
(
cmd
,
stdin
=
open
(
inpath
,
"rb"
),
stdout
=
fh
,
)
fh
.
seek
(
0
)
return
fh
if
os
.
path
.
isfile
(
file
):
f
=
open
(
file
,
"r"
)
return
open
(
file
,
"r"
)
elif
os
.
path
.
isfile
(
"%s.gz"
%
file
):
f
=
create_temp_file
(
os
.
popen
(
"zcat %s.gz"
%
file
,
"r"
))
return
call_decompressor
([
'zcat'
],
'{}.gz'
.
format
(
file
))
elif
os
.
path
.
isfile
(
"%s.bz2"
%
file
):
f
=
create_temp_file
(
os
.
popen
(
"bzcat %s.bz2"
%
file
,
"r"
))
return
call_decompressor
([
'bzcat'
],
'{}.bz2'
.
format
(
file
))
elif
os
.
path
.
isfile
(
"%s.xz"
%
file
):
f
=
create_temp_file
(
os
.
popen
(
"xzcat %s.xz"
%
file
,
"r"
))
return
call_decompressor
([
'xzcat'
],
'{}.xz'
.
format
(
file
))
else
:
f
=
None
return
f
def
pipe_file
(
f
,
t
):
f
.
seek
(
0
)
while
True
:
l
=
f
.
read
(
65536
)
if
not
l
:
break
t
.
write
(
l
)
t
.
close
()
return
None
class
Updates
:
...
...
@@ -252,20 +260,6 @@ class Updates:
out
.
write
(
" %s %7d %s.gz
\n
"
%
(
hs
[
h
][
2
][
2
],
hs
[
h
][
2
][
0
],
h
))
def
create_temp_file
(
r
):
f
=
tempfile
.
TemporaryFile
(
"w+t"
)
while
True
:
x
=
r
.
read
(
65536
)
if
not
x
:
break
f
.
write
(
x
)
r
.
close
()
del
x
,
r
f
.
flush
()
f
.
seek
(
0
)
return
f
def
sizehashes
(
f
):
size
=
os
.
fstat
(
f
.
fileno
())[
6
]
f
.
seek
(
0
)
...
...
@@ -336,9 +330,11 @@ def genchanges(Options, outdir, oldfile, origfile, maxdiffs=56):
if
not
os
.
path
.
isdir
(
outdir
):
os
.
mkdir
(
outdir
)
w
=
os
.
popen
(
"diff --ed - %s | gzip --rsyncable --no-name -c -9 > %s.gz"
%
(
newfile
,
difffile
),
"w"
)
pipe_file
(
oldf
,
w
)
with
open
(
"{}.gz"
.
format
(
difffile
),
"wb"
)
as
fh
:
daklib
.
daksubprocess
.
check_call
(
"diff --ed - {} | gzip --rsyncable --no-name -c -9"
.
format
(
newfile
),
shell
=
True
,
stdin
=
oldf
,
stdout
=
fh
)
oldf
.
close
()
difff
=
smartopen
(
difffile
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录