- Notifications
You must be signed in to change notification settings - Fork 196
/
Copy pathlooker.py
37 lines (26 loc) · 1015 Bytes
/
looker.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"""
Contains all of the Looker auth & SDK methods used in the app.
"""
importlooker_sdk
importbase64
# See the Python SDK README for complete instructions on initializing the Python SDK
# https://github.com/looker-open-source/sdk-codegen/tree/main/python
# Rename the looker.ini.sample file in the project root to looker.ini and fill it out
sdk=looker_sdk.init40("app/looker.ini")
# Or uncomment below to use environment variables instead, if you have set them.
# sdk = looker_sdk.init40('lookersdk-flask/looker.ini')
defget_my_user():
my_user=sdk.me()
returnmy_user
defget_looks():
response=sdk.all_looks()
returnresponse
defget_html_for_look(look_id):
response=sdk.run_look(look_id=look_id, result_format="html", apply_vis=True)
returnresponse
defget_image_for_look(look_id):
response=sdk.run_look(
look_id=look_id, result_format="png", image_width=300, image_height=300
)
image_string=base64.b64encode(response)
returnimage_string