add offlineimap configurations
[~bandali/configs] / offlineimap / .offlineimap.py
... / ...
CommitLineData
1import os
2import subprocess
3
4def mailpasswd(acct):
5 acct = os.path.basename(acct)
6 path = "/home/amin/.passwd/%s.gpg" % acct
7 args = ["gpg", "--use-agent", "--quiet", "--batch", "-d", path]
8 try:
9 return subprocess.check_output(args).strip()
10 except subprocess.CalledProcessError:
11 return ""
12
13def prime_gpg_agent():
14 ret = False
15 i = 1
16 while not ret:
17 ret = (mailpasswd("prime") == "prime")
18 if i > 2:
19 from offlineimap.ui import getglobalui
20 sys.stderr.write("Error reading in passwords. Terminating.\n")
21 getglobalui().terminate()
22 i += 1
23 return ret
24
25prime_gpg_agent()