From 3bfad0c1d0b0243a0cde9895c08ce96bfc924ce6 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Mon, 26 Jan 2026 10:56:21 +0000 Subject: [PATCH] xmrwallet.ops: refactor `mount_removable_device()` --- mmgen/tx/util.py | 10 ++++++---- mmgen/xmrwallet/ops/__init__.py | 12 ++++-------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/mmgen/tx/util.py b/mmgen/tx/util.py index d3886ddb..33df7346 100755 --- a/mmgen/tx/util.py +++ b/mmgen/tx/util.py @@ -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 diff --git a/mmgen/xmrwallet/ops/__init__.py b/mmgen/xmrwallet/ops/__init__.py index 54aa4bec..0db1b99f 100755 --- a/mmgen/xmrwallet/ops/__init__.py +++ b/mmgen/xmrwallet/ops/__init__.py @@ -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):