-
Notifications
You must be signed in to change notification settings - Fork 66
/
delete_look.py
45 lines (31 loc) · 944 Bytes
/
delete_look.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
38
39
40
41
42
43
44
import sys
import os
import yaml ### install the pyyaml package
from lookerapi import LookerApi
from datetime import datetime
from pprint import pprint
### ------- HERE ARE PARAMETERS TO CONFIGURE -------
looks_to_delete = sys.argv[1]
host = 'localhost'
### ------- OPEN THE CONFIG FILE and INSTANTIATE API -------
f = open('config.yml')
params = yaml.load(f)
f.close()
my_host = params['hosts'][host]['host']
my_secret = params['hosts'][host]['secret']
my_token = params['hosts'][host]['token']
looker = LookerApi(host=my_host,
token=my_token,
secret = my_secret)
### ------- HANDLE ARGUMENT FILELIST OR SINGLE LOOK -------
if os.path.isfile(looks_to_delete):
filelist = open(looks_to_delete)
for i in filelist:
print "deleting lookid: " + i
data = looker.delete_look(i)
pprint(data)
else:
data = looker.delete_look(looks_to_delete)
pprint(data)
### ------- Done -------
print "Done"