dotfiles

configuration files for shell, text editor, graphical environment, etc.
git clone git://src.adamsgaard.dk/dotfiles
Log | Files | Refs | README | LICENSE Back to index

commit b1916292b28fa7867b977ec732eeaf7e55fab036
parent 9d0f77759641d67894baccccddbf17429d9a5aec
Author: Anders Damsgaard <anders.damsgaard@geo.au.dk>
Date:   Mon,  7 Mar 2016 13:33:13 -0800

update script syntax

Diffstat:
M.mutt/offlineimap.py | 25++++++++++++-------------
1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/.mutt/offlineimap.py b/.mutt/offlineimap.py @@ -3,22 +3,21 @@ import re import subprocess import getpass import os +import sys user = getpass.getuser() home = os.getenv('HOME') -def get_keychain_pass(account=None, server=None): - params = { - 'security': '/usr/bin/security', - 'command': 'find-internet-password', - 'account': account, - 'server': server, - 'keychain': home + '/Library/Keychains/login.keychain', - } - command = "sudo -u " + user + " %(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) +def get_keychain_pass_osx(account=None, server=None): + if sys.platform == 'darwin': + command = 'sudo -u ' + user + \ + ' /usr/bin/security -v find-internet-password -g -a ' + account +\ + ' -s ' + server + ' ' + home + '/Library/Keychains/login.keychain' + 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)