Created
January 10, 2014 22:56
-
-
Save ryancdotorg/8364317 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from bitcoinrpc.authproxy import AuthServiceProxy | |
| def asp_from_config(filename): | |
| rpcport = '8332' | |
| rpcconn = '127.0.0.1' | |
| rpcuser = None | |
| rpcpass = None | |
| with open(filename, 'r') as f: | |
| for line in f: | |
| (key, val) = line.rstrip().replace(' ', '').split('=') | |
| if key == 'rpcuser': | |
| rpcuser = val | |
| elif key == 'rpcpassword': | |
| rpcpass = val | |
| elif key == 'rpcport': | |
| rpcport = val | |
| elif key == 'rpcconnect': | |
| rpcconn = val | |
| f.close() | |
| if rpcuser is not None and rpcpass is not None: | |
| rpcurl = 'http://%s:%s@%s:%s' % (rpcuser, rpcpass, rpcconn, rpcport) | |
| print_stderr('RPC server: %s' % rpcurl) | |
| return AuthServiceProxy(rpcurl) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment