Enable Python3 Compatibility

Flake8 currently ignores the following errors:
H237: module is removed in python3
H238: old style class declaration
Enable them for python2/3 compatibility

Change-Id: I4dd66c8ab388119b4abab83fda48a89e108f7821
Story: 2004515
Task: 29303
Signed-off-by: Eric Barrett <eric.barrett@windriver.com>
This commit is contained in:
Eric Barrett 2019-06-05 12:11:18 -04:00
parent 9ab5317dca
commit 25dee38f0b
7 changed files with 17 additions and 19 deletions

View File

@ -191,7 +191,7 @@ class PatchRecipeCmdFail(PatchRecipeError):
pass
class PatchList:
class PatchList(object):
"""
Patch List
"""
@ -571,7 +571,7 @@ class PatchList:
print("All patches built.")
class PackageData:
class PackageData(object):
"""
Package data
"""
@ -792,7 +792,7 @@ class PackageData:
sys.exit(2)
class RecipeData:
class RecipeData(object):
"""
Recipe data
"""
@ -912,7 +912,7 @@ class RecipeData:
return self.prebuilt
class PatchRecipeData:
class PatchRecipeData(object):
"""
Patch recipe data
"""

View File

@ -16,7 +16,7 @@ import cgcs_patch.constants as constants
from cgcs_patch.patch_functions import LOG
class PatchService:
class PatchService(object):
def __init__(self):
self.sock_out = None
self.sock_in = None

View File

@ -210,7 +210,7 @@ class PackageVersion(object):
return "%s%s-%s-%s.%s.rpm" % (prefix, pkgname, self.version, self.release, arch)
class BasePackageData:
class BasePackageData(object):
"""
Information about the base package data provided by the load
"""
@ -265,7 +265,7 @@ class BasePackageData:
return self.pkgs[sw_rel][pkgname][arch]
class PatchData:
class PatchData(object):
"""
Aggregated patch data
"""
@ -623,7 +623,7 @@ class PatchData:
return value
class PatchMetadata:
class PatchMetadata(object):
"""
Creating metadata for a single patch
"""
@ -713,7 +713,7 @@ class PatchMetadata:
write_xml_file(top, fname)
class PatchFile:
class PatchFile(object):
"""
Patch file
"""

View File

@ -6,7 +6,7 @@
#
import posixfile
import fcntl
import string
import time
@ -18,14 +18,14 @@ def get_unique_id(filename, digits=4):
path = "%s/%s" % (directory, filename)
try:
# open for update
file = posixfile.open(path, "r+")
file.lock("w|", digits)
file = open(path, "r+")
fcntl.lockf(file, fcntl.LOCK_EX, digits)
counter = int(file.read(digits)) + 1
except IOError:
# create it
try:
file = posixfile.open(path, "w")
file.lock("w|", digits)
file = open(path, "w")
fcntl.lockf(file, fcntl.LOCK_EX, digits)
except IOError:
print("creation of file '%s' failed" % path)
return -1

View File

@ -18,7 +18,7 @@ urls = (
)
class get_patch_id:
class get_patch_id(object):
def GET(self):
data = web.input(sw_version=None, prefix="CGCS")
output = pida.get_patch_id(data.sw_version, data.prefix)

View File

@ -42,7 +42,7 @@ def start_polling():
###################
# CLASSES
###################
class PatchAlarmDaemon():
class PatchAlarmDaemon(object):
""" Daemon process representation of
the patch monitoring program
"""

View File

@ -58,8 +58,6 @@ commands =
# H101 Use TODO(NAME)
# H102 Apache 2.0 license header not found
# H105 Don't use author tags
# H237 module posixfile is removed in Python 3
# H238 old style class declaration
# H306 imports not in alphabetical order
# H401 docstring should not start with a space
# H404 multi line docstring should start without a leading new line
@ -69,7 +67,7 @@ commands =
# F401 'XXXXX' imported but unused
# F841 local variable 'XXXXXX' is assigned to but never used
show-source = True
ignore = H101,H102,H105,H237,H238,H306,H401,H404,H405,E501,F401,F841
ignore = H101,H102,H105,H306,H401,H404,H405,E501,F401,F841
exclude = .venv,.git,.tox,dist,doc,*lib/python*,*egg,build,release-tag-*
# TODO: H106 Dont put vim configuration in source files (off by default).
# H203 Use assertIs(Not)None to check for None (off by default).