2019-09-04 16:40:41 +00:00
|
|
|
from subprocess import check_output, call
|
|
|
|
import os
|
|
|
|
import sys
|
2020-04-15 12:26:48 +00:00
|
|
|
import deprecation
|
2019-09-04 16:40:41 +00:00
|
|
|
|
2020-04-15 12:26:48 +00:00
|
|
|
@deprecation.deprecated(deprecated_in="0.5.0", removed_in="1.0",
|
|
|
|
details='use gopass_password_from_path(os.environ.get(env_var, None)) instead')
|
2020-01-28 11:47:43 +00:00
|
|
|
def gopass_credential_from_env_path (env_var):
|
|
|
|
env_path = os.environ.get(env_var, None)
|
2020-04-11 13:12:02 +00:00
|
|
|
return gopass_password_from_path(env_path)
|
2020-01-28 10:47:21 +00:00
|
|
|
|
2020-04-15 12:26:48 +00:00
|
|
|
@deprecation.deprecated(deprecated_in="0.5.0", removed_in="1.0",
|
|
|
|
details='use gopass_password_from_path(path) instead')
|
2020-01-28 10:47:21 +00:00
|
|
|
def gopass_credential_from_path (path):
|
2020-04-11 13:12:02 +00:00
|
|
|
return gopass_password_from_path(path)
|
|
|
|
|
|
|
|
|
|
|
|
def gopass_field_from_path (path, field):
|
|
|
|
credential = None
|
|
|
|
|
|
|
|
if path and field:
|
|
|
|
print('get credential for: ' + path)
|
|
|
|
if sys.version_info.major == 3:
|
|
|
|
credential = check_output(['gopass', 'show', path, field], encoding='UTF-8')
|
|
|
|
else:
|
|
|
|
credential = check_output(['gopass', 'show', path, field])
|
|
|
|
|
|
|
|
return credential
|
|
|
|
|
|
|
|
def gopass_password_from_path (path):
|
2019-09-04 16:40:41 +00:00
|
|
|
credential = None
|
|
|
|
|
2020-01-28 11:47:43 +00:00
|
|
|
if path:
|
2020-01-28 11:08:43 +00:00
|
|
|
print('get credential for: ' + path)
|
2019-09-04 16:40:41 +00:00
|
|
|
if sys.version_info.major == 3:
|
2020-04-11 13:12:02 +00:00
|
|
|
credential = check_output(['gopass', 'show', '--password', path], encoding='UTF-8')
|
2019-09-04 16:40:41 +00:00
|
|
|
else:
|
2020-04-11 13:12:02 +00:00
|
|
|
credential = check_output(['gopass', 'show', '--password', path])
|
2019-09-04 16:40:41 +00:00
|
|
|
|
|
|
|
return credential
|
2020-01-28 10:47:21 +00:00
|
|
|
|