Open rburghol opened 1 year ago
@rburghol What format is your "/var/www/python/auth.private" file in? So I can test it on my end :)
I suppose we could consider storing the auth info in a single location like "/var/www/auth/auth.private" since the same login info can be used for REST calls from both R and python (we'd probably need to store the file in a format (JSON?) that makes it easy to read the rest_uname
and rest_pw
to variables in both R and python environments)
@jdkleiner Just wanted to get this in writing -- the auth.private file used here is JSON, so, that makes it an ideal candidate moving forward for a cross-platform single file.
Excellent. FWIW I ran some tests using an auth.private file in the following format:
{
"auths": {
"rest_uname": "un_XXXX",
"rest_pw": "pwd_XXXX"
},
"src_json_node": "XXXX/d.dh/node/62"
}
Objectives:
hdf5
name? See #65hsp2 import_json [json file name]
src_json_node = '...d.dh/node/62' el_pid = 4723109 json_url = src_json_node + "/" + str(el_pid)
authentication using rest un and pw
jfile = open("/var/www/python/auth.private") jj = json.load(jfile) rest_uname = jj[0]['rest_uname'] rest_pass = jj[0]['rest_pw'] basic = HTTPBasicAuth(rest_uname, rest_pass )
Opening JSON file
jraw = requests.get(json_url, auth=basic) model_json = jraw.content.decode('utf-8')
returns JSON object as
a dictionary
model_data = json.loads(model_json) mlist = list(model_data)
now extract the model using the name
model_data= model_data[mlist[0]] for k in model_data.keys(): print(k)