def mount(volume, where, pw=None, validator=os.path.isdir, timeout=15): dictionary = { 'app': APP, 'volume': volume, 'where': where } out(utils.replacekeys('Mounting ${volume} at ${where} ...', dictionary)) if pw is None: cmd = utils.replacekeys(COMMANDS['mount'], dictionary) else: dictionary.update({'pw': pw}) cmd = utils.replacekeys(COMMANDS['mountpw'], dictionary) os.system(cmd) return wait(lambda: validator(where), timeout)
def call(argv): parser = argparse.ArgumentParser(prog='truecrypt') subparsers = parser.add_subparsers(dest='cmd') for key, cmd in COMMANDS.items(): subparser = subparsers.add_parser(key) for arg in re.findall(r"\$\{([A-Za-z0-9_]+)\}", cmd)[1:]: subparser.add_argument(arg) try: args = vars(parser.parse_args(argv)) except SystemExit: return cmd = args.pop('cmd') args['app'] = APP os.system(utils.replacekeys(COMMANDS[cmd], args))
def dismountall(): dictionary = { 'app': APP } out('Dismounting all ...') os.system(utils.replacekeys(COMMANDS['dismountall'], dictionary))
def dismount(where): dictionary = { 'app': APP, 'where': where } out(utils.replacekeys('Dismounting ${where} ...', dictionary)) os.system(utils.replacekeys(COMMANDS['dismount'], dictionary))
def automount(volume): dictionary = { 'app': APP, 'volume': volume } out(utils.replacekeys('Mounting ${volume} ...', dictionary)) os.system(utils.replacekeys(COMMANDS['automount'], dictionary))