The following are instructions for George to get started with encorporating credential retrieval from Password manager pro to support work on the SDE upgrade project.
I'm gonna provide you with two options for installing. The "right" way and the "cludgy" way.
python -m virtualenv ve_restol
ve_restol/Scripts/activate
pip install "git+https://github.com/bcgov/[email protected]#egg=PMP&subdirectory=PMP"
Instead of using virtualenv we are going to install the dependencies into as specific directory, then its up to you to make sure that your python interpreter knows to look in that directory for modules either by:
- creating a usercustomize.py file
- programatically adding the path to the pythonpath, sys.path to include the directory with the package
- create a PYTHONPATH env var that defines the path
cd <install dir>
python -m pip install -t <install dir> -e "git+https://github.com/bcgov/[email protected]#egg=PMP&subdirectory=PMP"
As mentioned above there are a bunch of different ways to do this. Going to show below how you can programatically do this. This is the ugyliest but also the most versatile.
import sys
sys.path = sys.path.append('<used above when you installed PMP>')
import PMP
We will provide you with the following information that you can add to the code:
- apikey / token
- url to pmp
- resource names to use.
# define a dictionary with the following info
pmpConfDict = {'token':'<the key that we will provide you>',
'baseurl': '<The url that we will provide you>',
'restdir': r'/restapi/json/v1/'}
# create a pmp object:
pmp = PMP.PMPRestConnect.PMP(pmpConfDict)
# get a password for a schema
schema = 'WHSE_HOCKEY'
rsrcNm = 'ETL_HOCKEY'
pswd = pmp.getAccountPassword(schema, rsrcNm)