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