and i *think* getSecret is done. had to work around some argparse weirdness.
This commit is contained in:
@@ -246,15 +246,18 @@ class VaultPass(object):
|
||||
'seconds': seconds,
|
||||
'printme': printme}
|
||||
data = self.getSecret(**args)
|
||||
if qr is not None:
|
||||
data, has_x = QR.genQr(data, image = True)
|
||||
if qr not in (False, None):
|
||||
qrdata, has_x = QR.genQr(data, image = True)
|
||||
if has_x:
|
||||
fpath = tempfile.mkstemp(prefix = '.vaultpass.qr.', suffix = '.svg', dir = '/dev/shm')[1]
|
||||
_logger.debug('Writing to {0} so it can be displayed'.format(fpath))
|
||||
with open(fpath, 'wb') as fh:
|
||||
fh.write(data.read())
|
||||
fh.write(qrdata.read())
|
||||
if printme:
|
||||
_logger.debug('Opening {0} in the default image viwer application'.format(fpath))
|
||||
# We intentionally want this to block, as most image viewers will
|
||||
# unload the image once the file is deleted and we can probably
|
||||
# elete it before the user can save it elsewhere or scan it with their phone.
|
||||
cmd = subprocess.run(['xdg-open', fpath], stdout = subprocess.PIPE, stderr = subprocess.PIPE)
|
||||
if cmd.returncode != 0:
|
||||
_logger.error('xdg-open returned non-zero status code')
|
||||
@@ -267,10 +270,10 @@ class VaultPass(object):
|
||||
_logger.debug('{0}: {1}'.format(x.upper(), o))
|
||||
os.remove(fpath)
|
||||
elif printme:
|
||||
print(data.read())
|
||||
data.seek(0, 0)
|
||||
# TODO: clip, etc.
|
||||
clipboard.pasteClipboard(printme = printme)
|
||||
print(qrdata.read())
|
||||
qrdata.seek(0, 0)
|
||||
if clip not in (False, None):
|
||||
clipboard.pasteClipboard(data, seconds = seconds, clipboard = clipboard, printme = printme)
|
||||
return(data)
|
||||
|
||||
def initVault(self, *args, **kwargs):
|
||||
|
||||
@@ -337,7 +337,7 @@ def parseArgs():
|
||||
dest = 'path',
|
||||
help = ('(Dummy option; kept for compatibility reasons)'))
|
||||
initvault.add_argument('gpg_id',
|
||||
dest = 'gpg_id',
|
||||
metavar = 'GPG_KEY_ID',
|
||||
help = ('(Dummy option; kept for compatibility reasons)'))
|
||||
# INSERT
|
||||
# vp.insertSecret()
|
||||
@@ -411,22 +411,14 @@ def parseArgs():
|
||||
# vp.getSecret(printme = True)
|
||||
# TODO: does the default overwrite the None if not specified?
|
||||
show.add_argument('-c', '--clip',
|
||||
nargs = '?',
|
||||
type = int,
|
||||
default = None,
|
||||
metavar = 'LINE_NUMBER',
|
||||
action = 'store_true',
|
||||
dest = 'clip',
|
||||
help = ('If specified, do not print the secret but instead copy it to the clipboard. '
|
||||
'LINE_NUMBER has no effect and is kept for compatibility reasons'))
|
||||
help = ('If specified, do not print the secret but instead copy it to the clipboard'))
|
||||
show.add_argument('-q', '--qrcode',
|
||||
dest = 'qr',
|
||||
nargs = '?',
|
||||
type = int,
|
||||
metavar = 'LINE_NUMBER',
|
||||
default = None,
|
||||
action = 'store_true',
|
||||
help = ('If specified, do not print the secret but instead generate a QR code of it (either '
|
||||
'graphically or in-terminal depending on environment). '
|
||||
'LINE_NUMBER has no effect and is kept for compatibility reasons'))
|
||||
'graphically or in-terminal depending on environment)'))
|
||||
show.add_argument('-s', '--seconds',
|
||||
dest = 'seconds',
|
||||
type = int,
|
||||
|
||||
Reference in New Issue
Block a user