Browse Source

macOS: enable live autosigning (bugfix)

The MMGen Project 6 months ago
parent
commit
d5939ef063
5 changed files with 12 additions and 11 deletions
  1. 4 1
      mmgen/autosign.py
  2. 2 3
      mmgen/main_txbump.py
  3. 2 3
      mmgen/main_txcreate.py
  4. 2 3
      mmgen/main_txsend.py
  5. 2 1
      mmgen/tx/util.py

+ 4 - 1
mmgen/autosign.py

@@ -731,7 +731,10 @@ class Autosign:
 		if sys.platform == 'linux':
 			return self.dev_label_path.exists()
 		elif sys.platform == 'darwin':
-			return self.mountpoint.exists()
+			if self.cfg.test_suite_root_pfx:
+				return self.mountpoint.exists()
+			else:
+				return run(['diskutil', 'info', self.dev_label], stdout=DEVNULL, stderr=DEVNULL).returncode == 0
 
 	async def main_loop(self):
 		if not self.cfg.stealth_led:

+ 2 - 3
mmgen/main_txbump.py

@@ -128,10 +128,9 @@ silent = cfg.yes and cfg.fee is not None and cfg.output_to_reduce is not None
 async def main():
 
 	if cfg.autosign:
-		from .tx.util import init_removable_device
+		from .tx.util import mount_removable_device
 		from .autosign import Signable
-		asi = init_removable_device(cfg)
-		asi.do_mount()
+		asi = mount_removable_device(cfg)
 		si = Signable.automount_transaction(asi)
 		if si.unsigned or si.unsent:
 			state = 'unsigned' if si.unsigned else 'unsent'

+ 2 - 3
mmgen/main_txcreate.py

@@ -87,10 +87,9 @@ cfg = Config(opts_data=opts_data)
 async def main():
 
 	if cfg.autosign:
-		from .tx.util import init_removable_device
+		from .tx.util import mount_removable_device
 		from .autosign import Signable
-		asi = init_removable_device(cfg)
-		asi.do_mount()
+		asi = mount_removable_device(cfg)
 		Signable.automount_transaction(asi).check_create_ok()
 
 	from .tx import NewTX

+ 2 - 3
mmgen/main_txsend.py

@@ -63,10 +63,9 @@ if len(cfg._args) == 1:
 	from .fileutil import check_infile
 	check_infile(infile)
 elif not cfg._args and cfg.autosign:
-	from .tx.util import init_removable_device
+	from .tx.util import mount_removable_device
 	from .autosign import Signable
-	asi = init_removable_device(cfg)
-	asi.do_mount()
+	asi = mount_removable_device(cfg)
 	si = Signable.automount_transaction(asi)
 	if cfg.abort:
 		si.shred_abortable() # prompts user, then raises exception or exits

+ 2 - 1
mmgen/tx/util.py

@@ -25,11 +25,12 @@ def get_autosign_obj(cfg):
 		})
 	)
 
-def init_removable_device(cfg):
+def mount_removable_device(cfg):
 	asi = get_autosign_obj(cfg)
 	if not asi.device_inserted:
 		from ..util import die
 		die(1, 'Removable device not present!')
 	import atexit
 	atexit.register(lambda: asi.do_umount())
+	asi.do_mount()
 	return asi