-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Python script to read production search index
- Loading branch information
1 parent
f16dd81
commit 62dd9ff
Showing
2 changed files
with
48 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"smtp_hostname": "email-smtp.us-east-1.amazonaws.com", | ||
"smtp_user": "AKIAYDM4GMMT2VHWEP6A", | ||
"smtp_pass": "BO/JNfw92A1e9YAGk10MSp1Q6Zs0WmBzWJbrHlSAYuSM", | ||
"API_CLIENT_ID": "4d5f8e8b-a61d-40d8-bb58-5a3f5d1d200a", | ||
"API_CLIENT_SECRET": "9ZPvyAWasU76P6nx8tGbcCToSS3z8MKrL+FEM/IcL4E=" | ||
} |
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,41 @@ | ||
import json | ||
import os | ||
import sys | ||
|
||
import globus_sdk | ||
|
||
if "API_CLIENT_ID" in os.environ: | ||
globus_secrets = { | ||
"API_CLIENT_ID": os.environ["API_CLIENT_ID"], | ||
"API_CLIENT_SECRET": os.environ["API_CLIENT_SECRET"], | ||
"smtp_hostname": os.environ["SMTP_HOSTNAME"], | ||
"smtp_user": os.environ["SMTP_USER"], | ||
"smtp_pass": os.environ["SMTP_PASS"] | ||
} | ||
else: | ||
if len(sys.argv) == 2: | ||
secret_file = f"./.mdfsecrets.{sys.argv[1]}" | ||
else: | ||
secret_file = "./.mdfsecrets" | ||
|
||
with open(secret_file, 'r') as f: | ||
globus_secrets = json.load(f) | ||
|
||
index = "1a57bbe5-5272-477f-9d31-343b8258b7a5" | ||
|
||
|
||
client = globus_sdk.ConfidentialAppAuthClient(globus_secrets['API_CLIENT_ID'], globus_secrets['API_CLIENT_SECRET']) | ||
cc_authorizer = globus_sdk.ClientCredentialsAuthorizer(client, globus_sdk.SearchClient.scopes.all) | ||
|
||
search_client = globus_sdk.SearchClient(authorizer=cc_authorizer) | ||
|
||
processed = 0 | ||
|
||
for page in search_client.paginated.search(index, "*"): | ||
for result in page.data["gmeta"]: | ||
print(f"{result['subject']}: {len(result['entries'])}") | ||
processed += 1 | ||
|
||
print(processed) | ||
if processed > 20: | ||
break |