File NagAconda-0.2.1-python3.patch of Package python-NagAconda
Index: NagAconda-0.2.1/NagAconda/Plugin.py
===================================================================
--- NagAconda-0.2.1.orig/NagAconda/Plugin.py
+++ NagAconda-0.2.1/NagAconda/Plugin.py
@@ -141,7 +141,7 @@ class Plugin:
# Before we really do anything, make sure a warning or critical
# threshold were even set.
- print 'range was ' + range_type
+ print('range was ' + range_type)
range_list = self.__warning
if range_type == 'critical':
@@ -160,14 +160,14 @@ class Plugin:
if len(range_list) < threshold:
if range_type not in self.__req_option:
return
- raise UserWarning, (
+ raise UserWarning (
"Please set part %s of the %s threshold!" % (
threshold, range_type))
# The option parser should have already split these into proper
# bottom, top, and match inversion, so long as the array element
# is defined Perform our range test and set the exit status.
- print range_list[threshold-1]
+ print(range_list[threshold-1])
(bottom, top, invert) = range_list[threshold-1]
if ((not invert and (val < bottom or val > top)) or
@@ -175,7 +175,7 @@ class Plugin:
self.__exit_status = range_type
self.__perf[name]['state'] = range_type
- print "%s:%s:%s = %s" % (val, bottom, top, ((val < bottom) or (val > top)))
+ print("%s:%s:%s = %s" % (val, bottom, top, ((val < bottom) or (val > top))))
def add_option(self, flag, name, helptext, **kwargs):
"""
@@ -200,7 +200,7 @@ class Plugin:
opt_usage = "-%s %s" % (flag, name.upper())
- if kwargs.has_key('required') and kwargs['required'] is True:
+ if 'required' in kwargs and kwargs['required'] is True:
self.__req_option.append(name)
else:
opt_usage = "[%s]" % opt_usage
@@ -298,7 +298,7 @@ class Plugin:
if self.__exit_message is not None:
exit_status += ', %s' % self.__exit_message
- print 'Status ' + exit_status + perf_string
+ print('Status ' + exit_status + perf_string)
sys.exit(exit_value)
def set_range(self, range_type, range_end, range_start=0,
@@ -415,20 +415,20 @@ class Plugin:
val_dict = {'val': val, 'min': None, 'max': None, 'scale': None,
'threshold': 1, 'state': 'ok'}
- if kwargs.has_key('lowest'):
+ if 'lowest' in kwargs:
val_dict['min'] = float(kwargs.get('lowest'))
- if kwargs.has_key('highest'):
+ if 'highest' in kwargs:
val_dict['max'] = float(kwargs.get('highest'))
- if kwargs.has_key('threshold'):
+ if 'threshold' in kwargs:
val_dict['threshold'] = kwargs['threshold']
# Nagios actually understands most byte and time oriented scales.
# The developer docs also list a counter scale, but we're not certain
# if any plugin has ever used that. Only accept known scales.
- if kwargs.has_key('scale'):
+ if 'scale' in kwargs:
scale = kwargs.get('scale')
if scale.upper() in ('B', 'KB', 'MB', 'GB', 'TB'):
@@ -445,11 +445,11 @@ class Plugin:
# variable is set so we don't have to loop through all of them later.
if len(self.__warning) > 0:
- print "checking warning"
+ print("checking warning")
self.__check_range('warning', name)
if len(self.__critical) > 0:
- print "checking critical"
+ print("checking critical")
self.__check_range('critical', name)
return self.__perf[name]['state']
@@ -544,7 +544,7 @@ class Plugin:
:type message: string
"""
- print 'Status Unknown: ' + message
+ print('Status Unknown: ' + message)
sys.exit(3)
def convert_range(option, opt_str, value, parser):
Index: NagAconda-0.2.1/NagAconda/__init__.py
===================================================================
--- NagAconda-0.2.1.orig/NagAconda/__init__.py
+++ NagAconda-0.2.1/NagAconda/__init__.py
@@ -16,5 +16,5 @@ greatly simplify the process of actually
__version__ = "0.2.1"
-from Plugin import *
+from .Plugin import *
Index: NagAconda-0.2.1/test/test_operation.py
===================================================================
--- NagAconda-0.2.1.orig/test/test_operation.py
+++ NagAconda-0.2.1/test/test_operation.py
@@ -30,7 +30,7 @@ class TestOperation(PlugTest):
self.plugin.start()
self.plugin.set_value('foo', 9)
self.plugin.finish()
- except SystemExit, e:
+ except SystemExit as e:
assert e.code == 0
else:
assert False
@@ -49,7 +49,7 @@ class TestOperation(PlugTest):
self.plugin.start()
self.plugin.set_value('foo', 11)
self.plugin.finish()
- except SystemExit, e:
+ except SystemExit as e:
assert e.code == 1
else:
assert False
@@ -70,7 +70,7 @@ class TestOperation(PlugTest):
self.plugin.start()
self.plugin.set_value('foo', 16)
self.plugin.finish()
- except SystemExit, e:
+ except SystemExit as e:
assert e.code == 2
else:
assert False
@@ -85,7 +85,7 @@ class TestOperation(PlugTest):
"""
try:
self.plugin.unknown_error('Something Explodey happened')
- except SystemExit, e:
+ except SystemExit as e:
assert e.code == 3
else:
assert False
Index: NagAconda-0.2.1/test/test_options.py
===================================================================
--- NagAconda-0.2.1.orig/test/test_options.py
+++ NagAconda-0.2.1/test/test_options.py
@@ -27,8 +27,8 @@ class TestOptions(PlugTest):
try:
self.plugin.start()
- except SystemExit, e:
- print dir(e)
+ except SystemExit as e:
+ print(dir(e))
assert True
else:
assert False
Index: NagAconda-0.2.1/test/test_ranges.py
===================================================================
--- NagAconda-0.2.1.orig/test/test_ranges.py
+++ NagAconda-0.2.1/test/test_ranges.py
@@ -93,7 +93,7 @@ class TestRanges(PlugTest):
15: 'warning', 17: 'critical' }
for (t_val, t_status) in expected.items():
- print "Testing %s for %s" % (t_val, t_status)
+ print("Testing %s for %s" % (t_val, t_status))
assert self.plugin.set_value('test', t_val) == t_status