pylint: Resolve logging-not-lazy

A new Python checker was added to warn about using a + operator inside
call of logging methods when one of the operands is a literal string.

https://pylint.readthedocs.io/en/latest/whatsnew/1.8.html

Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
This commit is contained in:
Radostin Stoyanov 2018-03-02 08:01:23 +00:00 committed by Cole Robinson
parent 474f60fc56
commit 1ae5c4ff75
9 changed files with 15 additions and 15 deletions

View File

@ -194,7 +194,7 @@ class Command(object):
code, output = self._launch_command(conn)
logging.debug(output + "\n")
logging.debug("%s\n", output)
return code, output
except Exception as e:
return (-1, "".join(traceback.format_exc()) + str(e))

View File

@ -1290,8 +1290,8 @@ class vmmAddHardware(vmmGObjectUI):
def _add_device(self):
self._dev.get_xml_config()
logging.debug("Adding device:\n" + self._dev.get_xml_config())
xml = self._dev.get_xml_config()
logging.debug("Adding device:\n%s", xml)
if self._remove_usb_controller:
kwargs = {}

View File

@ -470,7 +470,7 @@ class vmmCloneVM(vmmGObjectUI):
newpath = self.generate_clone_path_name(origpath, newname)
row[STORAGE_INFO_NEW_PATH] = newpath
except Exception as e:
logging.debug("Generating new path from clone name failed: " +
logging.debug("Generating new path from clone name failed: %s",
str(e))
def build_storage_entry(self, disk, storage_box):

View File

@ -162,6 +162,6 @@ def acquire_tgt():
"org.freedesktop.KrbAuthDialog", None)
ret = ka.acquireTgt("(s)", "")
except Exception as e:
logging.info("Cannot acquire tgt" + str(e))
logging.info("Cannot acquire tgt %s", str(e))
ret = False
return ret

View File

@ -1014,8 +1014,8 @@ class vmmConnection(vmmGObject):
self._change_state(self._STATE_CONNECTING)
logging.debug("Scheduling background open thread for " +
self.get_uri())
logging.debug("Scheduling background open thread for %s",
self.get_uri())
self._start_thread(self._open_thread, "Connect %s" % self.get_uri())
def _do_creds_password(self, creds):

View File

@ -182,7 +182,7 @@ class Installer(object):
Remove any temporary files retrieved during installation
"""
for f in self._tmpfiles:
logging.debug("Removing " + f)
logging.debug("Removing %s", str(f))
os.unlink(f)
for vol in self._tmpvols:

View File

@ -247,8 +247,8 @@ class Interface(XMLBuilder):
try:
iface.undefine()
except Exception as e:
logging.debug("Error cleaning up interface after failure: " +
"%s" % str(e))
logging.debug("Error cleaning up interface after failure: %s",
str(e))
raise RuntimeError(errmsg)
return iface

View File

@ -540,8 +540,8 @@ class StoragePool(_StorageObject):
try:
pool.undefine()
except Exception as e:
logging.debug("Error cleaning up pool after failure: " +
"%s" % str(e))
logging.debug("Error cleaning up pool after failure: %s",
str(e))
raise RuntimeError(errmsg)
self.conn.cache_new_pool(pool)

View File

@ -161,7 +161,7 @@ class _URLFetcher(object):
fn = fileobj.name
self._grabURL(filename, fileobj)
logging.debug("Saved file to " + fn)
logging.debug("Saved file to %s", fn)
return fn
def acquireFileContent(self, filename):
@ -300,7 +300,7 @@ class _MountedURLFetcher(_LocalURLFetcher):
dir=self.scratchdir)
mountcmd = "/bin/mount"
logging.debug("Preparing mount at " + self._srcdir)
logging.debug("Preparing mount at %s", self._srcdir)
cmd = [mountcmd, "-o", "ro", self.location[4:], self._srcdir]
logging.debug("mount cmd: %s", cmd)
@ -317,7 +317,7 @@ class _MountedURLFetcher(_LocalURLFetcher):
if not self._mounted:
return
logging.debug("Cleaning up mount at " + self._srcdir)
logging.debug("Cleaning up mount at %s", self._srcdir)
try:
if not self._in_test_suite:
cmd = ["/bin/umount", self._srcdir]