Skip to content
This repository was archived by the owner on Jan 22, 2026. It is now read-only.

Commit a5f1212

Browse files
committed
Specify all logging string format args as function parameters
As warned about by pylint.
1 parent ce0afbf commit a5f1212

26 files changed

Lines changed: 160 additions & 162 deletions

tests/clonetest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def testRemoteWithStorage(self):
180180
"when it shouldn't.")
181181
except (ValueError, RuntimeError), e:
182182
# Exception expected
183-
logging.debug("Received expected exception: %s" % str(e))
183+
logging.debug("Received expected exception: %s", str(e))
184184
finally:
185185
CloneManager._util.is_uri_remote = oldfunc
186186

@@ -229,4 +229,4 @@ def testCloneManagedToUnmanaged(self):
229229
raise AssertionError("Managed to unmanaged succeeded, expected "
230230
"failure.")
231231
except (ValueError, RuntimeError), e:
232-
logging.debug("Received expected exception: %s" % str(e))
232+
logging.debug("Received expected exception: %s", str(e))

tests/interface.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def define_xml(self, obj, compare=True):
7171
iface = obj.install()
7272

7373
newxml = iface.XMLDesc(0)
74-
logging.debug("Defined XML:\n%s" % newxml)
74+
logging.debug("Defined XML:\n%s", newxml)
7575

7676
iface.undefine()
7777

