Module: check_mk
Branch: master
Commit: 124451f1fb8ddb42c9df5e71ae9a664893e3f417
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=124451f1fb8ddb…
Author: Kenneth Okoh <ko(a)mathias-kettner.de>
Date: Thu Oct 4 14:34:29 2018 +0200
Pylint no-else-return refactoring: fixed new occurences since first commit
Change-Id: I38231b6c1cc1c800343411e134419bd72d3820a7
---
checks/mssql_backup | 3 +--
cmk/gui/availability.py | 32 ++++++++++++++------------------
cmk/gui/backup.py | 12 ++++--------
cmk/gui/bi.py | 3 +--
cmk/gui/dashboard.py | 3 +--
cmk/gui/http_status.py | 13 ++++++-------
cmk/gui/inventory.py | 3 +--
cmk/gui/plugins/dashboard/utils.py | 13 +++++--------
cmk/gui/plugins/visuals/filters.py | 3 +--
cmk/gui/utils.py | 3 +--
10 files changed, 35 insertions(+), 53 deletions(-)
diff --git a/checks/mssql_backup b/checks/mssql_backup
index 57349d2..b292302 100644
--- a/checks/mssql_backup
+++ b/checks/mssql_backup
@@ -210,8 +210,7 @@ check_info['mssql_backup'] = {
def _mssql_backup_per_type_item(db_name, backup):
if backup.type is None:
return "%s UNKNOWN" % db_name
- else:
- return "%s %s" % (db_name, backup.type.title())
+ return "%s %s" % (db_name, backup.type.title())
def inventory_mssql_backup_per_type(parsed):
diff --git a/cmk/gui/availability.py b/cmk/gui/availability.py
index 9b6ef3d..cfb8851 100644
--- a/cmk/gui/availability.py
+++ b/cmk/gui/availability.py
@@ -527,8 +527,7 @@ def render_number_function(timeformat):
def render_number(n, d):
if not d:
return _("n/a")
- else:
- return ("%." + timeformat[11:] + "f%%") % ( float(n)
/ float(d) * 100.0)
+ return ("%." + timeformat[11:] + "f%%") % ( float(n) /
float(d) * 100.0)
elif timeformat == "seconds":
def render_number(n, d):
return "%d s" % n
@@ -1081,8 +1080,8 @@ def compute_availability_groups(what, av_data, avoptions):
def object_title(what, av_entry):
if what == "host":
return av_entry["host"]
- else: # service and BI
- return av_entry["host"] + " / " +
av_entry["service"]
+ # service and BI
+ return av_entry["host"] + " / " + av_entry["service"]
# Merge consecutive rows with same state
@@ -1444,8 +1443,7 @@ def layout_timeline(what, timeline_rows, considered_duration,
avoptions, style):
def render_date(ts):
if avoptions["dateformat"] == "epoch":
return str(int(ts))
- else:
- return time.strftime(time_format, time.localtime(ts))
+ return time.strftime(time_format, time.localtime(ts))
return render_date
render_date = render_date_func(time_format)
@@ -1953,22 +1951,21 @@ def cell_active(sid, avoptions):
return False
if sid == "outof_notification_period" and
avoptions["notification_period"] != "honor":
return False
- elif sid == "outof_service_period": # Never show this as a column
+ if sid == "outof_service_period": # Never show this as a column
return False
- elif sid == "in_downtime" and
avoptions["downtimes"]["include"] != "honor":
+ if sid == "in_downtime" and
avoptions["downtimes"]["include"] != "honor":
return False
- elif sid == "unmonitored" and not
avoptions["consider"]["unmonitored"]:
+ if sid == "unmonitored" and not
avoptions["consider"]["unmonitored"]:
return False
- elif sid == "flapping" and not
avoptions["consider"]["flapping"]:
+ if sid == "flapping" and not
avoptions["consider"]["flapping"]:
return False
- elif sid == "host_down" and not
avoptions["consider"]["host_down"]:
+ if sid == "host_down" and not
avoptions["consider"]["host_down"]:
return False
- elif sid in sg and sid not in sg.values():
+ if sid in sg and sid not in sg.values():
return False
- elif sid in hsg and sid not in hsg.values():
+ if sid in hsg and sid not in hsg.values():
return False
- else:
- return True
+ return True
# Check if the availability of some object is below the levels
# that are configured in the avoptions.
@@ -1980,10 +1977,9 @@ def check_av_levels(ok_seconds, av_levels, considered_duration):
warn, crit = av_levels
if perc < crit:
return 2
- elif perc < warn:
+ if perc < warn:
return 1
- else:
- return 0
+ return 0
def get_av_groups(availability_table, avoptions):
diff --git a/cmk/gui/backup.py b/cmk/gui/backup.py
index 0c87e50..b810d13 100644
--- a/cmk/gui/backup.py
+++ b/cmk/gui/backup.py
@@ -72,8 +72,7 @@ def is_site():
def mkbackup_path():
if not is_site():
return "/usr/sbin/mkbackup"
- else:
- return "%s/bin/mkbackup" % os.environ["OMD_ROOT"]
+ return "%s/bin/mkbackup" % os.environ["OMD_ROOT"]
def system_config_path():
@@ -402,8 +401,7 @@ class Job(MKBackupJob, BackupEntity):
def _cron_userspec(self):
if os.environ.get("OMD_SITE"):
return ""
- else:
- return "root "
+ return "root "
def _cron_cmdline(self):
@@ -1590,8 +1588,7 @@ class RestoreJob(MKBackupJob):
def state_file_path(self):
if not is_site():
return "/var/lib/mkbackup/restore.state"
- else:
- return "/tmp/restore-%s.state" % os.environ["OMD_SITE"]
+ return "/tmp/restore-%s.state" % os.environ["OMD_SITE"]
def complete(self):
@@ -1717,8 +1714,7 @@ class PageBackupRestore(object):
backup_info = self._target.get_backup(backup_ident)
if backup_info["config"]["encrypt"] != None:
return self._start_encrypted_restore(backup_ident, backup_info)
- else:
- return self._start_unencrypted_restore(backup_ident)
+ return self._start_unencrypted_restore(backup_ident)
def _complete_restore(self, backup_ident):
diff --git a/cmk/gui/bi.py b/cmk/gui/bi.py
index 4938185..826e64c 100644
--- a/cmk/gui/bi.py
+++ b/cmk/gui/bi.py
@@ -3635,8 +3635,7 @@ def get_state_name(node):
if node[1]['type'] == NT_LEAF:
if 'service' in node[1]:
return service_state_names[node[0]['state']]
- else:
- return host_state_names[node[0]['state']]
+ return host_state_names[node[0]['state']]
return service_state_names[node[0]['state']]
diff --git a/cmk/gui/dashboard.py b/cmk/gui/dashboard.py
index 1b5d2b1..cce3321 100644
--- a/cmk/gui/dashboard.py
+++ b/cmk/gui/dashboard.py
@@ -213,8 +213,7 @@ class LegacyDashlet(cmk.gui.plugins.dashboard.IFrameDashlet):
title_func = self._spec.get("title_func")
if title_func:
return title_func(self._dashlet_spec)
- else:
- return self.title()
+ return self.title()
def on_resize(self):
diff --git a/cmk/gui/http_status.py b/cmk/gui/http_status.py
index 2061f3c..d93206d 100644
--- a/cmk/gui/http_status.py
+++ b/cmk/gui/http_status.py
@@ -80,15 +80,14 @@ def status_with_reason(code):
# type: (int) -> str
if code == HTTP_OK:
return '200 OK'
- elif code == HTTP_MOVED_TEMPORARILY:
+ if code == HTTP_MOVED_TEMPORARILY:
return '301 Moved Permanently'
- elif code == HTTP_MOVED_PERMANENTLY:
+ if code == HTTP_MOVED_PERMANENTLY:
return '302 Found'
- elif code == HTTP_NOT_MODIFIED:
+ if code == HTTP_NOT_MODIFIED:
return '304 Not Modified'
- elif code == HTTP_INTERNAL_SERVER_ERROR:
+ if code == HTTP_INTERNAL_SERVER_ERROR:
return '500 Internal Server Error'
- elif code == HTTP_NOT_FOUND:
+ if code == HTTP_NOT_FOUND:
return '404 Not Found'
- else:
- return str(code)
+ return str(code)
diff --git a/cmk/gui/inventory.py b/cmk/gui/inventory.py
index a98d1d6..0a0a409 100644
--- a/cmk/gui/inventory.py
+++ b/cmk/gui/inventory.py
@@ -389,8 +389,7 @@ def _may_see(host_name, site):
if not result:
return False
- else:
- return result[0] > 0
+ return result[0] > 0
def _write_xml(response):
diff --git a/cmk/gui/plugins/dashboard/utils.py b/cmk/gui/plugins/dashboard/utils.py
index cd6c5b2..c8f3779 100644
--- a/cmk/gui/plugins/dashboard/utils.py
+++ b/cmk/gui/plugins/dashboard/utils.py
@@ -263,19 +263,17 @@ class Dashlet(object):
def _add_wato_folder_to_url(self, url):
if not self._wato_folder:
return url
- elif '/' in url:
+ if '/' in url:
return url # do not append wato_folder to non-Check_MK-urls
- elif '?' in url:
+ if '?' in url:
return url + "&wato_folder=" +
html.urlencode(self._wato_folder)
- else:
- return url + "?wato_folder=" + html.urlencode(self._wato_folder)
+ return url + "?wato_folder=" + html.urlencode(self._wato_folder)
def size(self):
if self.is_resizable():
return self._dashlet_spec.get("size", self.initial_size())
- else:
- return self.initial_size()
+ return self.initial_size()
def position(self):
@@ -295,8 +293,7 @@ class Dashlet(object):
on_refresh = self.on_refresh()
if on_refresh:
return 'function() {%s}' % on_refresh
- else:
- return '"%s"' % self._add_wato_folder_to_url(url) # url
to dashboard_dashlet.py
+ return '"%s"' % self._add_wato_folder_to_url(url) # url to
dashboard_dashlet.py
except Exception:
# Ignore the exceptions in non debug mode, assuming the exception also
occures
# while dashlet rendering, which is then shown in the dashlet itselfs.
diff --git a/cmk/gui/plugins/visuals/filters.py b/cmk/gui/plugins/visuals/filters.py
index 09fd9f1..65a6aef 100644
--- a/cmk/gui/plugins/visuals/filters.py
+++ b/cmk/gui/plugins/visuals/filters.py
@@ -229,8 +229,7 @@ class FilterAddressFamily(Filter):
family = html.var("address_family", "both")
if family == "both":
return ""
- else:
- return "Filter: host_custom_variables = ADDRESS_FAMILY %s\n" %
livestatus.lqencode(family)
+ return "Filter: host_custom_variables = ADDRESS_FAMILY %s\n" %
livestatus.lqencode(family)
declare_filter(103, FilterAddressFamily())
diff --git a/cmk/gui/utils.py b/cmk/gui/utils.py
index fc29cc3..25e62ad 100644
--- a/cmk/gui/utils.py
+++ b/cmk/gui/utils.py
@@ -51,8 +51,7 @@ def drop_dotzero(v, digits=2):
t = "%%.%df" % digits % v
if "." in t:
return t.rstrip("0").rstrip(".")
- else:
- return t
+ return t
def num_split(s):