autosign,xmrwallet,proto.xmr.rpc: minor fixes and cleanups

This commit is contained in:
The MMGen Project 2023-04-24 13:23:42 +00:00
commit 260d49b097
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
3 changed files with 19 additions and 6 deletions

View file

@ -215,7 +215,11 @@ class Autosign:
try:
await rpc_init( self.cfg, proto )
except SocketError as e:
die(2,f'{coin} daemon not running or not listening on port {proto.rpc_port}')
from .daemon import CoinDaemon
d = CoinDaemon( self.cfg, proto=proto, test_suite=self.cfg.test_suite )
die(2,
f'\n{e}\nIs the {d.coind_name} daemon ({d.exec_fn}) running '
+ 'and listening on the correct port?' )
@property
def wallet_files(self):

View file

@ -133,4 +133,13 @@ class MoneroWalletRPCClient(MoneroRPCClient):
NB: the 'stop_wallet' RPC call closes the open wallet before shutting down the daemon,
returning an error if no wallet is open
"""
return self.call('stop_wallet')
try:
return self.call('stop_wallet')
except Exception as e:
from ...util import msg,msg_r,ymsg
from ...color import yellow
msg(f'{type(e).__name__}: {e}')
msg_r(yellow(f'Unable to shut down wallet daemon gracefully, so killing process instead...'))
ret = self.daemon.stop(silent=True)
ymsg('done')
return ret

View file

@ -568,8 +568,8 @@ class MoneroWalletOps:
gmsg_r(f'\n Opening {desc} wallet...')
self.c.call( # returns {}
'open_wallet',
filename=os.path.basename(self.fn),
password=self.d.wallet_passwd )
filename = os.path.basename(self.fn),
password = self.d.wallet_passwd )
gmsg('done')
if refresh:
@ -797,8 +797,8 @@ class MoneroWalletOps:
msg_r(' Opening wallet...')
self.c.call(
'open_wallet',
filename=os.path.basename(fn),
password=d.wallet_passwd )
filename = os.path.basename(fn),
password = d.wallet_passwd )
msg('done')
msg_r(' Getting wallet height (be patient, this could take a long time)...')