@@ -58,7 +58,7 @@ def main():
5858 workbook_path = source_server .workbooks .download (all_workbooks [0 ].id , tmpdir )
5959
6060 # Step 4: Check if destination site exists, then sign in to the site
61- pagination_info , all_sites = source_server .sites .get ()
61+ all_sites , pagination_info = source_server .sites .get ()
6262 found_destination_site = any ((True for site in all_sites if
6363 args .destination_site .lower () == site .content_url .lower ()))
6464 if not found_destination_site :
@@ -71,21 +71,14 @@ def main():
7171 # because of the different auth token and site ID.
7272 with dest_server .auth .sign_in (tableau_auth ):
7373
74- # Step 5: Find destination site's default project
75- pagination_info , dest_projects = dest_server .projects .get ()
76- target_project = next ((project for project in dest_projects if project .is_default ()), None )
77-
78- # Step 6: If default project is found, form a new workbook item and publish.
79- if target_project is not None :
80- new_workbook = TSC .WorkbookItem (name = args .workbook_name , project_id = target_project .id )
81- new_workbook = dest_server .workbooks .publish (new_workbook , workbook_path ,
82- mode = TSC .Server .PublishMode .Overwrite )
83- print ("Successfully moved {0} ({1})" .format (new_workbook .name , new_workbook .id ))
84- else :
85- error = "The default project could not be found."
86- raise LookupError (error )
87-
88- # Step 7: Delete workbook from source site and delete temp directory
74+ # Step 5: Create a new workbook item and publish workbook. Note that
75+ # an empty project_id will publish to the 'Default' project.
76+ new_workbook = TSC .WorkbookItem (name = args .workbook_name , project_id = "" )
77+ new_workbook = dest_server .workbooks .publish (new_workbook , workbook_path ,
78+ mode = TSC .Server .PublishMode .Overwrite )
79+ print ("Successfully moved {0} ({1})" .format (new_workbook .name , new_workbook .id ))
80+
81+ # Step 6: Delete workbook from source site and delete temp directory
8982 source_server .workbooks .delete (all_workbooks [0 ].id )
9083
9184 finally :
0 commit comments