Skip to content

Commit b722fe3

Browse files
authored
Python SDK: Some examples were ignoring profile (#81)
* Python SDK examples missing profile
1 parent 83fa0ab commit b722fe3

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

examples/get_engine.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222

2323
def run(engine: str, profile: str):
24-
cfg = config.read()
24+
cfg = config.read(profile=profile)
2525
ctx = api.Context(**cfg)
2626
rsp = api.get_engine(ctx, engine)
2727
print(json.dumps(rsp, indent=2))

examples/list_users.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,23 @@
1515
"""List all users."""
1616

1717
import json
18+
from argparse import ArgumentParser
1819
from urllib.request import HTTPError
1920
from railib import api, config, show
2021

2122

22-
def run():
23-
cfg = config.read()
23+
def run(profile: str):
24+
cfg = config.read(profile=profile)
2425
ctx = api.Context(**cfg)
2526
rsp = api.list_users(ctx)
2627
print(json.dumps(rsp, indent=2))
2728

2829

2930
if __name__ == "__main__":
31+
p = ArgumentParser()
32+
p.add_argument("-p", "--profile", type=str, help="profile name", default="default")
33+
args = p.parse_args()
3034
try:
31-
run()
35+
run(args.profile)
3236
except HTTPError as e:
3337
show.http_error(e)

0 commit comments

Comments
 (0)