aboutsummaryrefslogtreecommitdiffstats
path: root/.offlineimap/offlineimap.py
diff options
context:
space:
mode:
authorAaron LI <aaronly.me@gmail.com>2016-01-06 22:59:26 +0800
committerAaron LI <aaronly.me@gmail.com>2016-01-06 22:59:26 +0800
commit25b947edf445a96db335fe285a8b253b214649ff (patch)
tree3f785cdbef303c71111debd067c95a62ea456587 /.offlineimap/offlineimap.py
parent0ed3373f1c2d47aba769aa67439e05350c2792e9 (diff)
downloaddotfiles-25b947edf445a96db335fe285a8b253b214649ff.tar.bz2
Rename .* => _*; Move out private contents.
Diffstat (limited to '.offlineimap/offlineimap.py')
-rw-r--r--.offlineimap/offlineimap.py68
1 files changed, 0 insertions, 68 deletions
diff --git a/.offlineimap/offlineimap.py b/.offlineimap/offlineimap.py
deleted file mode 100644
index e3ae422..0000000
--- a/.offlineimap/offlineimap.py
+++ /dev/null
@@ -1,68 +0,0 @@
-#!/usr/bin/env python
-#
-# Add support of encrypting password with gpg2 for OfflineIMAP.
-# Provide function 'mailpasswd' to decrypt the password.
-#
-# Configurations:
-# [general]
-# pythonfile = ~/.offlineimap/offlineimap.py
-# ...
-# [Repository <reponame>]
-# remotepasseval = mailpasswd("<accountname>")
-# ...
-#
-# Reference:
-# [1] Encrypt OfflineIMAP Password
-# http://unix.stackexchange.com/questions/44214/encrypt-offlineimap-password
-#
-# Updated: 2015/02/02
-#
-
-import os
-import subprocess
-
-def mailpasswd(account):
- account = os.path.basename(account)
- path = '{0}/.offlineimap/{1}.gpg'.format(os.environ['HOME'], account)
- args = ['gpg2', '--for-your-eyes-only', '--no-tty',
- '--quiet', '--batch', '--decrypt', path]
- try:
- return subprocess.check_output(args).strip()
- except subprocess.CalledProcessError:
- return ''
-
-# subprocess.check_output() only introduced in python 2.7
-# this version of 'mailpasswd' works with older version of python
-#def mailpasswd(account):
-# account = os.path.basename(account)
-# path = '{0}/.offlineimap/{1}.gpg'.format(os.environ['HOME'], account)
-# args = ['gpg2', '--for-your-eyes-only', '--no-tty',
-# '--quiet', '--batch', '--decrypt', path]
-# proc = subprocess.Popen(args, stdout=subprocess.PIPE)
-# output = proc.communicate()[0].strip()
-# retcode = proc.wait()
-# if retcode == 0:
-# return output
-# else:
-# return ''
-
-
-# If you have several accounts that get checked simultaneously, and you
-# use 'gpg-agent', then it will ask for you passphrase for each account.
-# I prime the agent by creating a file, and priming the gpg-agent by
-# decrypting this file on launch of offlineimap.
-def prime_gpg_agent():
- # echo "prime" | gpg -e -r <recipient> > ~/.offlineimap/prime.gpg
- ret = False
- i = 1
- while not ret:
- ret = (mailpasswd("prime") == "prime")
- if i > 2:
- from offlineimap.ui import getglobalui
- sys.stderr.write("Error reading in passwords. Terminating.\n")
- getglobalui().terminate()
- i += 1
- return ret
-
-prime_gpg_agent()
-