Browse Source

xmrwallet: delay mounting of removable device

The MMGen Project 8 months ago
parent
commit
1f75be898d
6 changed files with 25 additions and 15 deletions
  1. 1 1
      .github/workflows/pylint.yaml
  2. 1 1
      mmgen/data/release_date
  3. 1 1
      mmgen/data/version
  4. 0 10
      mmgen/main_xmrwallet.py
  5. 22 1
      mmgen/xmrwallet.py
  6. 0 1
      pyproject.toml

+ 1 - 1
.github/workflows/pylint.yaml

@@ -17,7 +17,7 @@ jobs:
 
     strategy:
       matrix:
-        python-version: ["3.9","3.10","3.11"]
+        python-version: ["3.10","3.11"]
 
     steps:
     - uses: actions/checkout@v4

+ 1 - 1
mmgen/data/release_date

@@ -1 +1 @@
-January 2024
+February 2024

+ 1 - 1
mmgen/data/version

@@ -1 +1 @@
-14.1.dev7
+14.1.dev8

+ 0 - 10
mmgen/main_xmrwallet.py

@@ -145,16 +145,6 @@ else:
 
 op_cls = getattr(MoneroWalletOps,op.replace('-','_'))
 
-if cfg.autosign and not cfg.test_suite:
-	from .autosign import get_autosign_obj
-	asi = get_autosign_obj(cfg,'xmr')
-	if not asi.get_insert_status():
-		die(1,'Removable device not present!')
-	if op_cls.do_umount:
-		import atexit
-		atexit.register(lambda: asi.do_umount())
-	asi.do_mount()
-
 m = op_cls(cfg, xmrwallet_uargs(infile, wallets, spec))
 
 if async_run(m.main()):

+ 22 - 1
mmgen/xmrwallet.py

@@ -731,6 +731,21 @@ class MoneroWalletOps:
 		async def stop_wallet_daemon(self):
 			pass
 
+		def post_mount_action(self):
+			pass
+
+		def mount_removable_device(self):
+			if self.cfg.autosign and not self.cfg.test_suite:
+				from .autosign import get_autosign_obj
+				asi = get_autosign_obj(self.cfg,'xmr')
+				if not asi.get_insert_status():
+					die(1,'Removable device not present!')
+				if self.do_umount:
+					import atexit
+					atexit.register(lambda: asi.do_umount())
+				asi.do_mount()
+				self.post_mount_action()
+
 	class wallet(base):
 
 		opts = (
@@ -806,6 +821,7 @@ class MoneroWalletOps:
 					addr_idxs = uarg.wallets,
 					skip_chksum_msg = True )
 			else:
+				self.mount_removable_device()
 				# with watch_only, make a second attempt to open the file as KeyAddrList:
 				for first_try in (True,False):
 					try:
@@ -1687,7 +1703,7 @@ class MoneroWalletOps:
 		action = 'submitting transaction with'
 		opts = ('tx_relay_daemon',)
 
-		def check_uopts(self):
+		def post_mount_action(self):
 			self.tx # trigger an exit if no suitable transaction present
 
 		def die_no_tx(self,desc,num_txs,tx_dir):
@@ -1905,6 +1921,8 @@ class MoneroWalletOps:
 
 			super().__init__(cfg,uarg_tuple)
 
+			self.mount_removable_device()
+
 			self.tx = MoneroMMGenTX.Signed( self.cfg, Path(uarg.infile) )
 
 			if self.cfg.tx_relay_daemon:
@@ -1960,6 +1978,9 @@ class MoneroWalletOps:
 		do_umount = False
 
 		async def main(self,cols=None):
+
+			self.mount_removable_device()
+
 			if self.cfg.autosign:
 				asi = get_autosign_obj(self.cfg,'xmr')
 				files = [f for f in asi.xmr_tx_dir.iterdir() if f.name.endswith('.'+MoneroMMGenTX.Submitted.ext)]

+ 0 - 1
pyproject.toml

@@ -12,7 +12,6 @@ indent-after-paren = 2
 max-line-length = 110
  
 [tool.pylint.main]
-py-version = "3.7"
 recursive = true
 jobs = 0
 ignore = [