forked from pinda/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
executable file
·23 lines (20 loc) · 895 Bytes
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#! /usr/bin/env python
import getpass, re, subprocess, os
from os.path import expanduser, join
def get_keychain_pass(account=None, server=None):
params = {
'security': '/usr/bin/security',
'command': 'find-internet-password',
'user': getpass.getuser(),
'account': account,
'server': server,
'keychain': join(expanduser('~'), 'library/Keychains/login.keychain'),
}
command = "sudo -u %(user)s %(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_client_secret(account):
return os.environ[account]
print get_client_secret("BLENDLE_OAUTH2_CLIENT_SECRET")