Merge "Add flake8-bugbear and address warnings"
This commit is contained in:
commit
dc441b0b52
|
@ -17,6 +17,7 @@ import getopt
|
||||||
import subprocess
|
import subprocess
|
||||||
import time
|
import time
|
||||||
import re
|
import re
|
||||||
|
import six
|
||||||
from cgcs_patch.patch_functions import PatchFile
|
from cgcs_patch.patch_functions import PatchFile
|
||||||
# import twisted.python.lockfile
|
# import twisted.python.lockfile
|
||||||
|
|
||||||
|
@ -1258,7 +1259,7 @@ class PatchRecipeData(object):
|
||||||
rpm_dir = "%s/%s/%s" % (workdir, build_type, RPM_DIR)
|
rpm_dir = "%s/%s/%s" % (workdir, build_type, RPM_DIR)
|
||||||
rpm_db = self._get_rpm_db_path(self.patch_id)
|
rpm_db = self._get_rpm_db_path(self.patch_id)
|
||||||
issue_cmd("echo > %s" % rpm_db)
|
issue_cmd("echo > %s" % rpm_db)
|
||||||
for subdir in os.walk(rpm_dir).next()[1]:
|
for subdir in six.next(os.walk(rpm_dir))[1]:
|
||||||
rpm_sub_dir = "%s/%s" % (rpm_dir, subdir)
|
rpm_sub_dir = "%s/%s" % (rpm_dir, subdir)
|
||||||
issue_cmd("rpm -qp --dbpath %s --queryformat '%s %%{NAME} %%{RELEASE}\n' %s/*rpm >> %s 2> /dev/null" % (temp_rpm_db_dir, subdir, rpm_sub_dir, rpm_db))
|
issue_cmd("rpm -qp --dbpath %s --queryformat '%s %%{NAME} %%{RELEASE}\n' %s/*rpm >> %s 2> /dev/null" % (temp_rpm_db_dir, subdir, rpm_sub_dir, rpm_db))
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ class PatchAPIController(object):
|
||||||
try:
|
try:
|
||||||
pd = pc.patch_query_cached(**kwargs)
|
pd = pc.patch_query_cached(**kwargs)
|
||||||
except PatchError as e:
|
except PatchError as e:
|
||||||
return dict(error="Error: %s" % e.message)
|
return dict(error="Error: %s" % str(e))
|
||||||
|
|
||||||
return dict(pd=pd)
|
return dict(pd=pd)
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ class PatchAPIController(object):
|
||||||
try:
|
try:
|
||||||
result = pc.patch_query_specific_cached(list(args))
|
result = pc.patch_query_specific_cached(list(args))
|
||||||
except PatchError as e:
|
except PatchError as e:
|
||||||
return dict(error="Error: %s" % e.message)
|
return dict(error="Error: %s" % str(e))
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ class PatchAPIController(object):
|
||||||
try:
|
try:
|
||||||
result = pc.patch_apply_api(list(args), **kwargs)
|
result = pc.patch_apply_api(list(args), **kwargs)
|
||||||
except PatchError as e:
|
except PatchError as e:
|
||||||
return dict(error="Error: %s" % e.message)
|
return dict(error="Error: %s" % str(e))
|
||||||
|
|
||||||
pc.patch_sync()
|
pc.patch_sync()
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ class PatchAPIController(object):
|
||||||
try:
|
try:
|
||||||
result = pc.patch_remove_api(list(args), **kwargs)
|
result = pc.patch_remove_api(list(args), **kwargs)
|
||||||
except PatchError as e:
|
except PatchError as e:
|
||||||
return dict(error="Error: %s" % e.message)
|
return dict(error="Error: %s" % str(e))
|
||||||
|
|
||||||
pc.patch_sync()
|
pc.patch_sync()
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ class PatchAPIController(object):
|
||||||
try:
|
try:
|
||||||
result = pc.patch_delete_api(list(args))
|
result = pc.patch_delete_api(list(args))
|
||||||
except PatchError as e:
|
except PatchError as e:
|
||||||
return dict(error="Error: %s" % e.message)
|
return dict(error="Error: %s" % str(e))
|
||||||
|
|
||||||
pc.patch_sync()
|
pc.patch_sync()
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ class PatchAPIController(object):
|
||||||
result = pc.patch_import_api([fn])
|
result = pc.patch_import_api([fn])
|
||||||
except PatchError as e:
|
except PatchError as e:
|
||||||
os.remove(fn)
|
os.remove(fn)
|
||||||
return dict(error=e.message)
|
return dict(error=str(e))
|
||||||
|
|
||||||
os.remove(fn)
|
os.remove(fn)
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ class PatchAPIController(object):
|
||||||
try:
|
try:
|
||||||
result = pc.patch_import_api(sorted(files))
|
result = pc.patch_import_api(sorted(files))
|
||||||
except PatchError as e:
|
except PatchError as e:
|
||||||
return dict(error=e.message)
|
return dict(error=str(e))
|
||||||
|
|
||||||
pc.patch_sync()
|
pc.patch_sync()
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ class PatchAPIController(object):
|
||||||
try:
|
try:
|
||||||
result = pc.patch_init_release_api(list(args)[0])
|
result = pc.patch_init_release_api(list(args)[0])
|
||||||
except PatchError as e:
|
except PatchError as e:
|
||||||
return dict(error=e.message)
|
return dict(error=str(e))
|
||||||
|
|
||||||
pc.patch_sync()
|
pc.patch_sync()
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ class PatchAPIController(object):
|
||||||
try:
|
try:
|
||||||
result = pc.patch_del_release_api(list(args)[0])
|
result = pc.patch_del_release_api(list(args)[0])
|
||||||
except PatchError as e:
|
except PatchError as e:
|
||||||
return dict(error=e.message)
|
return dict(error=str(e))
|
||||||
|
|
||||||
pc.patch_sync()
|
pc.patch_sync()
|
||||||
|
|
||||||
|
@ -191,7 +191,7 @@ class PatchAPIController(object):
|
||||||
try:
|
try:
|
||||||
result = pc.patch_query_what_requires(list(args))
|
result = pc.patch_query_what_requires(list(args))
|
||||||
except PatchError as e:
|
except PatchError as e:
|
||||||
return dict(error="Error: %s" % e.message)
|
return dict(error="Error: %s" % str(e))
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -212,7 +212,7 @@ class PatchAPIController(object):
|
||||||
try:
|
try:
|
||||||
result = pc.patch_host_install(list(args)[0], force, async_req=True)
|
result = pc.patch_host_install(list(args)[0], force, async_req=True)
|
||||||
except PatchError as e:
|
except PatchError as e:
|
||||||
return dict(error="Error: %s" % e.message)
|
return dict(error="Error: %s" % str(e))
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -225,7 +225,7 @@ class PatchAPIController(object):
|
||||||
try:
|
try:
|
||||||
result = pc.drop_host(list(args)[0])
|
result = pc.drop_host(list(args)[0])
|
||||||
except PatchError as e:
|
except PatchError as e:
|
||||||
return dict(error="Error: %s" % e.message)
|
return dict(error="Error: %s" % str(e))
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -234,7 +234,7 @@ class PatchAPIController(object):
|
||||||
try:
|
try:
|
||||||
result = pc.patch_query_dependencies(list(args), **kwargs)
|
result = pc.patch_query_dependencies(list(args), **kwargs)
|
||||||
except PatchError as e:
|
except PatchError as e:
|
||||||
return dict(error=e.message)
|
return dict(error=str(e))
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -243,7 +243,7 @@ class PatchAPIController(object):
|
||||||
try:
|
try:
|
||||||
result = pc.patch_commit(list(args))
|
result = pc.patch_commit(list(args))
|
||||||
except PatchError as e:
|
except PatchError as e:
|
||||||
return dict(error=e.message)
|
return dict(error=str(e))
|
||||||
|
|
||||||
pc.patch_sync()
|
pc.patch_sync()
|
||||||
|
|
||||||
|
@ -254,7 +254,7 @@ class PatchAPIController(object):
|
||||||
try:
|
try:
|
||||||
result = pc.patch_commit(list(args), dry_run=True)
|
result = pc.patch_commit(list(args), dry_run=True)
|
||||||
except PatchError as e:
|
except PatchError as e:
|
||||||
return dict(error=e.message)
|
return dict(error=str(e))
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -271,7 +271,7 @@ class PatchAPIController(object):
|
||||||
try:
|
try:
|
||||||
result = pc.report_app_dependencies(list(args), **kwargs)
|
result = pc.report_app_dependencies(list(args), **kwargs)
|
||||||
except PatchError as e:
|
except PatchError as e:
|
||||||
return dict(status=500, error=e.message)
|
return dict(status=500, error=str(e))
|
||||||
|
|
||||||
pc.patch_sync()
|
pc.patch_sync()
|
||||||
|
|
||||||
|
|
|
@ -1351,7 +1351,7 @@ def get_auth_token_and_endpoint(region_name):
|
||||||
interface='internal',
|
interface='internal',
|
||||||
region_name=region_name)
|
region_name=region_name)
|
||||||
except (exceptions.http.Unauthorized, exceptions.EndpointNotFound) as e:
|
except (exceptions.http.Unauthorized, exceptions.EndpointNotFound) as e:
|
||||||
print(e.message)
|
print(str(e))
|
||||||
exit(-1)
|
exit(-1)
|
||||||
|
|
||||||
return token, endpoint
|
return token, endpoint
|
||||||
|
|
|
@ -984,8 +984,8 @@ class PatchController(PatchService):
|
||||||
continue
|
continue
|
||||||
except PatchValidationFailure as e:
|
except PatchValidationFailure as e:
|
||||||
msg = "Patch validation failed for %s" % patch_id
|
msg = "Patch validation failed for %s" % patch_id
|
||||||
if e.message is not None and e.message != '':
|
if str(e) is not None and str(e) != '':
|
||||||
msg += ":\n%s" % e.message
|
msg += ":\n%s" % str(e)
|
||||||
LOG.exception(msg)
|
LOG.exception(msg)
|
||||||
msg_error += msg + "\n"
|
msg_error += msg + "\n"
|
||||||
continue
|
continue
|
||||||
|
@ -1019,8 +1019,8 @@ class PatchController(PatchService):
|
||||||
self.patch_data.metadata[patch_id]["patchstate"] = constants.UNKNOWN
|
self.patch_data.metadata[patch_id]["patchstate"] = constants.UNKNOWN
|
||||||
except PatchValidationFailure as e:
|
except PatchValidationFailure as e:
|
||||||
msg = "Patch validation failed for %s" % patch_id
|
msg = "Patch validation failed for %s" % patch_id
|
||||||
if e.message is not None and e.message != '':
|
if str(e) is not None and str(e) != '':
|
||||||
msg += ":\n%s" % e.message
|
msg += ":\n%s" % str(e)
|
||||||
LOG.exception(msg)
|
LOG.exception(msg)
|
||||||
msg_error += msg + "\n"
|
msg_error += msg + "\n"
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -268,7 +268,7 @@ class BasePackageData(object):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
self.pkgs[sw_rel] = {}
|
self.pkgs[sw_rel] = {}
|
||||||
for root, dirs, files in os.walk("%s/Packages" % reldir): # pylint: disable=unused-variable
|
for _root, _dirs, files in os.walk("%s/Packages" % reldir): # pylint: disable=unused-variable
|
||||||
for name in files:
|
for name in files:
|
||||||
if name.endswith(".rpm"):
|
if name.endswith(".rpm"):
|
||||||
try:
|
try:
|
||||||
|
@ -589,7 +589,7 @@ class PatchData(object):
|
||||||
return self.package_versions[sw_ver][pkgname][arch][pkgver]
|
return self.package_versions[sw_ver][pkgname][arch][pkgver]
|
||||||
|
|
||||||
def load_all_metadata(self,
|
def load_all_metadata(self,
|
||||||
loaddir=os.getcwd(),
|
loaddir,
|
||||||
repostate=None):
|
repostate=None):
|
||||||
"""
|
"""
|
||||||
Parse all metadata files in the specified dir
|
Parse all metadata files in the specified dir
|
||||||
|
@ -831,8 +831,7 @@ class PatchFile(object):
|
||||||
|
|
||||||
self.semantics[action] = os.path.abspath(fname)
|
self.semantics[action] = os.path.abspath(fname)
|
||||||
|
|
||||||
def gen_patch(self,
|
def gen_patch(self, outdir):
|
||||||
outdir=os.getcwd()):
|
|
||||||
"""
|
"""
|
||||||
Generate the patch file, named PATCHID.patch
|
Generate the patch file, named PATCHID.patch
|
||||||
:param outdir: Output directory for the patch
|
:param outdir: Output directory for the patch
|
||||||
|
@ -1382,4 +1381,4 @@ def patch_build():
|
||||||
for rpmfile in remainder:
|
for rpmfile in remainder:
|
||||||
pf.add_rpm(rpmfile)
|
pf.add_rpm(rpmfile)
|
||||||
|
|
||||||
pf.gen_patch()
|
pf.gen_patch(outdir=os.getcwd())
|
||||||
|
|
|
@ -104,6 +104,8 @@ max-line-length = 120
|
||||||
|
|
||||||
[testenv:flake8]
|
[testenv:flake8]
|
||||||
basepython = python3
|
basepython = python3
|
||||||
|
deps = {[testenv]deps}
|
||||||
|
flake8-bugbear
|
||||||
usedevelop = False
|
usedevelop = False
|
||||||
#skip_install = True
|
#skip_install = True
|
||||||
commands =
|
commands =
|
||||||
|
|
|
@ -82,6 +82,8 @@ max-line-length = 120
|
||||||
|
|
||||||
[testenv:flake8]
|
[testenv:flake8]
|
||||||
basepython = python3
|
basepython = python3
|
||||||
|
deps = {[testenv]deps}
|
||||||
|
flake8-bugbear
|
||||||
usedevelop = False
|
usedevelop = False
|
||||||
#skip_install = True
|
#skip_install = True
|
||||||
commands =
|
commands =
|
||||||
|
|
Loading…
Reference in New Issue