Skip to content

Commit

Permalink
graphite module: use func mapping instead of eval('func') (ultrabug#1700
Browse files Browse the repository at this point in the history
)
  • Loading branch information
lasers authored and ultrabug committed Feb 10, 2019
1 parent b7ed3d6 commit 391d935
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions py3status/modules/graphite.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,19 +203,16 @@ def _notify_user(self):
)

def _check_threshold_and_get_color(self, displayed_value, target, value):
func = {"max": max, "min": min}
if self.threshold_bad:
if eval(
"{}(self.threshold_bad, value) == value".format(self.value_comparator)
):
test = func[self.value_comparator](self.threshold_bad, value)
if test == value:
self._store_notification(target, self.threshold_bad, displayed_value)
self.notification_level = "error"
return "bad"
if self.threshold_degraded:
if eval(
"{}(self.threshold_degraded, value) == value".format(
self.value_comparator
)
):
test = func[self.value_comparator](self.threshold_degraded, value)
if test == value:
self._store_notification(
target, self.threshold_degraded, displayed_value
)
Expand Down

0 comments on commit 391d935

Please sign in to comment.