Module: check_mk
Branch: master
Commit: 02bdf841d65af0771b4565adb6d7d72ba250a9dc
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=02bdf841d65af0…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Tue Sep 11 09:10:28 2018 +0200
Don't use globals()/vars() for dictionary-based string formatting.
Added spaces around splicing operator on the way, without them things look a
bit misleading.
Change-Id: Ia4da7f124e2967a9d2e35c2fdee9dfee17eedab2
---
agents/windows/msibuild/msi-update | 5 ++---
checks/netapp_api_fcp | 2 +-
cmk/gui/htmllib.py | 2 +-
cmk/gui/plugins/metrics/utils.py | 2 +-
doc/treasures/Event_Console/nsca2mkeventd/nsca2mkeventd | 7 ++++++-
doc/treasures/get_rrd_cache_stats | 2 +-
inventory/solaris_pkginfo | 2 +-
inventory/solaris_prtdiag | 2 +-
inventory/solaris_psrinfo | 2 +-
inventory/solaris_uname | 2 +-
omd/packages/omd/omd | 2 +-
tests/unit/web/test_table.py | 2 +-
12 files changed, 18 insertions(+), 14 deletions(-)
diff --git a/agents/windows/msibuild/msi-update b/agents/windows/msibuild/msi-update
index 9e95dce..30dc5d2 100755
--- a/agents/windows/msibuild/msi-update
+++ b/agents/windows/msibuild/msi-update
@@ -227,8 +227,8 @@ try:
lcab_files = ""
for index, lcab_file in sorted(cabinet_files):
- lcab_files += "%(source_dir)s/%(lcab_file)s " % globals()
- if os.system("lcab -n %(lcab_files)s %(work_dir)s/product.cab" % globals())
!= 0:
+ lcab_files += "%(source_dir)s/%(lcab_file)s " %
{"source_dir": source_dir, "lcab_file": lcab_file}
+ if os.system("lcab -n %(lcab_files)s %(work_dir)s/product.cab" %
{"lcab_files": lcab_files, "work_dir": work_dir}) != 0:
bail_out('Fehler!')
# Add modified product.cab
@@ -243,4 +243,3 @@ except Exception, e:
if work_dir and os.path.exists(work_dir):
shutil.rmtree(work_dir)
bail_out("Error on creating msi file: %s" % str(e))
-
diff --git a/checks/netapp_api_fcp b/checks/netapp_api_fcp
index 5321a85..744a414 100644
--- a/checks/netapp_api_fcp
+++ b/checks/netapp_api_fcp
@@ -152,7 +152,7 @@ def parse_netapp_api_fcp(info):
for what in ["avg_latency", "avg_read_latency",
"avg_write_latency"]:
if what in values:
- fcp_data[what] = get_rate("%s.%s" %(key, what), now,
int(values[what]) / 1000.0)
+ fcp_data[what] = get_rate("%s.%s" % (key, what), now,
int(values[what]) / 1000.0)
fcp_interfaces[key] = fcp_data
return fcp_interfaces
diff --git a/cmk/gui/htmllib.py b/cmk/gui/htmllib.py
index a3c585f..92fe1e6 100644
--- a/cmk/gui/htmllib.py
+++ b/cmk/gui/htmllib.py
@@ -592,7 +592,7 @@ class HTMLGenerator(OutputFunnel):
if sep.startswith(';'):
v = re.sub(';+', ';', v)
- yield ' %s=\"%s\"' %(k, v)
+ yield ' %s=\"%s\"' % (k, v)
for k in options:
yield " %s=\'\'" % k
diff --git a/cmk/gui/plugins/metrics/utils.py b/cmk/gui/plugins/metrics/utils.py
index a49c3fc..0f42dfa 100644
--- a/cmk/gui/plugins/metrics/utils.py
+++ b/cmk/gui/plugins/metrics/utils.py
@@ -51,7 +51,7 @@ class AutomaticDict(OrderedDict):
def append(self, item):
- self["%s_%i" %(self._list_identifier, self._item_index)] = item
+ self["%s_%i" % (self._list_identifier, self._item_index)] = item
self._item_index += 1
# TODO: Refactor to plugin_registry structures
diff --git a/doc/treasures/Event_Console/nsca2mkeventd/nsca2mkeventd
b/doc/treasures/Event_Console/nsca2mkeventd/nsca2mkeventd
index b1ec8bd..9c25f5c 100755
--- a/doc/treasures/Event_Console/nsca2mkeventd/nsca2mkeventd
+++ b/doc/treasures/Event_Console/nsca2mkeventd/nsca2mkeventd
@@ -45,6 +45,7 @@ def verbose(txt):
if opt_verbose:
log(txt)
+
def usage():
sys.stdout.write('''Usage: nsca2mkeventd [OPTIONS]
@@ -60,7 +61,11 @@ Default paths:
Event Pipe: %(g_pipe_path)s
Log file: %(g_logfile_path)s
-''' % globals())
+''' % {
+ "g_eventsocket_path": g_eventsocket_path,
+ "g_pipe_path": g_pipe_path,
+ "g_logfile_path": g_logfile_path,
+})
#.
# .--Daemonize-----------------------------------------------------------.
diff --git a/doc/treasures/get_rrd_cache_stats b/doc/treasures/get_rrd_cache_stats
index b03e2ef..9b39ec7 100755
--- a/doc/treasures/get_rrd_cache_stats
+++ b/doc/treasures/get_rrd_cache_stats
@@ -21,7 +21,7 @@ try:
stats[key[:len(key)-1]] = int(value)
for key, value in stats.items():
- print "%-15s :%15d" %(key, value)
+ print "%-15s :%15d" % (key, value)
except:
sys.stderr.write("Unable to retrieve statistics.\n")
diff --git a/inventory/solaris_pkginfo b/inventory/solaris_pkginfo
index 0196639..a821ed0 100644
--- a/inventory/solaris_pkginfo
+++ b/inventory/solaris_pkginfo
@@ -72,7 +72,7 @@ def inv_solaris_pkginfo(info):
elif key == "NAME":
# build a dict for each package initiator = PKGINST
# concat solaris pkginst and name to mk inventory name and write to dict
- entry = {'name' : "%s - %s" %(pkginst, value) }
+ entry = {'name' : "%s - %s" % (pkginst, value) }
elif key == "INSTDATE":
# 'try, except' blog is necessary because date conversion may fail
because of non en_US
# locale settings on the remote solaris server
diff --git a/inventory/solaris_prtdiag b/inventory/solaris_prtdiag
index d67c193..b0f9ce3 100644
--- a/inventory/solaris_prtdiag
+++ b/inventory/solaris_prtdiag
@@ -91,7 +91,7 @@ def inv_solaris_prtdiag(info):
if line[0].startswith('OBP'):
node = inv_tree("hardware.bios.")
bios_info = line[0].split()
- node["version"] = "%s %s" %(bios_info[0], bios_info[1])
+ node["version"] = "%s %s" % (bios_info[0], bios_info[1])
formated_date = bios_info[2] + bios_info[3]
node["date"] = int(time.mktime(time.strptime(formated_date,
"%Y/%m/%d%H:%M")))
node["vendor"] = "Oracle"
diff --git a/inventory/solaris_psrinfo b/inventory/solaris_psrinfo
index 596e1d1..48d0d3c 100644
--- a/inventory/solaris_psrinfo
+++ b/inventory/solaris_psrinfo
@@ -57,7 +57,7 @@
def inv_solaris_psrinfo(info):
node = inv_tree("hardware.cpu.")
node["Model"] = info[-1][0]
- node["Maximum Speed"] = "%s %s" %(info[-1][-2],
info[-1][-1].strip(')') )
+ node["Maximum Speed"] = "%s %s" % (info[-1][-2],
info[-1][-1].strip(')') )
inv_info['solaris_psrinfo'] = {
diff --git a/inventory/solaris_uname b/inventory/solaris_uname
index 0080c34..8de342d 100644
--- a/inventory/solaris_uname
+++ b/inventory/solaris_uname
@@ -32,7 +32,7 @@ def inv_solaris_uname(info):
node["vendor"] = "Oracle"
node["type"] = solaris_uname["System"]
node["version"] = solaris_uname["Release"]
- node["name"] = "%s %s"
%(solaris_uname["System"],solaris_uname["Release"])
+ node["name"] = "%s %s" %
(solaris_uname["System"],solaris_uname["Release"])
node["kernel_version"] = solaris_uname["KernelID"]
node["hostname"] = solaris_uname["Node"]
diff --git a/omd/packages/omd/omd b/omd/packages/omd/omd
index 678afc4..f3efb4e 100644
--- a/omd/packages/omd/omd
+++ b/omd/packages/omd/omd
@@ -4380,7 +4380,7 @@ def parse_command_options(args, options_spec):
sys.stdout.write("Possible options for this command:\n")
for llong, sshort, needarg, help in options_spec:
args_text = "%s--%s" % (sshort and "-%s," % sshort or
"", llong)
- sys.stdout.write(" %-15s %3s %s\n" %(args_text, needarg and
"ARG" or "", help))
+ sys.stdout.write(" %-15s %3s %s\n" % (args_text, needarg and
"ARG" or "", help))
sys.exit(0)
options = {}
diff --git a/tests/unit/web/test_table.py b/tests/unit/web/test_table.py
index e0a42dc..ec78c0a 100644
--- a/tests/unit/web/test_table.py
+++ b/tests/unit/web/test_table.py
@@ -215,5 +215,5 @@ def test_table_cubical(register_builtin_html, monkeypatch, sortable,
searchable,
limit = len(rows)
# Assert data correctness
- assert len(data) <= limit, 'Wrong number of rows: Got %s, should be <=
%s' %(len(data), limit)
+ assert len(data) <= limit, 'Wrong number of rows: Got %s, should be <=
%s' % (len(data), limit)
assert data == rows[:limit], "Incorrect data: %s\n\nVS\n%s" % (data,
rows[:limit])