Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
喜羊羊3508
Dak
提交
45cdc48f
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,发现更多精彩内容 >>
提交
45cdc48f
编写于
5月 31, 2009
作者:
M
Mark Hymers
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
convert stats to sqla
Signed-off-by:
N
Mark Hymers
<
mhy@debian.org
>
上级
6f4eabfe
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
26 addition
and
34 deletion
+26
-34
dak/stats.py
dak/stats.py
+26
-34
未找到文件。
dak/stats.py
浏览文件 @
45cdc48f
...
...
@@ -33,12 +33,12 @@
import
pg
,
sys
import
apt_pkg
from
daklib
import
utils
from
daklib
import
database
from
daklib.dbconn
import
DBConn
,
get_suite_architectures
,
Suite
,
Architecture
,
\
BinAssociation
################################################################################
Cnf
=
None
projectB
=
None
################################################################################
...
...
@@ -59,14 +59,17 @@ The following MODEs are available:
################################################################################
def
per_arch_space_use
():
q
=
projectB
.
query
(
"""
SELECT a.arch_string as Architecture, sum(f.size)
session
=
DBConn
().
session
()
q
=
session
.
execute
(
"""
SELECT a.arch_string as Architecture, sum(f.size) AS sum
FROM files f, binaries b, architecture a
WHERE a.id=b.architecture AND f.id=b.file
GROUP BY a.arch_string"""
)
print
q
q
=
projectB
.
query
(
"SELECT sum(size) FROM files WHERE filename ~ '.(diff.gz|tar.gz|dsc)$'"
)
print
q
GROUP BY a.arch_string ORDER BY sum"""
).
fetchall
()
for
j
in
q
:
print
"%-15.15s %s"
%
(
j
[
0
],
j
[
1
])
print
q
=
session
.
execute
(
"SELECT sum(size) FROM files WHERE filename ~ '.(diff.gz|tar.gz|dsc)$'"
).
fetchall
()
print
"%-15.15s %s"
%
(
"Source"
,
q
[
0
][
0
])
################################################################################
...
...
@@ -137,38 +140,30 @@ def number_of_packages():
suites
=
{}
suite_ids
=
{}
d
=
{}
session
=
DBConn
().
session
()
# Build up suite mapping
q
=
projectB
.
query
(
"SELECT id, suite_name FROM suite"
)
suite_ql
=
q
.
getresult
()
for
i
in
suite_ql
:
(
sid
,
name
)
=
i
suites
[
sid
]
=
name
suite_ids
[
name
]
=
sid
for
i
in
session
.
query
(
Suite
).
all
():
suites
[
i
.
suite_id
]
=
i
.
suite_name
suite_ids
[
i
.
suite_name
]
=
i
.
suite_id
# Build up architecture mapping
q
=
projectB
.
query
(
"SELECT id, arch_string FROM architecture"
)
for
i
in
q
.
getresult
():
(
aid
,
name
)
=
i
arches
[
aid
]
=
name
arch_ids
[
name
]
=
aid
for
i
in
session
.
query
(
Architecture
).
all
():
arches
[
i
.
arch_id
]
=
i
.
arch_string
arch_ids
[
i
.
arch_string
]
=
i
.
arch_id
# Pre-create the dictionary
for
suite_id
in
suites
.
keys
():
d
[
suite_id
]
=
{}
for
arch_id
in
arches
.
keys
():
d
[
suite_id
][
arch_id
]
=
0
# Get the raw data for binaries
q
=
projectB
.
query
(
"""
SELECT ba.suite, b.architecture
FROM binaries b, bin_associations ba
WHERE b.id = ba.bin"""
)
# Simultate 'GROUP by suite, architecture' with a dictionary
for
i
in
q
.
getresult
():
(
suite_id
,
arch_id
)
=
i
# XXX: Why don't we just get the DB to do this?
for
i
in
session
.
query
(
BinAssociation
):
suite_id
=
i
.
suite_id
arch_id
=
i
.
binary
.
arch_id
d
[
suite_id
][
arch_id
]
=
d
[
suite_id
][
arch_id
]
+
1
# Get the raw data for source
arch_id
=
arch_ids
[
"source"
]
q
=
projectB
.
query
(
"""
SELECT suite, count(suite) FROM src_associations GROUP BY suite;"""
)
for
i
in
q
.
getresult
():
for
i
in
session
.
execute
(
'SELECT suite, COUNT(suite) FROM src_associations GROUP BY suite'
).
all
():
(
suite_id
,
count
)
=
i
d
[
suite_id
][
arch_id
]
=
d
[
suite_id
][
arch_id
]
+
count
## Print the results
...
...
@@ -180,8 +175,8 @@ SELECT suite, count(suite) FROM src_associations GROUP BY suite;""")
for
suite
in
suite_list
:
suite_id
=
suite_ids
[
suite
]
suite_arches
[
suite_id
]
=
{}
for
arch
in
database
.
get_suite_architectures
(
suite_id
):
suite_arches
[
suite_id
][
arch
]
=
""
for
arch
in
get_suite_architectures
(
suite
):
suite_arches
[
suite_id
][
arch
.
arch_string
]
=
""
suite_id_list
.
append
(
suite_id
)
output_list
=
[
output_format
(
i
)
for
i
in
suite_list
]
longest_suite
=
longest
(
output_list
)
...
...
@@ -212,7 +207,7 @@ SELECT suite, count(suite) FROM src_associations GROUP BY suite;""")
################################################################################
def
main
():
global
Cnf
,
projectB
global
Cnf
Cnf
=
utils
.
get_conf
()
Arguments
=
[(
'h'
,
"help"
,
"Stats::Options::Help"
)]
...
...
@@ -234,9 +229,6 @@ def main ():
usage
(
1
)
mode
=
args
[
0
].
lower
()
projectB
=
pg
.
connect
(
Cnf
[
"DB::Name"
],
Cnf
[
"DB::Host"
],
int
(
Cnf
[
"DB::Port"
]))
database
.
init
(
Cnf
,
projectB
)
if
mode
==
"arch-space"
:
per_arch_space_use
()
elif
mode
==
"pkg-nums"
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录