Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
avocado
提交
96abcc35
A
avocado
项目概览
openeuler
/
avocado
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
avocado
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
96abcc35
编写于
3月 12, 2014
作者:
L
Lucas Meneghel Rodrigues
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
avocado.linux.software_manager: Fix logging calls
上级
e0312c24
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
38 addition
and
37 deletion
+38
-37
avocado/linux/software_manager.py
avocado/linux/software_manager.py
+38
-37
未找到文件。
avocado/linux/software_manager.py
浏览文件 @
96abcc35
...
...
@@ -32,6 +32,7 @@ from avocado.core import exceptions
log
=
logging
.
getLogger
(
'avocado.linux'
)
SUPPORTED_PACKAGE_MANAGERS
=
[
'apt-get'
,
'yum'
,
'zypper'
]
...
...
@@ -143,7 +144,7 @@ class BaseBackend(object):
if
provides
is
not
None
:
return
self
.
install
(
provides
)
else
:
log
ging
.
warning
(
'No package seems to provide %s'
,
path
)
log
.
warning
(
'No package seems to provide %s'
,
path
)
return
False
...
...
@@ -217,7 +218,7 @@ class RpmBackend(BaseBackend):
:param software_components: log in a format suitable for the
SoftwareComponent schema
"""
log
ging
.
debug
(
"Listing all system packages (may take a while)"
)
log
.
debug
(
"Listing all system packages (may take a while)"
)
if
software_components
:
cmd_format
=
"rpm -qa --qf '%s' | sort"
...
...
@@ -287,7 +288,7 @@ class DpkgBackend(BaseBackend):
"""
List all packages available in the system.
"""
log
ging
.
debug
(
"Listing all system packages (may take a while)"
)
log
.
debug
(
"Listing all system packages (may take a while)"
)
installed_packages
=
[]
cmd_result
=
process
.
run
(
'dpkg -l'
,
verbose
=
False
)
out
=
cmd_result
.
stdout
.
strip
()
...
...
@@ -342,7 +343,7 @@ class YumBackend(RpmBackend):
except
IndexError
:
ver
=
out
self
.
pm_version
=
ver
log
ging
.
debug
(
'Yum version: %s'
%
self
.
pm_version
)
log
.
debug
(
'Yum version: %s'
%
self
.
pm_version
)
self
.
yum_base
=
yum
.
YumBase
()
...
...
@@ -449,8 +450,8 @@ class YumBackend(RpmBackend):
try
:
d_provides
=
self
.
yum_base
.
searchPackageProvides
(
args
=
[
name
])
except
Exception
,
e
:
log
ging
.
error
(
"Error searching for package that "
"provides %s: %s"
,
name
,
e
)
log
.
error
(
"Error searching for package that "
"provides %s: %s"
,
name
,
e
)
d_provides
=
[]
provides_list
=
[
key
for
key
in
d_provides
]
...
...
@@ -483,7 +484,7 @@ class ZypperBackend(RpmBackend):
except
IndexError
:
ver
=
out
self
.
pm_version
=
ver
log
ging
.
debug
(
'Zypper version: %s'
%
self
.
pm_version
)
log
.
debug
(
'Zypper version: %s'
%
self
.
pm_version
)
def
install
(
self
,
name
):
"""
...
...
@@ -576,10 +577,10 @@ class ZypperBackend(RpmBackend):
except
IndexError
:
pass
if
len
(
list_provides
)
>
1
:
log
ging
.
warning
(
'More than one package found, '
'opting by the first queue result'
)
log
.
warning
(
'More than one package found, '
'opting by the first queue result'
)
if
list_provides
:
log
ging
.
info
(
"Package %s provides %s"
,
list_provides
[
0
],
name
)
log
.
info
(
"Package %s provides %s"
,
list_provides
[
0
],
name
)
return
list_provides
[
0
]
return
None
except
exceptions
.
CmdError
:
...
...
@@ -613,7 +614,7 @@ class AptBackend(DpkgBackend):
ver
=
out
self
.
pm_version
=
ver
log
ging
.
debug
(
'apt-get version: %s'
%
self
.
pm_version
)
log
.
debug
(
'apt-get version: %s'
%
self
.
pm_version
)
def
install
(
self
,
name
):
"""
...
...
@@ -690,7 +691,7 @@ class AptBackend(DpkgBackend):
try
:
process
.
system
(
ud_cmd
)
except
exceptions
.
CmdError
:
log
ging
.
error
(
"Apt package update failed"
)
log
.
error
(
"Apt package update failed"
)
if
name
:
up_command
=
'install --only-upgrade'
...
...
@@ -721,7 +722,7 @@ class AptBackend(DpkgBackend):
try
:
process
.
system
(
cache_update_cmd
,
ignore_status
=
True
)
except
exceptions
.
CmdError
:
log
ging
.
error
(
"Apt file cache update failed"
)
log
.
error
(
"Apt file cache update failed"
)
fu_cmd
=
command
+
' search '
+
path
try
:
provides
=
process
.
system_output
(
fu_cmd
).
split
(
'
\n
'
)
...
...
@@ -737,10 +738,10 @@ class AptBackend(DpkgBackend):
except
IndexError
:
pass
if
len
(
list_provides
)
>
1
:
log
ging
.
warning
(
'More than one package found, '
'opting by the first result'
)
log
.
warning
(
'More than one package found, '
'opting by the first result'
)
if
list_provides
:
log
ging
.
info
(
"Package %s provides %s"
,
list_provides
[
0
],
path
)
log
.
info
(
"Package %s provides %s"
,
list_provides
[
0
],
path
)
return
list_provides
[
0
]
return
None
except
exceptions
.
CmdError
:
...
...
@@ -793,7 +794,7 @@ def install_distro_packages(distro_pkg_map, interactive=False):
break
if
not
pkgs
:
log
ging
.
info
(
"No specific distro release package list"
)
log
.
info
(
"No specific distro release package list"
)
# when comparing distro names only, fallback to a lowercase version
# of the distro name is it's more common than the case as detected
...
...
@@ -802,7 +803,7 @@ def install_distro_packages(distro_pkg_map, interactive=False):
pkgs
=
distro_pkg_map
.
get
(
detected_distro
.
name
.
lower
(),
None
)
if
not
pkgs
:
log
ging
.
error
(
"No generic distro package list"
)
log
.
error
(
"No generic distro package list"
)
if
pkgs
:
needed_pkgs
=
[]
...
...
@@ -812,12 +813,12 @@ def install_distro_packages(distro_pkg_map, interactive=False):
needed_pkgs
.
append
(
pkg
)
if
needed_pkgs
:
text
=
' '
.
join
(
needed_pkgs
)
log
ging
.
info
(
'Installing packages "%s"'
,
text
)
log
.
info
(
'Installing packages "%s"'
,
text
)
result
=
software_manager
.
install
(
text
)
else
:
log
ging
.
error
(
"No packages found for %s %s %s %s"
,
detected_distro
.
name
,
detected_distro
.
arch
,
detected_distro
.
version
,
detected_distro
.
release
)
log
.
error
(
"No packages found for %s %s %s %s"
,
detected_distro
.
name
,
detected_distro
.
arch
,
detected_distro
.
version
,
detected_distro
.
release
)
return
result
...
...
@@ -839,54 +840,54 @@ if __name__ == '__main__':
if
action
==
'install'
:
if
software_manager
.
install
(
args
):
log
ging
.
info
(
"Packages %s installed successfully"
,
args
)
log
.
info
(
"Packages %s installed successfully"
,
args
)
else
:
log
ging
.
error
(
"Failed to install %s"
,
args
)
log
.
error
(
"Failed to install %s"
,
args
)
elif
action
==
'remove'
:
if
software_manager
.
remove
(
args
):
log
ging
.
info
(
"Packages %s removed successfully"
,
args
)
log
.
info
(
"Packages %s removed successfully"
,
args
)
else
:
log
ging
.
error
(
"Failed to remove %s"
,
args
)
log
.
error
(
"Failed to remove %s"
,
args
)
elif
action
==
'check-installed'
:
if
software_manager
.
check_installed
(
args
):
log
ging
.
info
(
"Package %s already installed"
,
args
)
log
.
info
(
"Package %s already installed"
,
args
)
else
:
log
ging
.
info
(
"Package %s not installed"
,
args
)
log
.
info
(
"Package %s not installed"
,
args
)
elif
action
==
'list-all'
:
for
pkg
in
software_manager
.
list_all
():
log
ging
.
info
(
pkg
)
log
.
info
(
pkg
)
elif
action
==
'list-files'
:
for
f
in
software_manager
.
list_files
(
args
):
log
ging
.
info
(
f
)
log
.
info
(
f
)
elif
action
==
'add-repo'
:
if
software_manager
.
add_repo
(
args
):
log
ging
.
info
(
"Repo %s added successfully"
,
args
)
log
.
info
(
"Repo %s added successfully"
,
args
)
else
:
log
ging
.
error
(
"Failed to remove repo %s"
,
args
)
log
.
error
(
"Failed to remove repo %s"
,
args
)
elif
action
==
'remove-repo'
:
if
software_manager
.
remove_repo
(
args
):
log
ging
.
info
(
"Repo %s removed successfully"
,
args
)
log
.
info
(
"Repo %s removed successfully"
,
args
)
else
:
log
ging
.
error
(
"Failed to remove repo %s"
,
args
)
log
.
error
(
"Failed to remove repo %s"
,
args
)
elif
action
==
'upgrade'
:
if
software_manager
.
upgrade
():
log
ging
.
info
(
"Package manager upgrade successful"
)
log
.
info
(
"Package manager upgrade successful"
)
elif
action
==
'what-provides'
:
provides
=
software_manager
.
provides
(
args
)
if
provides
is
not
None
:
log
ging
.
info
(
"Package %s provides %s"
,
provides
,
args
)
log
.
info
(
"Package %s provides %s"
,
provides
,
args
)
elif
action
==
'install-what-provides'
:
if
software_manager
.
install_what_provides
(
args
):
log
ging
.
info
(
"Installed successfully what provides %s"
,
args
)
log
.
info
(
"Installed successfully what provides %s"
,
args
)
elif
action
==
'show-help'
:
parser
.
print_help
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录