1
0

fix more bare excepts

This commit is contained in:
Bryan Stitt
2013-11-10 12:30:57 -08:00
parent 24cabcbee9
commit 6cd4ed486a
21 changed files with 67 additions and 67 deletions

View File

@@ -345,7 +345,7 @@ def get_history_values(n):
time_str = str( dt.time() )
else:
time_str = str( dt.date() )
except:
except Exception:
time_str = 'pending'
conf_str = 'v' if conf else 'o'
@@ -600,7 +600,7 @@ def payto_loop():
try:
amount = int( 100000000 * Decimal(amount) )
except:
except Exception:
modal_dialog('Error','Invalid amount')
continue
@@ -718,7 +718,7 @@ def show_seed():
try:
seed = wallet.get_seed(password)
except:
except Exception:
modal_dialog('error','incorrect password')
return
@@ -734,7 +734,7 @@ def change_password_dialog():
try:
wallet.get_seed(password)
except:
except Exception:
modal_dialog('error','incorrect password')
return
@@ -811,7 +811,7 @@ def settings_loop():
if fee:
try:
fee = int( 100000000 * Decimal(fee) )
except:
except Exception:
modal_dialog('error','invalid fee value')
wallet.set_fee(fee)
set_listview()
@@ -828,7 +828,7 @@ def settings_loop():
auto_connect = False
try:
network.set_parameters(host, port, protocol, proxy, auto_connect)
except:
except Exception:
modal_dialog('error','invalid server')
set_listview()
@@ -987,7 +987,7 @@ class ElectrumGui:
m = modal_input('Mnemonic','please enter your code')
try:
seed = mnemonic_decode(m.split(' '))
except:
except Exception:
modal_dialog('error: could not decode this seed')
return

View File

