mutt/offlineimap.py @ dbcbfa37f036

Update mutt/offlineimap.py

replaced sjl username with `whoami` for general purpose user detection
author fpischedda <francesco.pischedda@gmail.com>
date Tue, 02 Oct 2012 12:47:37 +0300
parents c6446e280dab
children (none)
#!/usr/bin/python
import re, subprocess
def get_keychain_pass(account=None, server=None):
    params = {
        'security': '/usr/bin/security',
        'command': 'find-internet-password',
        'account': account,
        'server': server,
        'keychain': '/Users/`whoami`/Library/Keychains/login.keychain',
    }
    command = "sudo -u `whoami` %(security)s -v %(command)s -g -a %(account)s -s %(server)s %(keychain)s" % params
    output = subprocess.check_output(command, shell=True, stderr=subprocess.STDOUT)
    outtext = [l for l in output.splitlines()
               if l.startswith('password: ')][0]

    return re.match(r'password: "(.*)"', outtext).group(1)