autosign: get_insert_status() -> device_inserted
This commit is contained in:
parent
6d87cb3980
commit
063847db0e
4 changed files with 10 additions and 15 deletions
|
|
@ -579,7 +579,7 @@ class Autosign:
|
|||
msg('Wrote ' + desc)
|
||||
|
||||
def gen_key(self,no_unmount=False):
|
||||
if not self.get_insert_status():
|
||||
if not self.device_inserted:
|
||||
die(1,'Removable device not present!')
|
||||
self.do_mount()
|
||||
self.wipe_encryption_key()
|
||||
|
|
@ -697,8 +697,11 @@ class Autosign:
|
|||
|
||||
bmsg(f'{count} file{suf(count)} shredded')
|
||||
|
||||
def get_insert_status(self):
|
||||
return self.cfg.no_insert_check or self.dev_label_path.exists()
|
||||
@property
|
||||
def device_inserted(self):
|
||||
if self.cfg.no_insert_check:
|
||||
return True
|
||||
return self.dev_label_path.exists()
|
||||
|
||||
async def main_loop(self):
|
||||
if not self.cfg.stealth_led:
|
||||
|
|
@ -707,7 +710,7 @@ class Autosign:
|
|||
n = 1 if threaded else 0
|
||||
prev_status = False
|
||||
while True:
|
||||
status = self.get_insert_status()
|
||||
status = self.device_inserted
|
||||
if status and not prev_status:
|
||||
msg('Device insertion detected')
|
||||
await self.do_sign()
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ def get_autosign_obj(cfg):
|
|||
|
||||
def init_removable_device(cfg):
|
||||
asi = get_autosign_obj(cfg)
|
||||
if not asi.get_insert_status():
|
||||
if not asi.device_inserted:
|
||||
from ..util import die
|
||||
die(1, 'Removable device not present!')
|
||||
import atexit
|
||||
|
|
|
|||
|
|
@ -824,7 +824,7 @@ class MoneroWalletOps:
|
|||
|
||||
def mount_removable_device(self):
|
||||
if self.cfg.autosign:
|
||||
if not self.asi.get_insert_status():
|
||||
if not self.asi.device_inserted:
|
||||
die(1,'Removable device not present!')
|
||||
if self.do_umount:
|
||||
import atexit
|
||||
|
|
|
|||
|
|
@ -164,10 +164,6 @@ class CmdTestAutosignBase(CmdTestBase):
|
|||
t.written_to_file('Autosign wallet')
|
||||
return t
|
||||
|
||||
@property
|
||||
def device_inserted(self):
|
||||
return self.asi.dev_label_path.exists()
|
||||
|
||||
def insert_device(self):
|
||||
self.asi.dev_label_path.touch()
|
||||
|
||||
|
|
@ -356,7 +352,7 @@ class CmdTestAutosignThreaded(CmdTestAutosignBase):
|
|||
|
||||
def _wait_signed(self,desc):
|
||||
oqmsg_r(gray(f'→ offline wallet{"s" if desc.endswith("s") else ""} waiting for {desc}'))
|
||||
assert not self.device_inserted, f'‘{self.asi.dev_label_path}’ is inserted!'
|
||||
assert not self.asi.device_inserted, f'‘{self.asi.dev_label_path}’ is inserted!'
|
||||
assert not self.asi.mountpoint.is_mount(), f'‘{self.asi.mountpoint}’ is mounted!'
|
||||
self.insert_device()
|
||||
while True:
|
||||
|
|
@ -375,10 +371,6 @@ class CmdTestAutosignThreaded(CmdTestAutosignBase):
|
|||
self.remove_device()
|
||||
return 'ok'
|
||||
|
||||
@property
|
||||
def device_inserted_online(self):
|
||||
return self.asi_online.dev_label_path.exists()
|
||||
|
||||
def insert_device_online(self):
|
||||
self.asi_online.dev_label_path.touch()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue