Standardizing message format and implementing stderr for errors
This commit is contained in:
@@ -135,7 +135,7 @@ def restore_create_dialog(wallet):
|
||||
# history and addressbook
|
||||
wallet.update_tx_history()
|
||||
wallet.fill_addressbook()
|
||||
print "recovery successful"
|
||||
print "Recovery successful"
|
||||
|
||||
gobject.idle_add( dialog.destroy )
|
||||
|
||||
@@ -206,7 +206,8 @@ def run_recovery_dialog(wallet):
|
||||
try:
|
||||
seed.decode('hex')
|
||||
except:
|
||||
print "not hex, trying decode"
|
||||
sys.stderr.write("Warning: Not hex, trying decode\n")
|
||||
sys.stderr.flush()
|
||||
seed = mnemonic.mn_decode( seed.split(' ') )
|
||||
if not seed:
|
||||
show_message("no seed")
|
||||
|
||||
@@ -22,8 +22,9 @@ from i18n import _
|
||||
try:
|
||||
import PyQt4
|
||||
except:
|
||||
print "could not import PyQt4"
|
||||
print "on Linux systems, you may try 'sudo apt-get install python-qt4'"
|
||||
sys.stderr.write("Error: Could not import PyQt4\n")
|
||||
sys.stderr.write("on Linux systems, you may try 'sudo apt-get install python-qt4'\n")
|
||||
sys.stderr.flush()
|
||||
sys.exit(1)
|
||||
|
||||
from PyQt4.QtGui import *
|
||||
@@ -35,8 +36,9 @@ from interface import DEFAULT_SERVERS
|
||||
try:
|
||||
import icons_rc
|
||||
except:
|
||||
print "Could not import icons_rc.py"
|
||||
print "Please generate it with: 'pyrcc4 icons.qrc -o lib/icons_rc.py'"
|
||||
sys.stderr.write("Error: Could not import icons_rc.py\n")
|
||||
sys.stderr.write("Please generate it with: 'pyrcc4 icons.qrc -o lib/icons_rc.py'\n")
|
||||
sys.stderr.flush()
|
||||
sys.exit(1)
|
||||
|
||||
from wallet import format_satoshis
|
||||
@@ -388,7 +390,8 @@ class ElectrumWindow(QMainWindow):
|
||||
if text not in self.wallet.aliases.keys():
|
||||
self.wallet.labels[addr] = text
|
||||
else:
|
||||
print "error: this is one of your aliases"
|
||||
sys.stderr.write("Error: This is one of your aliases\n")
|
||||
sys.stderr.flush()
|
||||
label = self.wallet.labels.get(addr,'')
|
||||
item.setText(column_label, QString(label))
|
||||
else:
|
||||
@@ -1141,7 +1144,8 @@ class ElectrumWindow(QMainWindow):
|
||||
seed = unicode(seed_e.text())
|
||||
seed.decode('hex')
|
||||
except:
|
||||
print "not hex, trying decode"
|
||||
sys.stderr.write("Warning: Not hex, trying decode\n")
|
||||
sys.stderr.flush()
|
||||
try:
|
||||
seed = mnemonic.mn_decode( seed.split(' ') )
|
||||
except:
|
||||
@@ -1473,7 +1477,7 @@ class ElectrumGui:
|
||||
# history and addressbook
|
||||
wallet.update_tx_history()
|
||||
wallet.fill_addressbook()
|
||||
print "recovery successful"
|
||||
print "Recovery successful"
|
||||
wallet.save()
|
||||
else:
|
||||
QMessageBox.information(None, _('Error'), _("No transactions found for this seed"), _('OK'))
|
||||
|
||||
@@ -247,7 +247,8 @@ class TcpStratumInterface(Interface):
|
||||
print "Connected to %s:%d"%(self.host,self.port)
|
||||
except:
|
||||
self.is_connected = False
|
||||
print "Not connected"
|
||||
sys.stderr.write("Not connected\n")
|
||||
sys.stderr.flush()
|
||||
|
||||
def run(self):
|
||||
try:
|
||||
@@ -262,7 +263,7 @@ class TcpStratumInterface(Interface):
|
||||
self.bytes_received += len(msg)
|
||||
if msg == '':
|
||||
self.is_connected = False
|
||||
print "disconnected."
|
||||
print "Disconnected."
|
||||
|
||||
while True:
|
||||
s = out.find('\n')
|
||||
@@ -276,7 +277,7 @@ class TcpStratumInterface(Interface):
|
||||
traceback.print_exc(file=sys.stdout)
|
||||
|
||||
self.is_connected = False
|
||||
print "poking"
|
||||
print "Poking"
|
||||
self.poke()
|
||||
|
||||
def send(self, messages):
|
||||
@@ -327,7 +328,8 @@ class WalletSynchronizer(threading.Thread):
|
||||
elif protocol == 'h':
|
||||
InterfaceClass = HttpStratumInterface
|
||||
else:
|
||||
print "unknown protocol"
|
||||
sys.stderr.write("Error: Unknown protocol\n")
|
||||
sys.stderr.flush()
|
||||
InterfaceClass = TcpStratumInterface
|
||||
|
||||
self.interface = InterfaceClass(host, port, self.wallet.debug_server)
|
||||
@@ -384,7 +386,8 @@ class WalletSynchronizer(threading.Thread):
|
||||
pass
|
||||
|
||||
else:
|
||||
print "unknown message:", method, params, result
|
||||
sys.stderr.write("Error: Unknown message:" + method + ", " + params + ", " + result)
|
||||
sys.stderr.flush()
|
||||
|
||||
|
||||
def start_interface(self):
|
||||
|
||||
@@ -156,7 +156,8 @@ def prompt_password(prompt, confirm=True):
|
||||
password2 = getpass.getpass("Confirm: ")
|
||||
|
||||
if password != password2:
|
||||
print "Error: Passwords do not match."
|
||||
sys.stderr.write("Error: Passwords do not match.\n")
|
||||
sys.stderr.flush()
|
||||
sys.exit(1)
|
||||
|
||||
else:
|
||||
@@ -920,7 +921,7 @@ class Wallet:
|
||||
|
||||
if not self.use_change and not change_addr:
|
||||
change_addr = inputs[0][0]
|
||||
print "sending change to", change_addr
|
||||
print "Sending change to", change_addr
|
||||
|
||||
outputs = self.choose_tx_outputs( to_address, amount, fee, total, change_addr )
|
||||
s_inputs = self.sign_inputs( inputs, outputs, password )
|
||||
|
||||
Reference in New Issue
Block a user