python-ox/ox/web/auth.py

22 lines
477 B
Python
Raw Normal View History

2010-07-07 23:25:57 +00:00
# -*- coding: utf-8 -*-
# vi:si:et:sw=4:sts=4:ts=4
# GPL 2009
import os
from ox.utils import json
2010-07-07 23:25:57 +00:00
def get(key):
user_auth = os.environ.get('oxAUTH', os.path.expanduser('~/.ox/auth.json'))
auth = {}
if os.path.exists(user_auth):
f = open(user_auth, "r")
data = f.read()
f.close()
auth = json.loads(data)
2010-07-07 23:25:57 +00:00
if key in auth:
return auth[key]
print "please add key %s to json file '%s'" % (key, user_auth)
return ""