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 #23 from decarlof/master
clean-up and module re-orgs
- Loading branch information
Showing
10 changed files
with
212 additions
and
197 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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import pathlib | ||
from requests.auth import HTTPBasicAuth | ||
|
||
from dmagic import log | ||
|
||
|
||
__author__ = "Francesco De Carlo" | ||
__copyright__ = "Copyright (c) 2015, UChicago Argonne, LLC." | ||
__docformat__ = 'restructuredtext en' | ||
__all__ = ['basic', | ||
'read_credentials', ] | ||
|
||
debug = False | ||
|
||
|
||
def basic(filename='.scheduling_credentials'): | ||
""" | ||
Get authorization using username and password contained in filename. | ||
""" | ||
credentials = read_credentials(pathlib.PurePath(pathlib.Path.home(), filename)) | ||
|
||
username = credentials[0][0] | ||
password = credentials[0][1] | ||
auth = HTTPBasicAuth(username, password) | ||
|
||
return auth | ||
|
||
|
||
def read_credentials(filename): | ||
""" | ||
Read username and password from filename. | ||
Must create filename in the user home directory with | separated values: user|pwd | ||
""" | ||
credentials = [] | ||
with open(filename, 'r') as file: | ||
for line in file: | ||
username, password = line.strip().split('|') | ||
credentials.append((username, password)) | ||
return credentials |
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
Oops, something went wrong.