xmrwallet.ops: refactor mount_removable_device()

This commit is contained in:
The MMGen Project 2026-01-26 10:56:21 +00:00
commit 3bfad0c1d0
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
2 changed files with 10 additions and 12 deletions

View file

@ -23,12 +23,14 @@ def get_autosign_obj(cfg, add_cfg={}):
# used only in online environment (xmrwallet, txcreate, txsend, txbump):
'online': not cfg.offline} | add_cfg))
def mount_removable_device(cfg, add_cfg={}):
asi = get_autosign_obj(cfg, add_cfg=add_cfg)
def mount_removable_device(cfg, do_umount=True, asi=None, add_cfg={}, do_umount_registered=[]):
asi = asi or get_autosign_obj(cfg, add_cfg=add_cfg)
if not asi.device_inserted:
from ..util import die
die(1, 'Removable device not present!')
import atexit
atexit.register(lambda: asi.do_umount())
if do_umount and not do_umount_registered:
import atexit
atexit.register(lambda: asi.do_umount())
do_umount_registered.append(None)
asi.do_mount()
return asi

View file

@ -12,7 +12,7 @@
xmrwallet.ops.__init__: Monero wallet ops for the MMGen Suite
"""
import re, atexit
import re
from ...color import blue
from ...util import msg, die, fmt
@ -115,14 +115,10 @@ class OpBase:
Proxy: {blue(m[2] or 'None')}
""", strip_char='\t', indent=indent))
def mount_removable_device(self, registered=[]):
def mount_removable_device(self):
if self.cfg.autosign:
if not self.asi.device_inserted:
die(1, 'Removable device not present!')
if self.do_umount and not registered:
atexit.register(lambda: self.asi.do_umount())
registered.append(None)
self.asi.do_mount()
from ...tx.util import mount_removable_device
mount_removable_device(self.cfg, do_umount=self.do_umount, asi=self.asi)
self.post_mount_action()
def pre_init_action(self):