mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-22 02:51:03 +00:00
Plugin bitcoind_: fix flake8 and python3 issues
This commit is contained in:
parent
3b4383696f
commit
fffb536e26
1 changed files with 15 additions and 14 deletions
|
@ -79,15 +79,15 @@ def main():
|
||||||
|
|
||||||
if command == 'suggest':
|
if command == 'suggest':
|
||||||
for var_name in request_labels.keys():
|
for var_name in request_labels.keys():
|
||||||
print var_name
|
print(var_name)
|
||||||
return
|
return
|
||||||
|
|
||||||
if command == 'config':
|
if command == 'config':
|
||||||
print 'graph_category htc'
|
print('graph_category htc')
|
||||||
print 'graph_title Bitcoin %s' % labels[0]
|
print('graph_title Bitcoin %s' % labels[0])
|
||||||
print 'graph_vlabel %s' % labels[1]
|
print('graph_vlabel %s' % labels[1])
|
||||||
for label in line_labels:
|
for label in line_labels:
|
||||||
print '%s.label %s' % (label, label)
|
print('%s.label %s' % (label, label))
|
||||||
return
|
return
|
||||||
|
|
||||||
# Munin should send connection options via environment vars
|
# Munin should send connection options via environment vars
|
||||||
|
@ -110,7 +110,7 @@ def main():
|
||||||
|
|
||||||
if error:
|
if error:
|
||||||
if command == 'autoconf':
|
if command == 'autoconf':
|
||||||
print 'no'
|
print('no')
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
# TODO: Better way to report errors to Munin-node.
|
# TODO: Better way to report errors to Munin-node.
|
||||||
|
@ -128,11 +128,11 @@ def main():
|
||||||
info['waiting'] = len(memory_pool)
|
info['waiting'] = len(memory_pool)
|
||||||
|
|
||||||
if command == 'autoconf':
|
if command == 'autoconf':
|
||||||
print 'yes'
|
print('yes')
|
||||||
return
|
return
|
||||||
|
|
||||||
for label in line_labels:
|
for label in line_labels:
|
||||||
print "%s.value %s" % (label, info[label])
|
print("%s.value %s" % (label, info[label]))
|
||||||
|
|
||||||
|
|
||||||
def parse_conf(filename):
|
def parse_conf(filename):
|
||||||
|
@ -151,7 +151,8 @@ def parse_conf(filename):
|
||||||
continue
|
continue
|
||||||
(var, value) = (m.group(1), m.group(2).strip())
|
(var, value) = (m.group(1), m.group(2).strip())
|
||||||
options[var] = value
|
options[var] = value
|
||||||
except:
|
except OSError:
|
||||||
|
# the config file may be missing
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return options
|
return options
|
||||||
|
@ -212,9 +213,9 @@ class Proxy(object):
|
||||||
def __call__(self, *args):
|
def __call__(self, *args):
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
arg_strings = [json.dumps(arg) for arg in args]
|
arg_strings = [json.dumps(arg) for arg in args]
|
||||||
print "Calling %s(%s) @ %s" % (self.method,
|
print("Calling %s(%s) @ %s" % (self.method,
|
||||||
', '.join(arg_strings),
|
', '.join(arg_strings),
|
||||||
self.service.url)
|
self.service.url))
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
'method': self.method,
|
'method': self.method,
|
||||||
|
@ -229,15 +230,15 @@ class Proxy(object):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
body = urllib2.urlopen(request).read()
|
body = urllib2.urlopen(request).read()
|
||||||
except Exception, e:
|
except urllib2.URLError as e:
|
||||||
return (None, e)
|
return (None, e)
|
||||||
|
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
print 'RPC Response (%s): %s' % (self.method, json.dumps(body, indent=4))
|
print('RPC Response (%s): %s' % (self.method, json.dumps(body, indent=4)))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
data = json.loads(body)
|
data = json.loads(body)
|
||||||
except ValueError, e:
|
except ValueError as e:
|
||||||
return (None, e.message)
|
return (None, e.message)
|
||||||
# TODO: Check that id matches?
|
# TODO: Check that id matches?
|
||||||
return (data['result'], data['error'])
|
return (data['result'], data['error'])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue