ruff: except: -> except Exception:
This commit is contained in:
parent
779133d203
commit
b43fc87e3a
38 changed files with 67 additions and 67 deletions
|
|
@ -110,7 +110,7 @@ class AddrListID(HiliteStr, InitErrors, MMGenObject):
|
|||
sid = SeedID(sid=a)
|
||||
try:
|
||||
mmtype = MMGenAddrType(proto=proto, id_str=b)
|
||||
except:
|
||||
except Exception:
|
||||
mmtype = MMGenPasswordType(proto=proto, id_str=b)
|
||||
else:
|
||||
assert isinstance(sid, SeedID), f'{sid!r} not a SeedID instance'
|
||||
|
|
|
|||
|
|
@ -258,7 +258,7 @@ class CoinInfo:
|
|||
def get_entry(cls, coin, network):
|
||||
try:
|
||||
idx = [e.symbol for e in cls.coin_constants[network]].index(coin.upper())
|
||||
except:
|
||||
except Exception:
|
||||
return None
|
||||
return cls.coin_constants[network][idx]
|
||||
|
||||
|
|
|
|||
|
|
@ -186,7 +186,7 @@ class Autosign:
|
|||
|
||||
try:
|
||||
dirlist = self.wallet_dir.iterdir()
|
||||
except:
|
||||
except Exception:
|
||||
die(1,
|
||||
f'Cannot open wallet directory ‘{self.wallet_dir}’. '
|
||||
'Did you run ‘mmgen-autosign setup’?')
|
||||
|
|
@ -330,7 +330,7 @@ class Autosign:
|
|||
try:
|
||||
self.keyfile.write_text(os.urandom(32).hex())
|
||||
self.keyfile.chmod(0o400)
|
||||
except:
|
||||
except Exception:
|
||||
die(2, 'Unable to write ' + desc)
|
||||
msg('Wrote ' + desc)
|
||||
|
||||
|
|
@ -367,17 +367,17 @@ class Autosign:
|
|||
import shutil
|
||||
try:
|
||||
shutil.rmtree(self.wallet_dir)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def create_wallet_dir():
|
||||
try:
|
||||
self.wallet_dir.mkdir(parents=True)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
self.wallet_dir.stat()
|
||||
except:
|
||||
except Exception:
|
||||
die(2, f'Unable to create wallet directory ‘{self.wallet_dir}’')
|
||||
|
||||
self.gen_key(no_unmount=True)
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ def is_mmgen_mnemonic(s):
|
|||
try:
|
||||
baseconv('mmgen').tobytes(s.split(), pad='seed')
|
||||
return True
|
||||
except:
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
class baseconv:
|
||||
|
|
|
|||
|
|
@ -840,7 +840,7 @@ def check_opts(cfg): # Raises exception if any check fails
|
|||
case 'hidden_incog_output_params':
|
||||
try:
|
||||
os.stat(fn)
|
||||
except:
|
||||
except Exception:
|
||||
b = os.path.dirname(fn)
|
||||
if b:
|
||||
check_outdir(b)
|
||||
|
|
@ -969,5 +969,5 @@ def conv_type(name, val, refval, *, src, invert_bool=False):
|
|||
else:
|
||||
try:
|
||||
return type(refval)(not val if invert_bool else val)
|
||||
except:
|
||||
except Exception:
|
||||
do_fail()
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ class cfg_file:
|
|||
with open(fn, 'w') as fp:
|
||||
fp.write('\n'.join(data)+'\n')
|
||||
os.chmod(fn, 0o600)
|
||||
except:
|
||||
except Exception:
|
||||
die(2, f'ERROR: unable to write to {fn!r}')
|
||||
|
||||
def parse_value(self, value, refval):
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ class Daemon(Lockable):
|
|||
def state_msg(self, *, extra_text=None):
|
||||
try:
|
||||
pid = self.pid
|
||||
except:
|
||||
except Exception:
|
||||
pid = None
|
||||
extra_text = 'not ' if self.state == 'stopped' else f'{extra_text} ' if extra_text else ''
|
||||
return '{:{w}} {:10} {}'.format(
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ def check_binary(args):
|
|||
from subprocess import run, DEVNULL
|
||||
try:
|
||||
run(args, stdout=DEVNULL, stderr=DEVNULL, check=True)
|
||||
except:
|
||||
except Exception:
|
||||
die(2, f'{args[0]!r} binary missing, not in path, or not executable')
|
||||
|
||||
def shred_file(cfg, fn, *, iterations=30):
|
||||
|
|
@ -137,7 +137,7 @@ def get_seed_file(cfg, *, nargs, wallets=None, invoked_as=None):
|
|||
def _open_or_die(filename, mode, *, silent=False):
|
||||
try:
|
||||
return open(filename, mode)
|
||||
except:
|
||||
except Exception:
|
||||
if silent:
|
||||
die(2, '')
|
||||
else:
|
||||
|
|
@ -216,7 +216,7 @@ def write_data_to_file(
|
|||
# MSWin workaround. See msg_r()
|
||||
try:
|
||||
sys.stdout.write(data.decode() if isinstance(data, bytes) else data)
|
||||
except:
|
||||
except Exception:
|
||||
os.write(1, data if isinstance(data, bytes) else data.encode())
|
||||
|
||||
def do_file(outfile, ask_write_prompt):
|
||||
|
|
@ -260,7 +260,7 @@ def write_data_to_file(
|
|||
try:
|
||||
with _open_or_die(outfile, 'wb') as fp:
|
||||
fp.write(data if binary else data.encode())
|
||||
except:
|
||||
except Exception:
|
||||
die(2, f'Failed to write {desc} to file {outfile!r}')
|
||||
|
||||
if not (hush or quiet):
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ def launch(*, mod=None, func=None, fqmod=None, package='mmgen'):
|
|||
except Exception as e:
|
||||
try:
|
||||
errmsg = str(e.args[0])
|
||||
except:
|
||||
except Exception:
|
||||
errmsg = repr(e.args[0]) if e.args else repr(e)
|
||||
|
||||
from collections import namedtuple
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ class MsgOps:
|
|||
async def __init__(self, msgfile, *, addr=None):
|
||||
try:
|
||||
m = SignedOnlineMsg(cfg, infile=msgfile)
|
||||
except:
|
||||
except Exception:
|
||||
m = ExportedMsgSigs(cfg, infile=msgfile)
|
||||
|
||||
nSigs = await m.verify(addr=addr)
|
||||
|
|
|
|||
|
|
@ -219,7 +219,7 @@ def process_result(ret, *, pager=False, print_result=False):
|
|||
case bytes():
|
||||
try:
|
||||
return triage_result(ret.decode())
|
||||
except:
|
||||
except Exception:
|
||||
# don't add NL to binary data if it can't be converted to utf8
|
||||
return os.write(1, ret) if print_result else ret
|
||||
case _:
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ def init_autosign(arg):
|
|||
elif post_send_op:
|
||||
try:
|
||||
tx_range = SentTXRange(arg)
|
||||
except:
|
||||
except Exception:
|
||||
die(2, f'{arg}: invalid transaction index arg '
|
||||
'(must be a non-negative integer or hyphen-separated range)')
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -357,7 +357,7 @@ class BitcoinRPCClient(RPCClient, metaclass=AsyncInit):
|
|||
try:
|
||||
lines = get_lines_from_file(
|
||||
self.cfg, fn, desc='daemon config file', silent=not self.cfg.verbose)
|
||||
except:
|
||||
except Exception:
|
||||
self.cfg._util.vmsg(f'Warning: {fn!r} does not exist or is unreadable')
|
||||
return {k: None for k in req_keys}
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ class BitcoinTwJSON(TwJSON):
|
|||
try:
|
||||
await self.twctl.rpc.check_or_create_daemon_wallet()
|
||||
return True
|
||||
except:
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
async def get_entries(self):
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ class New(Base, TxNew):
|
|||
self.cfg.fee_estimate_mode.upper())
|
||||
fee_per_kb = self.proto.coin_amt(ret['feerate']) if 'feerate' in ret else None
|
||||
fe_type = 'estimatesmartfee'
|
||||
except:
|
||||
except Exception:
|
||||
args = self.rpc.daemon.estimatefee_args(self.rpc)
|
||||
ret = await self.rpc.call('estimatefee', *args)
|
||||
fee_per_kb = self.proto.coin_amt(ret)
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ class Status(TxBase.Status):
|
|||
txid = tx.coin_txid,
|
||||
include_watchonly = True,
|
||||
verbose = False)
|
||||
except:
|
||||
except Exception:
|
||||
return False
|
||||
if ret.get('confirmations', 0) > 0:
|
||||
r.confs = ret['confirmations']
|
||||
|
|
@ -49,14 +49,14 @@ class Status(TxBase.Status):
|
|||
async def is_in_utxos():
|
||||
try:
|
||||
return 'txid' in await tx.rpc.call('getrawtransaction', tx.coin_txid, True)
|
||||
except:
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
async def is_in_mempool():
|
||||
try:
|
||||
await tx.rpc.call('getmempoolentry', tx.coin_txid)
|
||||
return True
|
||||
except:
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
async def is_replaced():
|
||||
|
|
@ -68,7 +68,7 @@ class Status(TxBase.Status):
|
|||
txid = tx.coin_txid,
|
||||
include_watchonly = True,
|
||||
verbose = False)
|
||||
except:
|
||||
except Exception:
|
||||
return False
|
||||
else:
|
||||
if 'bip125-replaceable' in ret and ret.get('confirmations', 1) <= 0:
|
||||
|
|
@ -108,7 +108,7 @@ class Status(TxBase.Status):
|
|||
for txid in r.replacing_txs:
|
||||
try:
|
||||
d.append(await tx.rpc.call('getmempoolentry', txid))
|
||||
except:
|
||||
except Exception:
|
||||
d.append({})
|
||||
for txid, mp_entry in zip(r.replacing_txs, d):
|
||||
msg(f' {txid}' + (' in mempool' if 'height' in mp_entry else ''))
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ class Token(Contract):
|
|||
try:
|
||||
assert ret.startswith('0x')
|
||||
return int(ret, 16)
|
||||
except:
|
||||
except Exception:
|
||||
msg(f'RPC call to decimals() failed (returned {ret!r})')
|
||||
|
||||
async def get_total_supply(self):
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ class RPCClient:
|
|||
return ret
|
||||
else:
|
||||
return json.loads(text, parse_float=float_parser)
|
||||
except:
|
||||
except Exception:
|
||||
if not m:
|
||||
t = json.loads(text)
|
||||
try:
|
||||
|
|
@ -184,10 +184,10 @@ class RPCClient:
|
|||
if text:
|
||||
try:
|
||||
m = json.loads(text)['error']['message']
|
||||
except:
|
||||
except Exception:
|
||||
try:
|
||||
m = text.decode()
|
||||
except:
|
||||
except Exception:
|
||||
m = text
|
||||
die('RPCFailure', f'{s.value} {s.name}: {m}')
|
||||
|
||||
|
|
|
|||
|
|
@ -105,12 +105,12 @@ class MMGenTermLinux(MMGenTerm):
|
|||
def get_terminal_size(cls):
|
||||
try:
|
||||
ret = os.get_terminal_size()
|
||||
except:
|
||||
except Exception:
|
||||
try:
|
||||
ret = (
|
||||
int(os.environ['COLUMNS']),
|
||||
int(os.environ['LINES']))
|
||||
except:
|
||||
except Exception:
|
||||
ret = (80, 25)
|
||||
return _term_dimensions(*ret)
|
||||
|
||||
|
|
@ -207,7 +207,7 @@ class MMGenTermMSWin(MMGenTerm):
|
|||
left, top, right, bottom = struct.unpack('hhhhHhhhhhh', csbi.raw)[5:9]
|
||||
x = right - left + 1
|
||||
y = bottom - top + 1
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
if x and y:
|
||||
|
|
@ -276,7 +276,7 @@ class MMGenTermMSWinStub(MMGenTermMSWin):
|
|||
while True:
|
||||
try:
|
||||
return sys.stdin.read(1)
|
||||
except:
|
||||
except Exception:
|
||||
msg('[read error, trying again]')
|
||||
time.sleep(0.5)
|
||||
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ def process_args(cmd, cmd_args, cls):
|
|||
|
||||
try:
|
||||
return __builtins__[arg_type](arg)
|
||||
except:
|
||||
except Exception:
|
||||
die(1, f'{arg!r}: Invalid argument for argument {arg_name} ({arg_type!r} required)')
|
||||
|
||||
if flag == 'VAR_ARGS':
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue