mirror of
https://github.com/wassname/IndicoIo-python.git
synced 2026-08-05 12:40:14 +08:00
Require api keys
This commit is contained in:
+12
-10
@@ -16,7 +16,7 @@ class Settings(ConfigParser.ConfigParser):
|
||||
for fd in self.files:
|
||||
try:
|
||||
self.readfp(fd)
|
||||
except AttributeError:
|
||||
except AttributeError:
|
||||
self.read(fd)
|
||||
|
||||
self.auth_settings = self.get_section('auth')
|
||||
@@ -33,22 +33,24 @@ class Settings(ConfigParser.ConfigParser):
|
||||
|
||||
def cloud(self):
|
||||
return (
|
||||
os.getenv("INDICO_CLOUD") or
|
||||
self.private_cloud_settings.get('cloud') or
|
||||
os.getenv("INDICO_CLOUD") or
|
||||
self.private_cloud_settings.get('cloud') or
|
||||
None
|
||||
)
|
||||
|
||||
def auth(self):
|
||||
def api_key(self):
|
||||
return (
|
||||
os.getenv("INDICO_USERNAME") or self.auth_settings.get('username'),
|
||||
os.getenv("INDICO_PASSWORD") or self.auth_settings.get('password')
|
||||
os.getenv("INDICO_API_KEY") or
|
||||
self.auth_settings.get('api_key') or
|
||||
None
|
||||
)
|
||||
|
||||
|
||||
SETTINGS = Settings(files=[
|
||||
os.path.expanduser("~/.indicorc"),
|
||||
os.path.join(os.getcwd(), '.indicorc')
|
||||
])
|
||||
|
||||
AUTH = SETTINGS.auth()
|
||||
CLOUD = SETTINGS.cloud()
|
||||
PUBLIC_API_HOST = 'apiv1.indico.io'
|
||||
api_key = SETTINGS.api_key()
|
||||
cloud = SETTINGS.cloud()
|
||||
PUBLIC_API_HOST = 'apiv2.indico.io'
|
||||
url_protocol = "https:"
|
||||
|
||||
Reference in New Issue
Block a user