Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17207 from ggovi/condcore-utilities-o2o-5-90X
Improvements for o2o tools
- Loading branch information
Showing
6 changed files
with
348 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,19 @@ | ||
import netrc | ||
import os | ||
|
||
netrcFileName = '.netrc' | ||
|
||
def get_credentials_from_file( service, authFile=None ): | ||
if not authFile is None: | ||
if os.path.isdir(authFile): | ||
authFile = os.path.join( authFile, netrcFileName ) | ||
creds = netrc.netrc( authFile ).authenticators(service) | ||
return creds | ||
|
||
def get_credentials( authPathEnvVar, service, authFile=None ): | ||
if authFile is None: | ||
if authPathEnvVar in os.environ: | ||
authPath = os.environ[authPathEnvVar] | ||
authFile = os.path.join(authPath,'.netrc') | ||
authFile = os.path.join(authPath, netrcFileName) | ||
return get_credentials_from_file( service, authFile ) | ||
|
Oops, something went wrong.