Skip to content

Commit

Permalink
Merge pull request #979 from aleskxyz/patch-1
Browse files Browse the repository at this point in the history
Refactor return value of check_for_error to None for all servers
  • Loading branch information
HenriWahl authored Oct 31, 2023
2 parents d0dc7b1 + 6dffdf5 commit a9f40f5
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Nagstamon/Servers/Alertmanager/alertmanagerserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def _get_status(self):

# check if any error occured
errors_occured = self.check_for_error(data, error, status_code)
if errors_occured is not False:
if errors_occured is not None:
return errors_occured

for alert in data:
Expand Down
10 changes: 5 additions & 5 deletions Nagstamon/Servers/Centreon/CentreonLegacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ def _get_status(self):
errors_occured = self.check_for_error(xmlobj, error, status_code)

# if there are errors return them
if errors_occured:
if errors_occured is not None:
return(errors_occured)

# Check if the result is not empty
Expand All @@ -625,7 +625,7 @@ def _get_status(self):
xmlobj, error, status_code = result.result, result.error, result.status_code
errors_occured = self.check_for_error(xmlobj, error, status_code)
# if there are errors return them
if errors_occured:
if errors_occured is not None:
return(errors_occured)

# a second time a bad session id should raise an error
Expand Down Expand Up @@ -690,7 +690,7 @@ def _get_status(self):
# check if any error occured
errors_occured = self.check_for_error(xmlobj, error, status_code)
# if there are errors return them
if errors_occured:
if errors_occured is not None:
return(errors_occured)

# Check if the result is not empty
Expand All @@ -710,7 +710,7 @@ def _get_status(self):
xmlobj, error, status_code = result.result, result.error, result.status_code
errors_occured = self.check_for_error(xmlobj, error, status_code)
# if there are errors return them
if errors_occured:
if errors_occured is not None:
return(errors_occured)

# a second time a bad session id should raise an error
Expand All @@ -735,7 +735,7 @@ def _get_status(self):
errors_occured = self.check_for_error(xmlobj_meta, error_meta, status_code_meta)

# if there are errors return them
if errors_occured:
if errors_occured is not None:
return(errors_occured)

# a second time a bad session id should raise an error
Expand Down
4 changes: 2 additions & 2 deletions Nagstamon/Servers/Generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ def _get_status(self):
# check if any error occured
errors_occured = self.check_for_error(htobj, error, status_code)
# if there are errors return them
if errors_occured is not False:
if errors_occured is not None:
return(errors_occured)

# put a copy of a part of htobj into table to be able to delete htobj
Expand Down Expand Up @@ -773,7 +773,7 @@ def _get_status(self):
# check if any error occured
errors_occured = self.check_for_error(htobj, error, status_code)
# if there are errors return them
if errors_occured is not False:
if errors_occured is not None:
return(errors_occured)

# too much copy.deepcopy()s here give recursion crashs
Expand Down
8 changes: 4 additions & 4 deletions Nagstamon/Servers/Icinga.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def _get_status_JSON(self):
# check if any error occured
errors_occured = self.check_for_error(jsonraw, error, status_code)
# if there are errors return them
if errors_occured:
if errors_occured is not None:
return(errors_occured)

jsondict = json.loads(jsonraw)
Expand Down Expand Up @@ -231,7 +231,7 @@ def _get_status_JSON(self):
# check if any error occured
errors_occured = self.check_for_error(jsonraw, error, status_code)
# if there are errors return them
if errors_occured:
if errors_occured is not None:
return(errors_occured)

jsondict = json.loads(jsonraw)
Expand Down Expand Up @@ -339,7 +339,7 @@ def _get_status_HTML(self):
# check if any error occured
errors_occured = self.check_for_error(htobj, error, status_code)
# if there are errors return them
if errors_occured:
if errors_occured is not None:
return(errors_occured)

# put a copy of a part of htobj into table to be able to delete htobj
Expand Down Expand Up @@ -468,7 +468,7 @@ def _get_status_HTML(self):
# check if any error occured
errors_occured = self.check_for_error(htobj, error, status_code)
# if there are errors return them
if errors_occured:
if errors_occured is not None:
return(errors_occured)

table = htobj('table', {'class': 'status'})[0]
Expand Down
2 changes: 1 addition & 1 deletion Nagstamon/Servers/IcingaDBWeb.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def _get_status(self):

# check if any error occured
potential_error = self.check_for_error(jsonraw, error, status_code)
if potential_error:
if potential_error is not None:
return potential_error

# Check if the backend is running
Expand Down
2 changes: 1 addition & 1 deletion Nagstamon/Servers/IcingaDBWebNotifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def _update_new_host_content(self) -> Result:

# check if any error occurred
potential_error = self.check_for_error(result.result, result.error, result.status_code)
if potential_error:
if potential_error is not None:
return potential_error

# HEALTH CHECK
Expand Down
2 changes: 1 addition & 1 deletion Nagstamon/Servers/Opsview.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def _get_status(self):
# check if any error occured
errors_occured = self.check_for_error(data, error, status_code)
# if there are errors return them
if errors_occured:
if errors_occured is not None:
return errors_occured

if conf.debug_mode:
Expand Down
2 changes: 1 addition & 1 deletion Nagstamon/Servers/Prometheus.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def _get_status(self):

# check if any error occured
errors_occured = self.check_for_error(data, error, status_code)
if errors_occured is not False:
if errors_occured is not None:
return(errors_occured)

if conf.debug_mode:
Expand Down
4 changes: 2 additions & 2 deletions Nagstamon/Servers/Thruk.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def _get_status(self):
# check if any error occured
errors_occured = self.check_for_error(jsonraw, error, status_code)
# if there are errors return them
if errors_occured:
if errors_occured is not None:
return(errors_occured)

# in case basic auth did not work try form login cookie based login
Expand Down Expand Up @@ -327,7 +327,7 @@ def _get_status(self):
# check if any error occured
errors_occured = self.check_for_error(jsonraw, error, status_code)
# if there are errors return them
if errors_occured:
if errors_occured is not None:
return(errors_occured)

# in case basic auth did not work try form login cookie based login
Expand Down
4 changes: 2 additions & 2 deletions Nagstamon/Servers/op5Monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def _get_status(self):
# check if any error occured
errors_occured = self.check_for_error(data, error, status_code)
# if there are errors return them
if errors_occured:
if errors_occured is not None:
return(errors_occured)

if data['count']:
Expand Down Expand Up @@ -212,7 +212,7 @@ def _get_status(self):
# check if any error occured
errors_occured = self.check_for_error(data, error, status_code)
# if there are errors return them
if errors_occured:
if errors_occured is not None:
return(errors_occured)

if data['count']:
Expand Down

0 comments on commit a9f40f5

Please sign in to comment.