提交 acc07362 编写于 作者: L Lukáš Doktor

avocado.utils.software_manager: Pylint fixes

Signed-off-by: NLukáš Doktor <ldoktor@redhat.com>
上级 85a4d1e4
......@@ -207,10 +207,7 @@ class RpmBackend(BaseBackend):
if 'not installed' in inst_version:
return False
if inst_version >= version:
return True
else:
return False
return bool(inst_version >= version)
def check_installed(self, name, version=None, arch=None):
"""
......@@ -367,7 +364,7 @@ class YumBackend(RpmBackend):
verbose=False, shell=True)
out = cmd_result.stdout.strip()
try:
ver = re.findall('\d*.\d*.\d*', out)[0]
ver = re.findall(r'\d*.\d*.\d*', out)[0]
except IndexError:
ver = out
self.pm_version = ver
......@@ -504,9 +501,9 @@ class YumBackend(RpmBackend):
return None
try:
d_provides = self.yum_base.searchPackageProvides(args=[name])
except Exception, e:
except Exception, exc:
log.error("Error searching for package that "
"provides %s: %s", name, e)
"provides %s: %s", name, exc)
d_provides = []
provides_list = [key for key in d_provides]
......@@ -674,19 +671,20 @@ class AptBackend(DpkgBackend):
executable = utils_path.find_command('apt-get')
self.base_command = executable + ' --yes --allow-unauthenticated'
self.repo_file_path = '/etc/apt/sources.list.d/avocado.list'
self.dpkg_force_confdef = '-o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold"'
self.dpkg_force_confdef = ('-o Dpkg::Options::="--force-confdef" '
'-o Dpkg::Options::="--force-confold"')
cmd_result = process.run('apt-get -v | head -1',
ignore_status=True,
verbose=False,
shell=True)
out = cmd_result.stdout.strip()
try:
ver = re.findall('\d\S*', out)[0]
ver = re.findall(r'\d\S*', out)[0]
except IndexError:
ver = out
self.pm_version = ver
log.debug('apt-get version: %s' % self.pm_version)
log.debug('apt-get version: %s', self.pm_version)
# gdebi-core is necessary for local installation with dependency
# handling
if not self.check_installed('gdebi-core'):
......@@ -706,7 +704,8 @@ class AptBackend(DpkgBackend):
i_cmd = utils_path.find_command('gdebi') + ' -n -q ' + name
else:
command = 'install'
i_cmd = " ".join([self.base_command, self.dpkg_force_confdef, command, name])
i_cmd = " ".join([self.base_command, self.dpkg_force_confdef,
command, name])
try:
process.system(i_cmd, shell=True, sudo=True)
......@@ -758,7 +757,7 @@ class AptBackend(DpkgBackend):
new_file_contents = []
with open(self.repo_file_path, 'r') as repo_file:
for line in repo_file.readlines():
if not line == repo:
if line != repo:
new_file_contents.append(line)
new_file_contents = "\n".join(new_file_contents)
prefix = "avocado_software_manager"
......@@ -790,10 +789,12 @@ class AptBackend(DpkgBackend):
if name:
up_command = 'install --only-upgrade'
up_cmd = " ".join([self.base_command, self.dpkg_force_confdef, up_command, name])
up_cmd = " ".join([self.base_command, self.dpkg_force_confdef,
up_command, name])
else:
up_command = 'upgrade'
up_cmd = " ".join([self.base_command, self.dpkg_force_confdef, up_command])
up_cmd = " ".join([self.base_command, self.dpkg_force_confdef,
up_command])
try:
process.system(up_cmd, shell=True, sudo=True)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册