@@ -40,7 +40,7 @@ def main():
40
40
enable_materialized_views = args .mode == "enable"
41
41
42
42
if (args .type is None ) != (args .mode is None ):
43
- print "Use '--type <content type> --mode <enable/disable>' to update materialized views settings."
43
+ print ( "Use '--type <content type> --mode <enable/disable>' to update materialized views settings." )
44
44
return
45
45
46
46
if args .type == 'site' :
@@ -61,10 +61,7 @@ def main():
61
61
62
62
def find_project_path (project , all_projects , path ):
63
63
path = project .name if len (path ) == 0 else project .name + '/' + path
64
- # if len(path) == 0:
65
- # path = project.name
66
- # else:
67
- # path = project.name + '/' + path
64
+
68
65
if project .parent_id is None :
69
66
return path
70
67
else :
@@ -83,7 +80,7 @@ def get_project_paths(server, projects):
83
80
84
81
def print_paths (paths ):
85
82
for path in paths .keys ():
86
- print path
83
+ print ( path )
87
84
88
85
89
86
def show_materialized_views_status (args , password , site_content_url ):
@@ -93,26 +90,26 @@ def show_materialized_views_status(args, password, site_content_url):
93
90
with server .auth .sign_in (tableau_auth ):
94
91
# For server admin, this will prints all the materialized views enabled sites
95
92
# For other users, this only prints the status of the site they belong to
96
- print "Materialized views is enabled on sites:"
93
+ print ( "Materialized views is enabled on sites:" )
97
94
for site in TSC .Pager (server .sites ):
98
95
if site .materialized_views_enabled :
99
96
enabled_sites .add (site )
100
- print "Site name:" , site .name
101
- print '\n '
97
+ print ( "Site name: {}" . format ( site .name ))
98
+ print ( '\n ' )
102
99
103
- print "Materialized views is enabled on workbooks:"
100
+ print ( "Materialized views is enabled on workbooks:" )
104
101
# Individual workbooks can be enabled only when the sites they belong to are enabled too
105
102
for site in enabled_sites :
106
103
site_auth = TSC .TableauAuth (args .username , password , site .content_url )
107
104
with server .auth .sign_in (site_auth ):
108
105
for workbook in TSC .Pager (server .workbooks ):
109
106
if workbook .materialized_views_enabled :
110
- print "Workbook:" , workbook . name , " from site:" , site .name
107
+ print ( "Workbook: {} from site: {}" . format ( workbook . name , site .name ))
111
108
112
109
113
110
def update_project_by_path (args , enable_materialized_views , password , site_content_url ):
114
111
if args .project_path is None :
115
- print "Use --project_path <project path> to specify the path of the project"
112
+ print ( "Use --project_path <project path> to specify the path of the project" )
116
113
return
117
114
tableau_auth = TSC .TableauAuth (args .username , password , site_content_url )
118
115
server = TSC .Server (args .server , use_server_version = True )
@@ -129,7 +126,7 @@ def update_project_by_path(args, enable_materialized_views, password, site_conte
129
126
130
127
def update_project_by_name (args , enable_materialized_views , password , site_content_url ):
131
128
if args .project_name is None :
132
- print "Use --project-name <project name> to specify the name of the project"
129
+ print ( "Use --project-name <project name> to specify the name of the project" )
133
130
return
134
131
tableau_auth = TSC .TableauAuth (args .username , password , site_content_url )
135
132
server = TSC .Server (args .server , use_server_version = True )
@@ -139,10 +136,10 @@ def update_project_by_name(args, enable_materialized_views, password, site_conte
139
136
140
137
if len (projects ) > 1 :
141
138
possible_paths = get_project_paths (server , projects )
142
- print "Project name is not unique, use '--project_path <path>'"
143
- print "Possible project paths:"
139
+ print ( "Project name is not unique, use '--project_path <path>'" )
140
+ print ( "Possible project paths:" )
144
141
print_paths (possible_paths )
145
- print '\n '
142
+ print ( '\n ' )
146
143
return
147
144
else :
148
145
update_project (projects [0 ], server , enable_materialized_views )
@@ -153,8 +150,9 @@ def update_project(project, server, enable_materialized_views):
153
150
if workbook .project_id == project .id :
154
151
workbook .materialized_views_enabled = enable_materialized_views
155
152
server .workbooks .update (workbook )
156
- print "Updated materialized views settings for project:" , project .name
157
- print '\n '
153
+
154
+ print ("Updated materialized views settings for project: {}" .format (project .name ))
155
+ print ('\n ' )
158
156
159
157
160
158
def parse_workbook_path (file_path ):
@@ -168,11 +166,8 @@ def parse_workbook_path(file_path):
168
166
169
167
def update_workbook (args , enable_materialized_views , password , site_content_url ):
170
168
if args .file_path is None :
171
- print "Use '--file-path <file path>' to specify the path of a list of workbooks"
172
- print "In the file, each line is a path to a workbook, for example:"
173
- print "project1/project2/workbook_name_1"
174
- print "project3/workbook_name_2"
175
- print '\n '
169
+ print ("Use '--file-path <file path>' to specify the path of a list of workbooks" )
170
+ print ('\n ' )
176
171
return
177
172
178
173
tableau_auth = TSC .TableauAuth (args .username , password , site_id = site_content_url )
@@ -193,15 +188,15 @@ def update_workbooks_by_paths(all_projects, enable_materialized_views, server, w
193
188
if len (workbooks ) == 1 :
194
189
workbooks [0 ].materialized_views_enabled = enable_materialized_views
195
190
server .workbooks .update (workbooks [0 ])
196
- print "Updated materialized views settings for workbook:" , workbooks [0 ].name
191
+ print ( "Updated materialized views settings for workbook: {}" . format ( workbooks [0 ].name ))
197
192
else :
198
193
for workbook in workbooks :
199
194
path = find_project_path (all_projects [workbook .project_id ], all_projects , "" )
200
195
if path in workbook_paths :
201
196
workbook .materialized_views_enabled = enable_materialized_views
202
197
server .workbooks .update (workbook )
203
- print "Updated materialized views settings for workbook:" , path + '/' + workbook .name
204
- print '\n '
198
+ print ( "Updated materialized views settings for workbook: {}" . format ( path + '/' + workbook .name ))
199
+ print ( '\n ' )
205
200
206
201
207
202
def update_site (args , enable_materialized_views , password , site_content_url ):
@@ -212,8 +207,8 @@ def update_site(args, enable_materialized_views, password, site_content_url):
212
207
site_to_update .materialized_views_enabled = enable_materialized_views
213
208
214
209
server .sites .update (site_to_update )
215
- print "Updated materialized views settings for site:" , site_to_update .name
216
- print '\n '
210
+ print ( "Updated materialized views settings for site: {}" . format ( site_to_update .name ))
211
+ print ( '\n ' )
217
212
218
213
219
214
if __name__ == "__main__" :
0 commit comments