Merge pull request #5360

71acb86 print the caught error instead of raising an error (Heath)
This commit is contained in:
Wladimir J. van der Laan 2015-03-18 14:35:14 +01:00
commit 29fef0b903
No known key found for this signature in database
GPG Key ID: 74810B012346C9A6

View File

@ -20,8 +20,8 @@ if cmd == "backupwallet":
try: try:
path = raw_input("Enter destination path/filename: ") path = raw_input("Enter destination path/filename: ")
print access.backupwallet(path) print access.backupwallet(path)
except: except Exception as inst:
print "\n---An error occurred---\n" print inst
elif cmd == "encryptwallet": elif cmd == "encryptwallet":
try: try:
@ -32,29 +32,29 @@ elif cmd == "encryptwallet":
print "\n---Wallet encrypted. Server stopping, restart to run with encrypted wallet---\n" print "\n---Wallet encrypted. Server stopping, restart to run with encrypted wallet---\n"
else: else:
print "\n---Passphrases do not match---\n" print "\n---Passphrases do not match---\n"
except: except Exception as inst:
print "\n---An error occurred---\n" print inst
elif cmd == "getaccount": elif cmd == "getaccount":
try: try:
addr = raw_input("Enter a Bitcoin address: ") addr = raw_input("Enter a Bitcoin address: ")
print access.getaccount(addr) print access.getaccount(addr)
except: except Exception as inst:
print "\n---An error occurred---\n" print inst
elif cmd == "getaccountaddress": elif cmd == "getaccountaddress":
try: try:
acct = raw_input("Enter an account name: ") acct = raw_input("Enter an account name: ")
print access.getaccountaddress(acct) print access.getaccountaddress(acct)
except: except Exception as inst:
print "\n---An error occurred---\n" print inst
elif cmd == "getaddressesbyaccount": elif cmd == "getaddressesbyaccount":
try: try:
acct = raw_input("Enter an account name: ") acct = raw_input("Enter an account name: ")
print access.getaddressesbyaccount(acct) print access.getaddressesbyaccount(acct)
except: except Exception as inst:
print "\n---An error occurred---\n" print inst
elif cmd == "getbalance": elif cmd == "getbalance":
try: try:
@ -64,57 +64,57 @@ elif cmd == "getbalance":
print access.getbalance(acct, mc) print access.getbalance(acct, mc)
except: except:
print access.getbalance() print access.getbalance()
except: except Exception as inst:
print "\n---An error occurred---\n" print inst
elif cmd == "getblockbycount": elif cmd == "getblockbycount":
try: try:
height = raw_input("Height: ") height = raw_input("Height: ")
print access.getblockbycount(height) print access.getblockbycount(height)
except: except Exception as inst:
print "\n---An error occurred---\n" print inst
elif cmd == "getblockcount": elif cmd == "getblockcount":
try: try:
print access.getblockcount() print access.getblockcount()
except: except Exception as inst:
print "\n---An error occurred---\n" print inst
elif cmd == "getblocknumber": elif cmd == "getblocknumber":
try: try:
print access.getblocknumber() print access.getblocknumber()
except: except Exception as inst:
print "\n---An error occurred---\n" print inst
elif cmd == "getconnectioncount": elif cmd == "getconnectioncount":
try: try:
print access.getconnectioncount() print access.getconnectioncount()
except: except Exception as inst:
print "\n---An error occurred---\n" print inst
elif cmd == "getdifficulty": elif cmd == "getdifficulty":
try: try:
print access.getdifficulty() print access.getdifficulty()
except: except Exception as inst:
print "\n---An error occurred---\n" print inst
elif cmd == "getgenerate": elif cmd == "getgenerate":
try: try:
print access.getgenerate() print access.getgenerate()
except: except Exception as inst:
print "\n---An error occurred---\n" print inst
elif cmd == "gethashespersec": elif cmd == "gethashespersec":
try: try:
print access.gethashespersec() print access.gethashespersec()
except: except Exception as inst:
print "\n---An error occurred---\n" print inst
elif cmd == "getinfo": elif cmd == "getinfo":
try: try:
print access.getinfo() print access.getinfo()
except: except Exception as inst:
print "\n---An error occurred---\n" print inst
elif cmd == "getnewaddress": elif cmd == "getnewaddress":
try: try:
@ -123,8 +123,8 @@ elif cmd == "getnewaddress":
print access.getnewaddress(acct) print access.getnewaddress(acct)
except: except:
print access.getnewaddress() print access.getnewaddress()
except: except Exception as inst:
print "\n---An error occurred---\n" print inst
elif cmd == "getreceivedbyaccount": elif cmd == "getreceivedbyaccount":
try: try:
@ -134,8 +134,8 @@ elif cmd == "getreceivedbyaccount":
print access.getreceivedbyaccount(acct, mc) print access.getreceivedbyaccount(acct, mc)
except: except:
print access.getreceivedbyaccount() print access.getreceivedbyaccount()
except: except Exception as inst:
print "\n---An error occurred---\n" print inst
elif cmd == "getreceivedbyaddress": elif cmd == "getreceivedbyaddress":
try: try:
@ -145,15 +145,15 @@ elif cmd == "getreceivedbyaddress":
print access.getreceivedbyaddress(addr, mc) print access.getreceivedbyaddress(addr, mc)
except: except:
print access.getreceivedbyaddress() print access.getreceivedbyaddress()
except: except Exception as inst:
print "\n---An error occurred---\n" print inst
elif cmd == "gettransaction": elif cmd == "gettransaction":
try: try:
txid = raw_input("Enter a transaction ID: ") txid = raw_input("Enter a transaction ID: ")
print access.gettransaction(txid) print access.gettransaction(txid)
except: except Exception as inst:
print "\n---An error occurred---\n" print inst
elif cmd == "getwork": elif cmd == "getwork":
try: try:
@ -162,8 +162,8 @@ elif cmd == "getwork":
print access.gettransaction(data) print access.gettransaction(data)
except: except:
print access.gettransaction() print access.gettransaction()
except: except Exception as inst:
print "\n---An error occurred---\n" print inst
elif cmd == "help": elif cmd == "help":
try: try:
@ -172,8 +172,8 @@ elif cmd == "help":
print access.help(cmd) print access.help(cmd)
except: except:
print access.help() print access.help()
except: except Exception as inst:
print "\n---An error occurred---\n" print inst
elif cmd == "listaccounts": elif cmd == "listaccounts":
try: try:
@ -182,8 +182,8 @@ elif cmd == "listaccounts":
print access.listaccounts(mc) print access.listaccounts(mc)
except: except:
print access.listaccounts() print access.listaccounts()
except: except Exception as inst:
print "\n---An error occurred---\n" print inst
elif cmd == "listreceivedbyaccount": elif cmd == "listreceivedbyaccount":
try: try:
@ -193,8 +193,8 @@ elif cmd == "listreceivedbyaccount":
print access.listreceivedbyaccount(mc, incemp) print access.listreceivedbyaccount(mc, incemp)
except: except:
print access.listreceivedbyaccount() print access.listreceivedbyaccount()
except: except Exception as inst:
print "\n---An error occurred---\n" print inst
elif cmd == "listreceivedbyaddress": elif cmd == "listreceivedbyaddress":
try: try:
@ -204,8 +204,8 @@ elif cmd == "listreceivedbyaddress":
print access.listreceivedbyaddress(mc, incemp) print access.listreceivedbyaddress(mc, incemp)
except: except:
print access.listreceivedbyaddress() print access.listreceivedbyaddress()
except: except Exception as inst:
print "\n---An error occurred---\n" print inst
elif cmd == "listtransactions": elif cmd == "listtransactions":
try: try:
@ -216,8 +216,8 @@ elif cmd == "listtransactions":
print access.listtransactions(acct, count, frm) print access.listtransactions(acct, count, frm)
except: except:
print access.listtransactions() print access.listtransactions()
except: except Exception as inst:
print "\n---An error occurred---\n" print inst
elif cmd == "move": elif cmd == "move":
try: try:
@ -230,8 +230,8 @@ elif cmd == "move":
print access.move(frm, to, amt, mc, comment) print access.move(frm, to, amt, mc, comment)
except: except:
print access.move(frm, to, amt) print access.move(frm, to, amt)
except: except Exception as inst:
print "\n---An error occurred---\n" print inst
elif cmd == "sendfrom": elif cmd == "sendfrom":
try: try:
@ -245,8 +245,8 @@ elif cmd == "sendfrom":
print access.sendfrom(frm, to, amt, mc, comment, commentto) print access.sendfrom(frm, to, amt, mc, comment, commentto)
except: except:
print access.sendfrom(frm, to, amt) print access.sendfrom(frm, to, amt)
except: except Exception as inst:
print "\n---An error occurred---\n" print inst
elif cmd == "sendmany": elif cmd == "sendmany":
try: try:
@ -258,8 +258,8 @@ elif cmd == "sendmany":
print access.sendmany(frm,to,mc,comment) print access.sendmany(frm,to,mc,comment)
except: except:
print access.sendmany(frm,to) print access.sendmany(frm,to)
except: except Exception as inst:
print "\n---An error occurred---\n" print inst
elif cmd == "sendtoaddress": elif cmd == "sendtoaddress":
try: try:
@ -271,16 +271,16 @@ elif cmd == "sendtoaddress":
print access.sendtoaddress(to,amt,comment,commentto) print access.sendtoaddress(to,amt,comment,commentto)
except: except:
print access.sendtoaddress(to,amt) print access.sendtoaddress(to,amt)
except: except Exception as inst:
print "\n---An error occurred---\n" print inst
elif cmd == "setaccount": elif cmd == "setaccount":
try: try:
addr = raw_input("Address: ") addr = raw_input("Address: ")
acct = raw_input("Account:") acct = raw_input("Account:")
print access.setaccount(addr,acct) print access.setaccount(addr,acct)
except: except Exception as inst:
print "\n---An error occurred---\n" print inst
elif cmd == "setgenerate": elif cmd == "setgenerate":
try: try:
@ -290,36 +290,36 @@ elif cmd == "setgenerate":
print access.setgenerate(gen, cpus) print access.setgenerate(gen, cpus)
except: except:
print access.setgenerate(gen) print access.setgenerate(gen)
except: except Exception as inst:
print "\n---An error occurred---\n" print inst
elif cmd == "settxfee": elif cmd == "settxfee":
try: try:
amt = raw_input("Amount:") amt = raw_input("Amount:")
print access.settxfee(amt) print access.settxfee(amt)
except: except Exception as inst:
print "\n---An error occurred---\n" print inst
elif cmd == "stop": elif cmd == "stop":
try: try:
print access.stop() print access.stop()
except: except Exception as inst:
print "\n---An error occurred---\n" print inst
elif cmd == "validateaddress": elif cmd == "validateaddress":
try: try:
addr = raw_input("Address: ") addr = raw_input("Address: ")
print access.validateaddress(addr) print access.validateaddress(addr)
except: except Exception as inst:
print "\n---An error occurred---\n" print inst
elif cmd == "walletpassphrase": elif cmd == "walletpassphrase":
try: try:
pwd = getpass.getpass(prompt="Enter wallet passphrase: ") pwd = getpass.getpass(prompt="Enter wallet passphrase: ")
access.walletpassphrase(pwd, 60) access.walletpassphrase(pwd, 60)
print "\n---Wallet unlocked---\n" print "\n---Wallet unlocked---\n"
except: except Exception as inst:
print "\n---An error occurred---\n" print inst
elif cmd == "walletpassphrasechange": elif cmd == "walletpassphrasechange":
try: try:
@ -328,10 +328,8 @@ elif cmd == "walletpassphrasechange":
access.walletpassphrasechange(pwd, pwd2) access.walletpassphrasechange(pwd, pwd2)
print print
print "\n---Passphrase changed---\n" print "\n---Passphrase changed---\n"
except: except Exception as inst:
print print inst
print "\n---An error occurred---\n"
print
else: else:
print "Command not found or not supported" print "Command not found or not supported"