tests/pylint-virtinst.sh

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ addchecker() {
9797
addmsg_support() {
9898
out=`pylint --list-msgs 2>&1`
9999
if `echo $out | grep -q $1` ; then
100+
echo "adding!"
100101
addmsg "$1"
101102
fi
102103
}
@@ -114,20 +115,18 @@ addmsg "W0703" # W0703: Catch 'Exception'
114115
addmsg "W0704" # W0704: Exception doesn't do anything
115116
addmsg "W0702" # W0702: No exception type specified
116117
addmsg "R0201" # R0201: Method could be a function
118+
addchecker "Design" # Things like "Too many func arguments",
119+
# "Too man public methods"
117120

118121
# Possibly useful at some point
119122
addmsg "W0403" # W0403: Relative imports
120-
addmsg "W0511" # W0511: FIXME and XXX: messages (useful in the future)
123+
addmsg "W0511" # W0511: FIXME and XXX: messages
121124
addmsg "R0401" # R0401: Cyclic imports
125+
addchecker "Similarities" # Finds duplicate code
122126

123127
# Not supported in many pylint versions
124-
addmsg_support "W6501" # W6501: Using string formatters in logging message
125-
# (see help message for info)
128+
# Put new messages here with addmsg_support
126129

127-
# Disabled Checkers:
128-
addchecker "Design" # Things like "Too many func arguments",
129-
# "Too man public methods"
130-
addchecker "Similarities" # Finds duplicate code (enable this later?)
131130

132131
AWK=awk
133132
[ `uname -s` = 'SunOS' ] && AWK=nawk

tests/urltest.py

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -242,22 +242,22 @@ def _fetchLocalMedia(self, mediapath):
242242

243243
# Make sure we detect _a_ distro
244244
hvmstore = self._getStore(fetcher, mediapath, "hvm", arch)
245-
logging.debug("Local distro detected as: %s" % hvmstore)
245+
logging.debug("Local distro detected as: %s", hvmstore)
246246
finally:
247247
fetcher.cleanupLocation()
248248

249249

250250
def _fetchFromURLDict(self, distname, url, arch, distro_info, check_xen):
251-
logging.debug("\nDistro='%s' arch='%s' url=%s" % \
252-
(distname, arch, url))
251+
logging.debug("\nDistro='%s' arch='%s' url=%s",
252+
distname, arch, url)
253253

254254
fetcher = OSDistro._fetcherForURI(url, "/tmp")
255255
try:
256256
fetcher.prepareLocation()
257257
except Exception, e:
258258
# Don't raise an error here: the site might be down atm
259-
logging.error("%s-%s: Couldn't access url %s: %s. Skipping." % \
260-
(distname, arch, fetcher.location, str(e)))
259+
logging.error("%s-%s: Couldn't access url %s: %s. Skipping.",
260+
distname, arch, fetcher.location, str(e))
261261
fetcher.cleanupLocation()
262262
return
263263

@@ -303,8 +303,8 @@ def _grabURLMedia(self, fetcher, distname, url, arch, distro_info,
303303
exp_store = distroClass(distname)
304304
for s in [hvmstore, xenstore]:
305305
if s and not isinstance(s, exp_store):
306-
logging.error("(%s): expected store %s, was %s" % \
307-
(distname, exp_store, s))
306+
logging.error("(%s): expected store %s, was %s",
307+
distname, exp_store, s)
308308
self.fail()
309309

310310
# Make sure the stores are reporting correct distro name/variant
@@ -318,7 +318,7 @@ def fakeAcquireFile(filename, meter):
318318
if not isinstance(meter, urlgrabber.progress.BaseMeter):
319319
raise ValueError("passed meter is '%s' not an"
320320
" actual meter." % meter)
321-
logging.debug("Fake acquiring %s" % filename)
321+
logging.debug("Fake acquiring %s", filename)
322322
return fetcher.hasFile(filename)
323323

324324
# Replace acquireFile with hasFile, so we don't actually have to fetch
@@ -328,47 +328,47 @@ def fakeAcquireFile(filename, meter):
328328
# Fetch boot iso
329329
try:
330330
if re.match(r"%s" % NOBOOTISO_FILTER, distname):
331-
logging.debug("Known lack of boot.iso in %s tree. Skipping." \
332-
% distname)
331+
logging.debug("Known lack of boot.iso in %s tree. Skipping.",
332+
distname)
333333
else:
334334
boot = hvmstore.acquireBootDisk(testguest, fetcher, self.meter)
335-
logging.debug("acquireBootDisk: %s" % str(boot))
335+
logging.debug("acquireBootDisk: %s", str(boot))
336336

337337
if boot != True:
338338
raise RuntimeError("Didn't fetch any boot iso.")
339339
except Exception, e:
340-
logging.exception("%s-%s: bootdisk fetching: %s" %
341-
(distname, arch, str(e)))
340+
logging.exception("%s-%s: bootdisk fetching: %s",
341+
distname, arch, str(e))
342342
self.fail()
343343

344344
# Fetch regular kernel
345345
try:
346346
kern = hvmstore.acquireKernel(testguest, fetcher, self.meter)
347-
logging.debug("acquireKernel (hvm): %s" % str(kern))
347+
logging.debug("acquireKernel (hvm): %s", str(kern))
348348

349349
if kern[0] is not True or kern[1] is not True:
350350
raise RuntimeError("Didn't fetch any hvm kernel.")
351351
except Exception, e:
352-
logging.exception("%s-%s: hvm kernel fetching: %s" %
353-
(distname, arch, str(e)))
352+
logging.exception("%s-%s: hvm kernel fetching: %s",
353+
distname, arch, str(e))
354354
self.fail()
355355

356356
# Fetch xen kernel
357357
try:
358358
if xenstore and check_xen:
359359
kern = xenstore.acquireKernel(testguest, fetcher, self.meter)
360-
logging.debug("acquireKernel (xen): %s" % str(kern))
360+
logging.debug("acquireKernel (xen): %s", str(kern))
361361

362362
if kern[0] is not True or kern[1] is not True:
363363
raise RuntimeError("Didn't fetch any xen kernel.")
364364
else:
365365
logging.debug("acquireKernel (xen): Hardcoded skipping.")
366366
except Exception, e:
367367
if re.match(r"%s" % EXPECT_XEN_FAIL, distname):
368-
logging.debug("%s: anticipated xen failure." % distname)
368+
logging.debug("%s: anticipated xen failure.", distname)
369369
else:
370-
logging.exception("%s-%s: xen kernel fetching: %s" %
371-
(distname, arch, str(e)))
370+
logging.exception("%s-%s: xen kernel fetching: %s",
371+
distname, arch, str(e))
372372
self.fail()
373373

374374
def _getStore(self, fetcher, url, _type, arch):
@@ -379,7 +379,7 @@ def _getStore(self, fetcher, url, _type, arch):
379379
arch=arch, typ=_type)
380380
except Exception, e:
381381
if str(e).count("502"):
382-
logging.debug("Caught proxy error: %s" % str(e))
382+
logging.debug("Caught proxy error: %s", str(e))
383383
time.sleep(.5)
384384
continue
385385
raise
@@ -397,7 +397,7 @@ def testURLFetch(self):
397397
for label in keys:
398398
distro_info = None
399399
if MATCH_FILTER and not re.match(r"%s" % MATCH_FILTER, label):
400-
logging.debug("Excluding '%s' from exclude filter." % label)
400+
logging.debug("Excluding '%s' from exclude filter.", label)
401401
continue
402402

403403
check_xen = not bool(urls[label].get("noxen"))
@@ -430,7 +430,7 @@ def testLocalMedia(self):
430430
try:
431431
self._fetchLocalMedia(p)
432432
except Exception, e:
433-
logging.exception("Local path '%s' failed: %s" % (p, e))
433+
logging.exception("Local path '%s' failed: %s", p, e)
434434
print "Local path FAILED."
435435
assertions += 1
436436

tests/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def get_conn():
7272

7373
# Register libvirt handler
7474
def libvirt_callback(ignore, err):
75-
logging.warn("libvirt errmsg: %s" % err[2])
75+
logging.warn("libvirt errmsg: %s", err[2])
7676
libvirt.registerErrorHandler(f=libvirt_callback, ctx=None)
7777

7878
def sanitize_xml_for_define(xml):

tests/validation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ def _testArgs(self, obj, testclass, name, exception_check=None,
421421
"""@obj Object to test parameters against
422422
@testclass Full class to test initialization against
423423
@name String name indexing args"""
424-
logging.debug("Testing '%s'" % name)
424+
logging.debug("Testing '%s'", name)
425425
testdict = args[name]
426426
if manual_dict != None:
427427
testdict = manual_dict

tests/xmlconfig.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class TestXMLConfig(unittest.TestCase):
5353

5454
def setUp(self):
5555
utils.reset_conn()
56-
logging.debug("Running %s" % self.id())
56+
logging.debug("Running %s", self.id())
5757

5858
def tearDown(self):
5959
if os.path.exists(utils.scratch):

virt-clone

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def get_clone_name(new_name, auto_clone, design):
3838
if not new_name and auto_clone:
3939
# Generate a name to use
4040
new_name = clmgr.generate_clone_name(design)
41-
logging.debug("Auto-generated clone name '%s'." % new_name)
41+
logging.debug("Auto-generated clone name '%s'", new_name)
4242

4343
prompt_txt = _("What is the name for the cloned virtual machine?")
4444
err_txt = _("A name is required for the new virtual machine.")

virt-convert

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -207,23 +207,23 @@ def main():
207207
if not options.output_dir:
208208
options.output_dir = unixname
209209
try:
210-
logging.debug("Creating directory %s" % options.output_dir)
210+
logging.debug("Creating directory %s", options.output_dir)
211211
if options.nodry:
212212
os.mkdir(options.output_dir)
213213
clean += [ options.output_dir ]
214214
except OSError, e:
215215
if (e.errno != errno.EEXIST):
216-
fail("Could not create directory %s: %s" %
216+
fail("Could not create directory %s: %s",
217217
(options.output_dir, e.strerror))
218218

219219
if not options.output_file:
220220
options.output_file = os.path.join(options.output_dir,
221221
"%s%s" % (unixname, outp.suffix))
222222

223-
logging.debug("input_file: %s" % options.input_file)
224-
logging.debug("input_dir: %s" % options.input_dir)
225-
logging.debug("output_file: %s" % options.output_file)
226-
logging.debug("output_dir: %s" % options.output_dir)
223+
logging.debug("input_file: %s", options.input_file)
224+
logging.debug("input_dir: %s", options.input_dir)
225+
logging.debug("output_file: %s", options.output_file)
226+
logging.debug("output_dir: %s", options.output_dir)
227227

228228
print_stdout(_("Generating output in '%(format)s' format to %(dir)s/") %
229229
{"format": options.output_format, "dir": options.output_dir})
@@ -260,7 +260,7 @@ def main():
260260

261261
try:
262262
output = outp.export(vmdef)
263-
logging.debug("Output VM config:\n%s" % output)
263+
logging.debug("Output VM config:\n%s", output)
264264

265265
if options.nodry:
266266
outfile = open(options.output_file, "w")

virt-install

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,9 @@ def get_virt_type(conn, options):
254254
req_virt_type, req_accel = prompt_virt(capabilities, options.arch,
255255
req_virt_type, req_accel)
256256

257-
logging.debug("Requesting virt method '%s', hv type '%s'." %
258-
((req_virt_type and req_virt_type or _("default")),
259-
(req_hv_type and req_hv_type or _("default"))))
257+
logging.debug("Requesting virt method '%s', hv type '%s'.",
258+
(req_virt_type and req_virt_type or _("default")),
259+
(req_hv_type and req_hv_type or _("default")))
260260

261261
arch = options.arch
262262
if re.match("i.86", arch or ""):
@@ -280,7 +280,7 @@ def get_virt_type(conn, options):
280280
_util.is_qemu(conn) and
281281
capsguest.arch in ["i686", "x86_64"] and
282282
not capsdomain.is_accelerated()):
283-
logging.warn("KVM acceleration not available, using '%s'" %
283+
logging.warn("KVM acceleration not available, using '%s'",
284284
capsdomain.hypervisor_type)
285285

286286
return (capsguest, capsdomain)
@@ -466,8 +466,8 @@ def build_guest_instance(conn, options):
466466

467467
virt_type = capsguest.os_type
468468
hv_name = capsdomain.hypervisor_type
469-
logging.debug("Received virt method '%s'" % virt_type)
470-
logging.debug("Hypervisor name is '%s'" % hv_name)
469+
logging.debug("Received virt method '%s'", virt_type)
470+
logging.debug("Hypervisor name is '%s'", hv_name)
471471

472472
# Get Guest instance from installer parameters.
473473
installer = build_installer(options, conn, virt_type, hv_name,
@@ -580,11 +580,11 @@ def start_install(guest, continue_inst, options):
580580
gtype = guest.graphics_dev.type
581581
if gtype in [virtinst.VirtualGraphics.TYPE_VNC,
582582
virtinst.VirtualGraphics.TYPE_SPICE]:
583-
logging.debug("Launching virt-viewer for graphics type '%s'" %
583+
logging.debug("Launching virt-viewer for graphics type '%s'",
584584
gtype)
585585
return vnc_console(dom, guest.get_uri())
586586
else:
587-
logging.debug("No viewer to launch for graphics type '%s'" %
587+
logging.debug("No viewer to launch for graphics type '%s'",
588588
gtype)
589589
return None # SDL needs no viewer app
590590
else:
@@ -619,7 +619,7 @@ def start_install(guest, continue_inst, options):
619619
meter = (options.quiet and
620620
progress.BaseMeter() or
621621
progress.TextMeter(fo=sys.stdout))
622-
logging.debug("Guest.has_install_phase: %s" %
622+
logging.debug("Guest.has_install_phase: %s",
623623
guest.installer.has_install_phase())
624624

625625
# we've got everything -- try to start the install
@@ -704,7 +704,7 @@ def check_domain(guest, dom, conscb, wait_for_install, wait_time, start_time):
704704
return ret
705705

706706
# Domain seems to be running
707-
logging.debug("Domain state after install: %s" % state)
707+
logging.debug("Domain state after install: %s", state)
708708

709709
if not wait_for_install or wait_time == 0:
710710
# User either:

0 commit comments

Comments
 (0)