Add rpcport detection, use spaces instead of tabs

This commit is contained in:
TheNain38 2016-03-19 12:53:15 +01:00 committed by TheNain38
parent ab19dba99d
commit c70d98d642
3 changed files with 100 additions and 97 deletions

View file

@ -1,5 +1,5 @@
from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException
import time, json, os, sys, re, socket, json
import time, json, os, sys, re, socket
# Either returns domain's address or none if it doesn't exist
# Supports subdomains and .bit on the end
@ -23,7 +23,7 @@ def lookupDomain(domain):
#domain doesn't exist
return None
domain_json = json.loads(domain_object['value'])
domain_json = json.loads(domain_object["value"])
try:
domain_address = domain_json["zeronet"][subdomain]
@ -47,8 +47,11 @@ else:
namecoin_conf = open(namecoin_location + "namecoin.conf").read()
# Connecting to RPC
rpc_user = re.search("rpcuser=(.*)$", namecoin_conf, re.M).group(1)
rpc_pass = re.search("rpcpassword=(.*)$", namecoin_conf, re.M).group(1)
rpc_url = "http://%s:%s@127.0.0.1:8336" % (rpc_user, rpc_pass)
rpc_user = re.search(r"^\s*rpcuser\s*=(\S+)\s*(?:#.*)?$", namecoin_conf, re.M).group(1)
rpc_pass = re.search(r"^\s*rpcpassword\s*=(\S+)\s*(?:#.*)?$", namecoin_conf, re.M).group(1)
rpc_port = re.search(r"^\s*rpcport\s*=(\d{1,5})\s*(?:#.*)?$", namecoin_conf, re.M)
rpc_port = rpc_port.group(1) if rpc_port is not None else "8336"
rpc_url = "http://%s:%s@127.0.0.1:%s" % (rpc_user, rpc_pass, rpc_port)
rpc = AuthServiceProxy(rpc_url, timeout=60*5)