2018-02-10 07:47:29 +01:00
|
|
|
import os.path
|
|
|
|
import subprocess
|
2019-02-22 14:15:36 +01:00
|
|
|
import distutils.spawn
|
2018-02-10 07:47:29 +01:00
|
|
|
home = os.path.expanduser("~")
|
|
|
|
def mailpasswd(acct):
|
|
|
|
acct = os.path.basename(acct)
|
2019-02-21 16:14:17 +01:00
|
|
|
path = "%s/.local/share/muttwizard/%s.gpg" % (home,acct)
|
2019-02-22 14:15:36 +01:00
|
|
|
if distutils.spawn.find_executable("gpg"):
|
|
|
|
GPG="gpg"
|
|
|
|
else:
|
|
|
|
GPG="gpg2"
|
|
|
|
args = [GPG, "--use-agent", "--quiet", "--batch", "-d", path]
|
2018-02-10 07:47:29 +01:00
|
|
|
try:
|
2019-02-19 14:14:17 +01:00
|
|
|
return subprocess.check_output(args).strip().decode('UTF-8')
|
2018-02-10 07:47:29 +01:00
|
|
|
except subprocess.CalledProcessError:
|
|
|
|
return ""
|