@@ -51,12 +51,12 @@ def numbify(entry, is_int = False):
s = s[:p] + '.' + s[p:p+8]
try:
amount = int( Decimal(s) * 100000000 )
except:
except Exception:
amount = None
else:
try:
amount = int( s )
except:
except Exception:
amount = None
entry.set_text(s)
return amount
@@ -70,7 +70,7 @@ def show_seed_dialog(wallet, password, parent):
return
try:
seed = wallet.get_seed(password)
except:
except Exception:
show_message("Incorrect password")
return
dialog = gtk.MessageDialog(
@@ -140,7 +140,7 @@ def run_recovery_dialog():
try:
seed.decode('hex')
except:
except Exception:
print_error("Warning: Not hex, trying decode")
seed = mnemonic.mn_decode( seed.split(' ') )
if not seed:
@@ -209,7 +209,7 @@ def run_settings_dialog(self):
try:
fee = int( 100000000 * Decimal(fee) )
except:
except Exception:
show_message("error")
return
self.wallet.set_fee(fee)
@@ -217,7 +217,7 @@ def run_settings_dialog(self):
try:
nz = int( nz )
if nz>8: nz = 8
except:
except Exception:
show_message("error")
return
@@ -359,7 +359,7 @@ def run_network_dialog( network, parent ):
proxy = network.config.get('proxy')
auto_connect = network.config.get('auto_cycle')
network.set_parameters(host, port, protocol, proxy, auto_connect)
except:
except Exception:
show_message("error:" + server)
return False
@@ -441,7 +441,7 @@ def change_password_dialog(wallet, parent, icon):
try:
wallet.get_seed(password)
except:
except Exception:
show_message("Incorrect password")
return
@@ -591,7 +591,7 @@ class ElectrumWindow:
if re.match('^(|([\w\-\.]+)@)((\w[\w\-]+\.)+[\w\-]+)$', r):
try:
to_address = self.wallet.get_alias(r, interactive=False)
except:
except Exception:
continue
if to_address:
s = r + ' <' + to_address + '>'
@@ -789,12 +789,12 @@ class ElectrumWindow:
try:
amount = int( Decimal(amount_entry.get_text()) * 100000000 )
except:
except Exception:
self.show_message( "invalid amount")
return
try:
fee = int( Decimal(fee_entry.get_text()) * 100000000 )
except:
except Exception:
self.show_message( "invalid fee")
return
@@ -1145,7 +1145,7 @@ class ElectrumWindow:
if conf > 0:
try:
time_str = datetime.datetime.fromtimestamp( timestamp).isoformat(' ')[:-3]
except:
except Exception:
time_str = "------"
conf_icon = gtk.STOCK_APPLY
elif conf == -1:

View File

@@ -26,7 +26,7 @@ import shutil
try:
import PyQt4
except:
except Exception:
sys.exit("Error: Could not import PyQt4 on Linux systems, you may try 'sudo apt-get install python-qt4'")
from PyQt4.QtGui import *
@@ -39,7 +39,7 @@ from electrum.bitcoin import MIN_RELAY_TX_FEE
try:
import icons_rc
except:
except Exception:
sys.exit("Error: Could not import icons_rc.py, please generate it with: 'pyrcc4 icons.qrc -o gui/qt/icons_rc.py'")
from util import *

View File

@@ -219,7 +219,7 @@ class Console(QtGui.QPlainTextEdit):
exec command in self.namespace
except SystemExit:
self.close()
except:
except Exception:
traceback_lines = traceback.format_exc().split('\n')
# Remove traceback mentioning this file, and a linebreak
for i in (3,2,1,-1):

View File

@@ -284,7 +284,7 @@ class InstallWizard(QDialog):
return
try:
wallet.init_seed(seed)
except:
except Exception:
import traceback
traceback.print_exc(file=sys.stdout)
QMessageBox.warning(None, _('Error'), _('Incorrect seed'), _('OK'))

View File

@@ -690,7 +690,7 @@ class ElectrumWindow(QMainWindow):
if conf > 0:
try:
time_str = datetime.datetime.fromtimestamp( timestamp).isoformat(' ')[:-3]
except:
except Exception:
time_str = _("error")
if conf == -1:
@@ -872,12 +872,12 @@ class ElectrumWindow(QMainWindow):
try:
amount = self.read_amount(unicode( self.amount_e.text()))
except:
except Exception:
QMessageBox.warning(self, _('Error'), _('Invalid Amount'), _('OK'))
return
try:
fee = self.read_amount(unicode( self.fee_e.text()))
except:
except Exception:
QMessageBox.warning(self, _('Error'), _('Invalid Fee'), _('OK'))
return
@@ -923,7 +923,7 @@ class ElectrumWindow(QMainWindow):
with open(fileName,'w') as f:
f.write(json.dumps(tx.as_dict(),indent=4) + '\n')
QMessageBox.information(self, _('Unsigned transaction created'), _("Unsigned transaction was saved to file:") + " " +fileName, _('OK'))
except:
except Exception:
QMessageBox.warning(self, _('Error'), _('Could not write transaction to file'), _('OK'))
# add recipient to addressbook
@@ -1559,7 +1559,7 @@ class ElectrumWindow(QMainWindow):
if self.wallet.seed:
try:
mnemonic = self.wallet.get_mnemonic(password)
except:
except Exception:
QMessageBox.warning(self, _('Error'), _('Incorrect Password'), _('OK'))
return
from seed_dialog import SeedDialog
@@ -1781,7 +1781,7 @@ class ElectrumWindow(QMainWindow):
txt.decode('hex')
tx = Transaction(txt)
return tx
except:
except Exception:
pass
try:
@@ -1794,7 +1794,7 @@ class ElectrumWindow(QMainWindow):
input_info = json.loads(tx_dict['input_info'])
tx.add_input_info(input_info)
return tx
except:
except Exception:
pass
QMessageBox.critical(None, _("Unable to parse transaction"), _("Electrum was unable to parse your transaction"))
@@ -1991,7 +1991,7 @@ class ElectrumWindow(QMainWindow):
lang_combo.addItems(languages.values())
try:
index = languages.keys().index(self.config.get("language",''))
except:
except Exception:
index = 0
lang_combo.setCurrentIndex(index)
grid.addWidget(lang_combo, 1, 1)
@@ -2040,7 +2040,7 @@ class ElectrumWindow(QMainWindow):
fee = unicode(fee_e.text())
try:
fee = self.read_amount(fee)
except:
except Exception:
QMessageBox.warning(self, _('Error'), _('Invalid value') +': %s'%fee, _('OK'))
return
@@ -2050,7 +2050,7 @@ class ElectrumWindow(QMainWindow):
try:
nz = int( nz )
if nz>8: nz=8
except:
except Exception:
QMessageBox.warning(self, _('Error'), _('Invalid value')+':%s'%nz, _('OK'))
return
@@ -2146,7 +2146,7 @@ class ElectrumWindow(QMainWindow):
w = None
cb.clicked.connect(mk_toggle(cb,p,w))
grid.addWidget(HelpButton(p.description()), i, 2)
except:
except Exception:
print_msg(_("Error: cannot display plugin"), p)
traceback.print_exc(file=sys.stdout)
grid.setRowStretch(i+1,1)

View File

@@ -85,7 +85,7 @@ def run_password_dialog(self, wallet, parent):
try:
wallet.get_seed(password)
except:
except Exception:
QMessageBox.warning(parent, _('Error'), _('Incorrect Password'), _('OK'))
return
@@ -97,7 +97,7 @@ def run_password_dialog(self, wallet, parent):
try:
wallet.update_password(password, new_password)
except:
except Exception:
QMessageBox.warning(parent, _('Error'), _('Failed to update password'), _('OK'))
return

View File

@@ -35,7 +35,7 @@ class QRCodeWidget(QWidget):
self.qr.addData(self.addr)
self.qr.make()
break
except:
except Exception:
self.qr=None
continue
self.update()

View File

@@ -26,7 +26,7 @@ import StringIO
try:
import PyQt4
except:
except Exception:
sys.exit("Error: Could not import PyQt4 on Linux systems, you may try 'sudo apt-get install python-qt4'")
from PyQt4.QtGui import *

View File

@@ -104,7 +104,7 @@ class ElectrumGui:
if confirmations:
try:
time_str = datetime.datetime.fromtimestamp( timestamp).isoformat(' ')[:-3]
except:
except Exception:
time_str = "unknown"
else:
time_str = 'pending'
@@ -175,12 +175,12 @@ class ElectrumGui:
return
try:
amount = int( Decimal( self.str_amount) * 100000000 )
except:
except Exception:
print(_('Invalid Amount'))
return
try:
fee = int( Decimal( self.str_fee) * 100000000 )
except:
except Exception:
print(_('Invalid Fee'))
return

View File

@@ -64,7 +64,7 @@ class ElectrumGui:
def set_cursor(self, x):
try:
curses.curs_set(x)
except:
except Exception:
pass
def restore_or_create(self):
@@ -112,7 +112,7 @@ class ElectrumGui:
if conf:
try:
time_str = datetime.datetime.fromtimestamp( timestamp).isoformat(' ')[:-3]
except:
except Exception:
time_str = "------"
else:
time_str = 'pending'
@@ -291,12 +291,12 @@ class ElectrumGui:
return
try:
amount = int( Decimal( self.str_amount) * 100000000 )
except:
except Exception:
self.show_message(_('Invalid Amount'))
return
try:
fee = int( Decimal( self.str_fee) * 100000000 )
except:
except Exception:
self.show_message(_('Invalid Fee'))
return
@@ -360,7 +360,7 @@ class ElectrumGui:
if not auto_connect:
try:
host, port, protocol = server.split(':')
except:
except Exception:
self.show_message("Error:" + server + "\nIn doubt, type \"auto-connect\"")
return False
@@ -468,7 +468,7 @@ class ElectrumGui:
choices = item.get('choices')
try:
j = choices.index(item.get('value'))
except:
except Exception:
j = 0
new_choice = choices[(j + 1)% len(choices)]
item['value'] = new_choice