mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-22 14:16:00 +00:00
Plugin bitcoind_: switch to Python3
This commit is contained in:
parent
fffb536e26
commit
bc20826c4e
1 changed files with 10 additions and 9 deletions
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
"""=cut
|
"""=cut
|
||||||
=head1 NAME
|
=head1 NAME
|
||||||
|
@ -48,12 +48,13 @@ Copyright (C) 2012 Mike Koss
|
||||||
|
|
||||||
=cut"""
|
=cut"""
|
||||||
|
|
||||||
|
import json
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import re
|
import urllib.error
|
||||||
import urllib2
|
import urllib.request
|
||||||
import json
|
|
||||||
|
|
||||||
|
|
||||||
DEBUG = False
|
DEBUG = False
|
||||||
|
@ -222,15 +223,15 @@ class Proxy(object):
|
||||||
'params': args,
|
'params': args,
|
||||||
'id': self.id,
|
'id': self.id,
|
||||||
}
|
}
|
||||||
request = urllib2.Request(self.service.url, json.dumps(data))
|
request = urllib.request.Request(self.service.url, json.dumps(data))
|
||||||
if self.service.username:
|
if self.service.username:
|
||||||
# Strip the newline from the b64 encoding!
|
# Strip the newline from the b64 encoding!
|
||||||
b64 = ('%s:%s' % (self.service.username, self.service.password)).encode('base64')[:-1]
|
b64 = ('%s:%s' % (self.service.username, self.service.password)).encode('base64')[:-1]
|
||||||
request.add_header('Authorization', 'Basic %s' % b64)
|
request.add_header('Authorization', 'Basic %s' % b64)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
body = urllib2.urlopen(request).read()
|
body = urllib.request.urlopen(request).read()
|
||||||
except urllib2.URLError as e:
|
except urllib.error.URLError as e:
|
||||||
return (None, e)
|
return (None, e)
|
||||||
|
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
|
@ -245,8 +246,8 @@ class Proxy(object):
|
||||||
|
|
||||||
|
|
||||||
def get_json_url(url):
|
def get_json_url(url):
|
||||||
request = urllib2.Request(url)
|
request = urllib.request.Request(url)
|
||||||
body = urllib2.urlopen(request).read()
|
body = urllib.request.urlopen(request).read()
|
||||||
data = json.loads(body)
|
data = json.loads(body)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue