CMS 3D CMS Logo

credentials.py
Go to the documentation of this file.
1 import netrc
2 import os
3 
4 netrcFileName = '.netrc'
5 defAuthPathEnvVar = 'HOME'
6 authPathEnvVar = 'COND_AUTH_PATH'
7 
8 
9 def get_credentials_from_file( service, authPath ):
10  authFile = netrcFileName
11  if not authPath is None:
12  authFile = os.path.join( authPath, authFile )
13  creds = netrc.netrc( authFile ).authenticators(service)
14  return creds
15 
16 def get_credentials( service, authPath=None ):
17  if authPath is None:
18  if authPathEnvVar in os.environ:
19  authPath = os.environ[authPathEnvVar]
20  else:
21  if defAuthPathEnvVar in os.environ:
22  authPath = os.environ[defAuthPathEnvVar]
23  else:
24  authPath = ''
25  return get_credentials_from_file( service, authPath )
26 
credentials.get_credentials
def get_credentials(service, authPath=None)
Definition: credentials.py:16
credentials.get_credentials_from_file
def get_credentials_from_file(service, authPath)
Definition: credentials.py:9