tozny/tozstore-cloud9-integration

Problem running working_script.py to download data

Opened this issue · 0 comments

I am facing some issues while running python scripts to download data to AWS and to my local machine. I was hoping if you could help me.
I can share my config.json, credentials.json, flyway.conf files if necessary.

AWS Problems:

Script 1: working-script.py (Sample script provided by the study. Only added record_type for SMS from 20200602-TA1-Smartphone_Sensor_Detail-2020.xlsx)

from e3db.types import Search

from compliance import get_most_recent_check
from client_creator import ClientSupport
import e3db

def run():

# DO NOT SHARE THIS WORKSPACE WITH OTHERS IF YOUR CONFIG IS PRESENT
# DO NOT ADD YOUR CONFIG INTO SOURCE CONTROL

support = ClientSupport.from_config(
    "/home/ec2-user/environment/tozstore-cloud9-integration/ta2resources/config.json")

# Construct search query here (The sample query retrieves all records your client can read with the replaced record type)
# For full examples on the search query see https://github.com/tozny/e3db-python
q = Search(count=50, include_data=True, include_all_writers=True).match(
    record_type=["a-kry-sensor-sms"])
#q = Search(count=50, include_data=True, include_all_writers=True).match(
#    record_type=["<Replace with a record type>"])

# The simplest approach is to use support.search_and_store(q)
support.search_and_store(q)

# If intermediary actions are needed on the records one can also do
# records = support.search(q)
# support.store(records)

if name == 'main':
# By removing the compliance check you may be violating the law.
get_most_recent_check()
run()

Command Used to run:
python3 working-script.py

Error:
Traceback (most recent call last):
File "working-script.py", line 34, in
run()
File "working-script.py", line 19, in run
record_type=["a-kry-sensor-sms"])
TypeError: match() got an unexpected keyword argument 'record_type'

Because of the error I changed the script (modified the query) a little based on the analyzer_samples.py

Script 2: sample_script.py (modified the query following analyzer_samples.py. See attached)
q = Search(include_data=True, include_all_writers=True, count=50).match(
condition="AND", plain={"type":"a-kry-sensor-sms"})

Run:
python3 sample_script.py

Error:
Fetching 0 records, with a total of None of data
Do you want to fetch files [Y/n]?
Y
Successfully fetched all records

Local Machine Problem:
As you can see, no records were returned which brought me to question if my credentials or configuration were corrupt or not.
So I ran analyzer-samples.py from local machine which gave me the following error:

Records not found. Ensure your client has been approved for access