Skip to content

Commit 1b7c588

Browse files
committed
example script usability improvements
1 parent ca44330 commit 1b7c588

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

examples/09_custom_file_transfer_example.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@
2020
import sys
2121

2222
# Add the parent directory to the path so we can import the jupiterone client
23-
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
23+
try:
24+
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
25+
except NameError:
26+
# Handle case when __file__ is not available (e.g., when exec'd)
27+
sys.path.append('..')
2428

2529
from jupiterone.client import JupiterOneClient
2630

examples/J1QLdeferredResponse.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
# JupiterOne GraphQL API headers
1414
j1_graphql_headers = {
1515
'Content-Type': 'application/json',
16-
'Authorization': 'Bearer ' + token,
17-
'Jupiterone-Account': acct
16+
'Authorization': 'Bearer ' + (token or ''),
17+
'Jupiterone-Account': acct or ''
1818
}
1919

2020
gql_query = """

examples/bulk_upload.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
token = os.environ.get("JUPITERONE_TOKEN")
66
url = "https://graphql.us.jupiterone.io"
77

8+
# Check if credentials are available
9+
if not account or not token:
10+
print("Error: JUPITERONE_ACCOUNT and JUPITERONE_TOKEN environment variables must be set")
11+
print("This example script requires valid JupiterOne credentials to run")
12+
exit(1)
13+
814
j1 = JupiterOneClient(account=account, token=token, url=url)
915

1016
instance_id = "<Integration Instance ID>"

examples/examples.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88
token = os.environ.get("JUPITERONE_TOKEN")
99
url = "https://graphql.us.jupiterone.io"
1010

11+
# Check if credentials are available
12+
if not account or not token:
13+
print("Error: JUPITERONE_ACCOUNT and JUPITERONE_TOKEN environment variables must be set")
14+
print("This example script requires valid JupiterOne credentials to run")
15+
exit(1)
16+
1117
j1 = JupiterOneClient(account=account, token=token, url=url)
1218

1319
# query_v1

0 commit comments

Comments
 (0)