Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
喜羊羊3508
Dak
提交
1d79ca7f
D
Dak
项目概览
喜羊羊3508
/
Dak
12 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
1d79ca7f
编写于
5月 05, 2008
作者:
J
Joerg Jaspert
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Exception handling
上级
f86fb53a
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
48 addition
and
51 deletion
+48
-51
ChangeLog
ChangeLog
+7
-3
dak/check_archive.py
dak/check_archive.py
+1
-1
dak/generate_releases.py
dak/generate_releases.py
+2
-1
dak/import_archive.py
dak/import_archive.py
+3
-2
dak/process_unchecked.py
dak/process_unchecked.py
+14
-14
dak/rm.py
dak/rm.py
+2
-1
daklib/queue.py
daklib/queue.py
+2
-1
daklib/utils.py
daklib/utils.py
+17
-28
未找到文件。
ChangeLog
浏览文件 @
1d79ca7f
2008
-
05
-
05
Joerg
Jaspert
<
joerg
@
debian
.
org
>
*
dak
/
queue_report
.
py
:
Use
the
exception
class
*
dak
/
process_unchecked
.
py
:
dito
*
daklib
/
dak_exceptions
.
py
:
New
file
,
central
place
for
all
those
own
exceptions
dak
may
raise
.
*
daklib
/
utils
.
py
:
Use
dak_exceptions
and
delete
all
those
string
exception
raising
stuff
,
which
is
depcreated
.
During
that
delete
the
unknown_hostname_exc
,
as
it
wasnt
used
.
*
dak
/
import_archive
.
py
:
use
the
new
Exception
class
*
dak
/
rm
.
py
:
dito
*
dak
/
generate_releases
.
py
:
dito
*
dak
/
queue_report
.
py
:
dito
*
daklib
/
queue
.
py
:
dito
2008
-
05
-
04
Joerg
Jaspert
<
joerg
@
debian
.
org
>
...
...
dak/check_archive.py
浏览文件 @
1d79ca7f
...
...
@@ -132,7 +132,7 @@ def check_dscs():
f
=
line
[:
-
1
]
try
:
utils
.
parse_changes
(
f
,
signing_rules
=
1
)
except
utils
.
invalid_dsc_format_exc
,
line
:
except
InvalidDscError
,
line
:
utils
.
warn
(
"syntax error in .dsc file '%s', line %s."
%
(
f
,
line
))
count
+=
1
...
...
dak/generate_releases.py
浏览文件 @
1d79ca7f
...
...
@@ -25,6 +25,7 @@
import
sys
,
os
,
popen2
,
tempfile
,
stat
,
time
,
pg
import
apt_pkg
import
daklib.utils
as
utils
from
daklib.exceptions
import
*
################################################################################
...
...
@@ -107,7 +108,7 @@ def print_md5sha_files (tree, files, hashop):
else
:
size
=
os
.
stat
(
path
+
name
)[
stat
.
ST_SIZE
]
file_handle
=
utils
.
open_file
(
path
+
name
)
except
utils
.
cant_open_exc
:
except
CantOpenError
:
print
"ALERT: Couldn't open "
+
path
+
name
else
:
hash
=
hashop
(
file_handle
)
...
...
dak/import_archive.py
浏览文件 @
1d79ca7f
...
...
@@ -40,6 +40,7 @@ import commands, os, pg, re, sys, time
import
apt_pkg
import
daklib.database
as
database
import
daklib.utils
as
utils
from
daklib.exceptions
import
*
###############################################################################
...
...
@@ -323,7 +324,7 @@ def process_sources (filename, suite, component, archive):
suite_id
=
database
.
get_suite_id
(
suite
)
try
:
file
=
utils
.
open_file
(
filename
)
except
utils
.
cant_open_exc
:
except
CantOpenError
:
utils
.
warn
(
"can't open '%s'"
%
(
filename
))
return
Scanner
=
apt_pkg
.
ParseTagFile
(
file
)
...
...
@@ -406,7 +407,7 @@ def process_packages (filename, suite, component, archive):
suite_id
=
database
.
get_suite_id
(
suite
)
try
:
file
=
utils
.
open_file
(
filename
)
except
utils
.
cant_open_exc
:
except
CantOpenError
:
utils
.
warn
(
"can't open '%s'"
%
(
filename
))
return
Scanner
=
apt_pkg
.
ParseTagFile
(
file
)
...
...
dak/process_unchecked.py
浏览文件 @
1d79ca7f
...
...
@@ -182,19 +182,19 @@ def check_changes():
# Parse the .changes field into a dictionary
try
:
changes
.
update
(
utils
.
parse_changes
(
filename
))
except
utils
.
cant_open_exc
:
except
CantOpenError
:
reject
(
"%s: can't read file."
%
(
filename
))
return
0
except
utils
.
changes_parse_error_exc
,
line
:
except
ParseChangesError
,
line
:
reject
(
"%s: parse error, can't grok: %s."
%
(
filename
,
line
))
return
0
# Parse the Files field from the .changes into another dictionary
try
:
files
.
update
(
utils
.
build_file_list
(
changes
))
except
utils
.
changes_parse_error_exc
,
line
:
except
ParseChangesError
,
line
:
reject
(
"%s: parse error, can't grok: %s."
%
(
filename
,
line
))
except
utils
.
nk_format_exc
,
format
:
except
UnknownFormatError
,
format
:
reject
(
"%s: unknown format '%s'."
%
(
filename
,
format
))
return
0
...
...
@@ -686,21 +686,21 @@ def check_dsc():
# Parse the .dsc file
try
:
dsc
.
update
(
utils
.
parse_changes
(
dsc_filename
,
signing_rules
=
1
))
except
utils
.
cant_open_exc
:
except
CantOpenError
:
# if not -n copy_to_holding() will have done this for us...
if
Options
[
"No-Action"
]:
reject
(
"%s: can't read file."
%
(
dsc_filename
))
except
utils
.
changes_parse_error_exc
,
line
:
except
ParseChangesError
,
line
:
reject
(
"%s: parse error, can't grok: %s."
%
(
dsc_filename
,
line
))
except
utils
.
invalid_dsc_format_exc
,
line
:
except
InvalidDscError
,
line
:
reject
(
"%s: syntax error on line %s."
%
(
dsc_filename
,
line
))
# Build up the file list of files mentioned by the .dsc
try
:
dsc_files
.
update
(
utils
.
build_file_list
(
dsc
,
is_a_dsc
=
1
))
except
utils
.
no_files_exc
:
except
NoFilesFieldError
:
reject
(
"%s: no Files: field."
%
(
dsc_filename
))
return
0
except
utils
.
changes_parse_error_exc
,
line
:
except
ParseChangesError
,
line
:
reject
(
"%s: parse error, can't grok: %s."
%
(
dsc_filename
,
line
))
return
0
...
...
@@ -946,9 +946,9 @@ def check_hashes ():
try
:
fs
=
utils
.
build_file_list
(
changes
,
0
,
"checksums-%s"
%
h
,
h
)
check_hash
(
".changes %s"
%
(
h
),
fs
,
h
,
f
,
files
)
except
utils
.
no_files_exc
:
except
NoFilesFieldError
:
reject
(
"No Checksums-%s: field in .changes"
%
(
h
))
except
utils
.
changes_parse_error_exc
,
line
:
except
ParseChangesError
,
line
:
reject
(
"parse error for Checksums-%s in .changes, can't grok: %s."
%
(
h
,
line
))
if
"source"
not
in
changes
[
"architecture"
]:
continue
...
...
@@ -956,9 +956,9 @@ def check_hashes ():
try
:
fs
=
utils
.
build_file_list
(
dsc
,
1
,
"checksums-%s"
%
h
,
h
)
check_hash
(
".dsc %s"
%
(
h
),
fs
,
h
,
f
,
dsc_files
)
except
utils
.
no_files_exc
:
except
NoFilesFieldError
:
reject
(
"No Checksums-%s: field in .dsc"
%
(
h
))
except
utils
.
changes_parse_error_exc
,
line
:
except
ParseChangesError
,
line
:
reject
(
"parse error for Checksums-%s in .dsc, can't grok: %s."
%
(
h
,
line
))
################################################################################
...
...
@@ -975,7 +975,7 @@ def check_hash (where, lfiles, key, testfn, basedict = None):
try
:
file_handle
=
utils
.
open_file
(
f
)
except
utils
.
cant_open_exc
:
except
CantOpenError
:
continue
# Check hash
...
...
dak/rm.py
浏览文件 @
1d79ca7f
...
...
@@ -43,6 +43,7 @@ import commands, os, pg, re, sys
import
apt_pkg
,
apt_inst
import
daklib.database
as
database
import
daklib.utils
as
utils
from
daklib.exceptions
import
*
################################################################################
...
...
@@ -364,7 +365,7 @@ def main ():
filename
=
"/"
.
join
(
source_packages
[
i
])
try
:
dsc
=
utils
.
parse_changes
(
filename
)
except
utils
.
cant_open_exc
:
except
CantOpenError
:
utils
.
warn
(
"couldn't open '%s'."
%
(
filename
))
continue
for
package
in
dsc
.
get
(
"binary"
).
split
(
','
):
...
...
daklib/queue.py
100644 → 100755
浏览文件 @
1d79ca7f
...
...
@@ -22,6 +22,7 @@
import
cPickle
,
errno
,
os
,
pg
,
re
,
stat
,
sys
,
time
import
apt_inst
,
apt_pkg
import
utils
,
database
from
dak_exceptions
import
*
from
types
import
*
...
...
@@ -615,7 +616,7 @@ distribution."""
morgue_file
=
os
.
path
.
join
(
Cnf
[
"Dir::Morgue"
],
Cnf
[
"Dir::MorgueReject"
],
file_entry
)
try
:
morgue_file
=
utils
.
find_next_free
(
morgue_file
)
except
utils
.
tried_too_hard_exc
:
except
NoFreeFilenameError
:
# Something's either gone badly Pete Tong, or
# someone is trying to exploit us.
utils
.
warn
(
"**WARNING** failed to move %s from the reject directory to the morgue."
%
(
file_entry
))
...
...
daklib/utils.py
浏览文件 @
1d79ca7f
...
...
@@ -49,17 +49,6 @@ re_verwithext = re.compile(r"^(\d+)(?:\.(\d+))(?:\s+\((\S+)\))?$")
re_srchasver
=
re
.
compile
(
r
"^(\S+)\s+\((\S+)\)$"
)
changes_parse_error_exc
=
"Can't parse line in .changes file"
invalid_dsc_format_exc
=
"Invalid .dsc file"
nk_format_exc
=
"Unknown Format: in .changes file"
no_files_exc
=
"No Files: field in .dsc or .changes file."
cant_open_exc
=
"Can't open file"
unknown_hostname_exc
=
"Unknown hostname"
cant_overwrite_exc
=
"Permission denied; can't overwrite existent file."
file_exists_exc
=
"Destination file exists"
sendmail_failed_exc
=
"Sendmail invocation failed"
tried_too_hard_exc
=
"Tried too hard to find a free filename."
default_config
=
"/etc/dak/dak.conf"
default_apt_config
=
"/etc/dak/apt.conf"
...
...
@@ -72,7 +61,7 @@ def open_file(filename, mode='r'):
try
:
f
=
open
(
filename
,
mode
)
except
IOError
:
raise
cant_open_exc
,
filename
raise
CantOpenError
,
filename
return
f
################################################################################
...
...
@@ -135,7 +124,7 @@ The rules for (signing_rules == 1)-mode are:
lines
=
changes_in
.
readlines
()
if
not
lines
:
raise
changes_parse_error_exc
,
"[Empty changes file]"
raise
ParseChangesError
,
"[Empty changes file]"
# Reindex by line number so we can easily verify the format of
# .dsc files...
...
...
@@ -157,10 +146,10 @@ The rules for (signing_rules == 1)-mode are:
if
signing_rules
==
1
:
index
+=
1
if
index
>
num_of_lines
:
raise
invalid_dsc_format_exc
,
index
raise
InvalidDscError
,
index
line
=
indexed_lines
[
index
]
if
not
line
.
startswith
(
"-----BEGIN PGP SIGNATURE"
):
raise
invalid_dsc_format_exc
,
index
raise
InvalidDscError
,
index
inside_signature
=
0
break
else
:
...
...
@@ -189,7 +178,7 @@ The rules for (signing_rules == 1)-mode are:
mlf
=
re_multi_line_field
.
match
(
line
)
if
mlf
:
if
first
==
-
1
:
raise
changes_parse_error_exc
,
"'%s'
\n
[Multi-line field continuing on from nothing?]"
%
(
line
)
raise
ParseChangesError
,
"'%s'
\n
[Multi-line field continuing on from nothing?]"
%
(
line
)
if
first
==
1
and
changes
[
field
]
!=
""
:
changes
[
field
]
+=
'
\n
'
first
=
0
...
...
@@ -198,7 +187,7 @@ The rules for (signing_rules == 1)-mode are:
error
+=
line
if
signing_rules
==
1
and
inside_signature
:
raise
invalid_dsc_format_exc
,
index
raise
InvalidDscError
,
index
changes_in
.
close
()
changes
[
"filecontents"
]
=
""
.
join
(
lines
)
...
...
@@ -212,7 +201,7 @@ The rules for (signing_rules == 1)-mode are:
changes
[
"source-version"
]
=
srcver
.
group
(
2
)
if
error
:
raise
changes_parse_error_exc
,
error
raise
ParseChangesError
,
error
return
changes
...
...
@@ -225,12 +214,12 @@ def build_file_list(changes, is_a_dsc=0, field="files", hashname="md5sum"):
# Make sure we have a Files: field to parse...
if
not
changes
.
has_key
(
field
):
raise
no_files_exc
raise
NoFilesFieldError
# Make sure we recognise the format of the Files: field
format
=
re_verwithext
.
search
(
changes
.
get
(
"format"
,
"0.0"
))
if
not
format
:
raise
nk_format_exc
,
"%s"
%
(
changes
.
get
(
"format"
,
"0.0"
))
raise
UnknownFormatError
,
"%s"
%
(
changes
.
get
(
"format"
,
"0.0"
))
format
=
format
.
groups
()
if
format
[
1
]
==
None
:
...
...
@@ -242,12 +231,12 @@ def build_file_list(changes, is_a_dsc=0, field="files", hashname="md5sum"):
if
is_a_dsc
:
if
format
!=
(
1
,
0
):
raise
nk_format_exc
,
"%s"
%
(
changes
.
get
(
"format"
,
"0.0"
))
raise
UnknownFormatError
,
"%s"
%
(
changes
.
get
(
"format"
,
"0.0"
))
else
:
if
(
format
<
(
1
,
5
)
or
format
>
(
1
,
8
)):
raise
nk_format_exc
,
"%s"
%
(
changes
.
get
(
"format"
,
"0.0"
))
raise
UnknownFormatError
,
"%s"
%
(
changes
.
get
(
"format"
,
"0.0"
))
if
field
!=
"files"
and
format
<
(
1
,
8
):
raise
nk_format_exc
,
"%s"
%
(
changes
.
get
(
"format"
,
"0.0"
))
raise
UnknownFormatError
,
"%s"
%
(
changes
.
get
(
"format"
,
"0.0"
))
includes_section
=
(
not
is_a_dsc
)
and
field
==
"files"
...
...
@@ -263,7 +252,7 @@ def build_file_list(changes, is_a_dsc=0, field="files", hashname="md5sum"):
else
:
(
md5
,
size
,
name
)
=
s
except
ValueError
:
raise
changes_parse_error_exc
,
i
raise
ParseChangesError
,
i
if
section
==
""
:
section
=
"-"
...
...
@@ -371,7 +360,7 @@ def send_mail (message, filename=""):
# Invoke sendmail
(
result
,
output
)
=
commands
.
getstatusoutput
(
"%s < %s"
%
(
Cnf
[
"Dinstall::SendmailCommand"
],
filename
))
if
(
result
!=
0
):
raise
sendmail_failed_exc
,
output
raise
SendmailFailedError
,
output
# Clean up any temporary files
if
message
:
...
...
@@ -427,10 +416,10 @@ def copy (src, dest, overwrite = 0, perms = 0664):
# Don't overwrite unless forced to
if
os
.
path
.
exists
(
dest
):
if
not
overwrite
:
raise
file_exists_exc
raise
FileExistsError
else
:
if
not
os
.
access
(
dest
,
os
.
W_OK
):
raise
cant_overwrite_exc
raise
CantOverwriteError
shutil
.
copy2
(
src
,
dest
)
os
.
chmod
(
dest
,
perms
)
...
...
@@ -574,7 +563,7 @@ def find_next_free (dest, too_many=100):
dest
=
orig_dest
+
'.'
+
repr
(
extra
)
extra
+=
1
if
extra
>=
too_many
:
raise
tried_too_hard_exc
raise
NoFreeFilenameError
return
dest
################################################################################
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录