Module: check_mk
Branch: master
Commit: b6ac001baf182b145ab8d0dd634af36444763bd8
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b6ac001baf182b…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Wed Jul 11 16:12:01 2018 +0200
Fixed a few misplaced-comparison-constant warnings.
Unless you're Yoda, putting the constant last feels more natural...
Change-Id: I9c1c504e16ea6e82f57982a05f1a07b4284a58dd
---
checks/esx_vsphere_vm | 2 +-
checks/saprouter_cert | 6 +++---
cmk/man_pages.py | 2 +-
cmk_base/localize.py | 2 +-
omd/packages/omd/omd | 16 ++++++++--------
5 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/checks/esx_vsphere_vm b/checks/esx_vsphere_vm
index 5af5707..6d4a1ee 100644
--- a/checks/esx_vsphere_vm
+++ b/checks/esx_vsphere_vm
@@ -412,7 +412,7 @@ def check_esx_vsphere_vm_snapshots(_no_item, params, info):
elif oldest_time == snapshot[1]:
oldest_snapshot = snapshot
- if "poweredOn" == snapshot[2]:
+ if snapshot[2] == "poweredOn":
powered_on_snapshot = snapshot
yield 0, "Powered On: %s" % (powered_on_snapshot and
powered_on_snapshot[3] or "None")
diff --git a/checks/saprouter_cert b/checks/saprouter_cert
index f2dac8a..60358b1 100644
--- a/checks/saprouter_cert
+++ b/checks/saprouter_cert
@@ -59,7 +59,7 @@ def parse_saprouter_cert(info):
parsed = {}
validity = None
for line in info:
- if "Validity" == line[0]:
+ if line[0] == "Validity":
validity = "valid"
parsed.setdefault(validity, {})
@@ -69,10 +69,10 @@ def parse_saprouter_cert(info):
elif validity and ("NotAfter:" in line or "NotAfter" in
line):
parsed[validity].setdefault("not_after", parse_date(line[-5:-1]))
- elif "sso for user" == " ".join(line[:3]).lower():
+ elif " ".join(line[:3]).lower() == "sso for user":
parsed.setdefault("sso_user", line[-1].replace('"',
""))
- elif "with pse file" == " ".join(line[:3]).lower():
+ elif " ".join(line[:3]).lower() == "with pse file":
parsed.setdefault("pse_file", line[-1].replace('"',
""))
elif not validity:
diff --git a/cmk/man_pages.py b/cmk/man_pages.py
index 2d75424..412b195 100644
--- a/cmk/man_pages.py
+++ b/cmk/man_pages.py
@@ -413,7 +413,7 @@ def _run_dialog(args):
p = subprocess.Popen(["dialog", "--shadow"] + args, env = env,
stderr = subprocess.PIPE)
response = p.stderr.read()
- return 0 == os.waitpid(p.pid, 0)[1], response
+ return os.waitpid(p.pid, 0)[1] == 0, response
def _create_fallback_man_page(name, path, error_message):
diff --git a/cmk_base/localize.py b/cmk_base/localize.py
index 64a5c1a..0f61cb7 100644
--- a/cmk_base/localize.py
+++ b/cmk_base/localize.py
@@ -232,7 +232,7 @@ def localize_edit(lang):
if not os.path.exists(editor):
editor = 'vi'
- if 0 == subprocess.call([editor, po_file]):
+ if subprocess.call([editor, po_file]) == 0:
localize_compile(lang)
else:
logger.error("Aborted.")
diff --git a/omd/packages/omd/omd b/omd/packages/omd/omd
index e98b329..e2319bf 100644
--- a/omd/packages/omd/omd
+++ b/omd/packages/omd/omd
@@ -214,7 +214,7 @@ def patch_has_merge():
# check wether our version of patch supports the option '--merge'
global patch_supports_merge
if patch_supports_merge == None:
- patch_supports_merge = (0 == os.system("true |
PATH=/omd/versions/default/bin:$PATH patch --merge >/dev/null 2>&1"))
+ patch_supports_merge = (os.system("true |
PATH=/omd/versions/default/bin:$PATH patch --merge >/dev/null 2>&1") == 0)
if not patch_supports_merge:
sys.stdout.write("Your version of patch does not support
--merge.\n")
return patch_supports_merge
@@ -227,7 +227,7 @@ def run_dialog(args):
}
p = Popen(["dialog", "--shadow"] + args, env = env, stderr =
PIPE)
response = p.stderr.read()
- return 0 == os.waitpid(p.pid, 0)[1], response
+ return os.waitpid(p.pid, 0)[1] == 0, response
def dialog_menu(title, text, choices, defvalue, oktext, canceltext):
@@ -420,7 +420,7 @@ def groupadd(groupname, gid = None):
cmd += "-g %d " % int(gid)
cmd += groupname
- if 0 != os.system(cmd):
+ if os.system(cmd) != 0:
bail_out("Cannot create group for site user.")
def useradd(sitename, uid = None, gid = None):
@@ -429,8 +429,8 @@ def useradd(sitename, uid = None, gid = None):
useradd_options = g_info["USERADD_OPTIONS"]
if uid != None:
useradd_options += " -u %d" % int(uid)
- if 0 != os.system("useradd %s -r -d '%s' -c 'OMD site %s' -g %s
-G omd %s -s /bin/bash" % \
- (useradd_options, site_dir(sitename), sitename, sitename,
sitename)):
+ if os.system("useradd %s -r -d '%s' -c 'OMD site %s' -g %s -G
omd %s -s /bin/bash" % \
+ (useradd_options, site_dir(sitename), sitename, sitename, sitename)) !=
0:
groupdel(sitename)
bail_out("Error creating site user.")
@@ -1163,7 +1163,7 @@ def merge_update_file(relpath, old_version, new_version):
elif choice == "try again":
os.rename(user_path + ".orig", user_path)
os.system("%s '%s'" % (editor, user_path))
- if 0 == try_merge():
+ if try_merge() == 0:
sys.stdout.write("Successfully merged changes from %s -> %s into
%s\n" %
(old_version, new_version, fn))
return
@@ -1629,7 +1629,7 @@ def unmount_tmpfs(sitename, output = True, kill = False):
sys.stdout.write("Unmounting temporary filesystem...")
for t in range(0, 10):
- if 0 == os.system("umount '%s'" % tmp_dir(sitename)):
+ if os.system("umount '%s'" % tmp_dir(sitename)) == 0:
if output:
ok()
return True
@@ -3142,7 +3142,7 @@ def print_diff(rel_path, source_path, target_path, source_version,
source_perms)
arrow = tty_magenta + '->' + tty_normal
if 'c' in status:
source_content = instantiate_skel(source_file)
- if 0 == os.system("which colordiff > /dev/null
2>&1"):
+ if os.system("which colordiff > /dev/null 2>&1") ==
0:
diff = "colordiff"
else:
diff = "diff"