Fix pylint errors and warnings
Remove `except` block which immediately raises the same exception again (it's not a subclass of another caught exception, so this is safe). Remove a false positive, because it is not emitted from the code base. Disable subprocess-popen-preexec-fn in startProgram, which is not used internally.
This commit is contained in:
parent
9736dff762
commit
160044ba9d
@ -23,9 +23,11 @@ log = logging.getLogger("composer")
|
||||
import os
|
||||
import sys
|
||||
|
||||
from composer import vernum
|
||||
from composer.cli import main
|
||||
from composer.cli.cmdline import composer_cli_parser
|
||||
# Disable pylint warnings for these, because it cannot deal with this file and
|
||||
# the module both being called "composer"
|
||||
from composer import vernum # pylint: disable=import-self
|
||||
from composer.cli import main # pylint: disable=no-name-in-module
|
||||
from composer.cli.cmdline import composer_cli_parser # pylint: disable=no-name-in-module
|
||||
|
||||
VERSION = "{0}-{1}".format(os.path.basename(sys.argv[0]), vernum)
|
||||
|
||||
|
@ -115,6 +115,7 @@ def startProgram(argv, root='/', stdin=None, stdout=subprocess.PIPE, stderr=subp
|
||||
if env_add:
|
||||
env.update(env_add)
|
||||
|
||||
# pylint: disable=subprocess-popen-preexec-fn
|
||||
return subprocess.Popen(argv,
|
||||
stdin=stdin,
|
||||
stdout=stdout,
|
||||
|
@ -196,10 +196,7 @@ def loop_attach(outfile):
|
||||
|
||||
# Sometimes the loop device isn't ready yet, make extra sure before returning
|
||||
loop_waitfor(dev, outfile)
|
||||
except CalledProcessError:
|
||||
# Problems running losetup are always errors, raise immediately
|
||||
raise
|
||||
except RuntimeError as e:
|
||||
except RuntimeError:
|
||||
# Try to setup the loop device 3 times
|
||||
if retries == 3:
|
||||
logger.error("loop_attach failed, retries exhausted.")
|
||||
|
@ -248,10 +248,10 @@ class LoraxTemplateRunner(object):
|
||||
# skip the bit about "ltmpl.py, in _run()" - we know that
|
||||
exclines.pop(1)
|
||||
# log the "ErrorType: this is what happened" line
|
||||
logger.error(" " + exclines[-1].strip())
|
||||
logger.error(" %s", exclines[-1].strip())
|
||||
# and log the entire traceback to the debug log
|
||||
for _line in ''.join(exclines).splitlines():
|
||||
logger.debug(" " + _line)
|
||||
logger.debug(" %s", _line)
|
||||
if self.fatalerrors:
|
||||
raise
|
||||
|
||||
|
@ -9,9 +9,6 @@ class LoraxLintConfig(PocketLintConfig):
|
||||
PocketLintConfig.__init__(self)
|
||||
|
||||
self.falsePositives = [ FalsePositive(r"Module 'pylorax' has no 'version' member"),
|
||||
# threading.Lock() is a factory function which returns an
|
||||
# instance of the Lock class that is supported by the platform
|
||||
FalsePositive(r"Context manager 'lock' doesn't implement __enter__ and __exit__"),
|
||||
FalsePositive(r"Catching too general exception Exception"),
|
||||
FalsePositive(r"^E0712.*: Catching an exception which doesn't inherit from (Base|)Exception: GError$"),
|
||||
FalsePositive(r"Module 'composer' has no 'version' member"),
|
||||
|
Loading…
Reference in New Issue
Block a user