aboutsummaryrefslogtreecommitdiff
path: root/utils/python-rpc/console.py
diff options
context:
space:
mode:
Diffstat (limited to 'utils/python-rpc/console.py')
-rwxr-xr-xutils/python-rpc/console.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/utils/python-rpc/console.py b/utils/python-rpc/console.py
index 57a04528b..4b3c18f5d 100755
--- a/utils/python-rpc/console.py
+++ b/utils/python-rpc/console.py
@@ -4,7 +4,16 @@ from __future__ import print_function
import sys
import subprocess
import socket
-import urlparse
+try:
+ import urllib.parse
+ url_parser = urllib.parse.urlparse
+except:
+ try:
+ import urlparse
+ url_parser = urlparse.urlparse
+ except:
+ print('urllib or urlparse is needed')
+ sys.exit(1)
import framework.rpc
import framework.daemon
import framework.wallet
@@ -21,7 +30,7 @@ for n in range(1, len(sys.argv)):
try:
port = int(sys.argv[n])
except:
- t = urlparse.urlparse(sys.argv[n], allow_fragments = False)
+ t = url_parser(sys.argv[n], allow_fragments = False)
scheme = t.scheme or scheme
host = t.hostname or host
port = t.port or port
@@ -29,7 +38,7 @@ for n in range(1, len(sys.argv)):
raise Exception(USAGE)
if port <= 0 or port > 65535:
raise Exception(USAGE)
- except Exception, e:
+ except Exception as e:
print('Error: ' + str(e))
raise Exception(USAGE)
@@ -49,7 +58,7 @@ for n in range(1, len(sys.argv)):
}
try:
res = rpc.send_json_rpc_request(get_version)
- except Exception, e:
+ except Exception as e:
raise Exception('Failed to call version RPC: ' + str(e))
if 'version' not in res: