44# By default, all content is published to the Default project on the Default site.
55####
66
7- import tableauserverclient as TSC
87import argparse
98import getpass
10- import logging
119import glob
10+ import logging
11+ import tableauserverclient as TSC
12+
1213
1314
1415def main ():
1516 parser = argparse .ArgumentParser (description = 'Initialize a server with content.' )
1617 parser .add_argument ('--server' , '-s' , required = True , help = 'server address' )
1718 parser .add_argument ('--datasources-folder' , '-df' , required = True , help = 'folder containing datasources' )
1819 parser .add_argument ('--workbooks-folder' , '-wf' , required = True , help = 'folder containing workbooks' )
19- parser .add_argument ('--site' , '-si ' , required = False , default = 'Default ' , help = 'site to use' )
20+ parser .add_argument ('--site-id ' , '-sid ' , required = False , default = '' , help = 'site id of the site to use' )
2021 parser .add_argument ('--project' , '-p' , required = False , default = 'Default' , help = 'project to use' )
2122 parser .add_argument ('--username' , '-u' , required = True , help = 'username to sign into server' )
2223 parser .add_argument ('--logging-level' , '-l' , choices = ['debug' , 'info' , 'error' ], default = 'error' ,
@@ -42,32 +43,34 @@ def main():
4243 ################################################################################
4344 print ("Checking to see if we need to create the site..." )
4445
45- all_sites , _ = server .sites . get ( )
46- existing_site = next ((s for s in all_sites if s .name == args .site ), None )
46+ all_sites = TSC . Pager ( server .sites )
47+ existing_site = next ((s for s in all_sites if s .content_url == args .site_id ), None )
4748
4849 # Create the site if it doesn't exist
4950 if existing_site is None :
50- print ("Site not found: {0} Creating it..." ).format (args .site )
51- new_site = TSC .SiteItem (name = args .site , content_url = args .site .replace (" " , "" ),
51+ print ("Site not found: {0} Creating it..." ).format (args .site_id )
52+ new_site = TSC .SiteItem (name = args .site_id , content_url = args .site_id .replace (" " , "" ),
5253 admin_mode = TSC .SiteItem .AdminMode .ContentAndUsers )
5354 server .sites .create (new_site )
5455 else :
55- print ("Site {0} exists. Moving on..." ).format (args .site )
56+ print ("Site {0} exists. Moving on..." ).format (args .site_id )
5657
5758 ################################################################################
5859 # Step 3: Sign-in to our target site
5960 ################################################################################
6061 print ("Starting our content upload..." )
6162 server_upload = TSC .Server (args .server )
62- tableau_auth .site = args .site
63+
64+ tableau_auth .site_id = args .site_id
6365
6466 with server_upload .auth .sign_in (tableau_auth ):
6567
6668 ################################################################################
6769 # Step 4: Create the project we need only if it doesn't exist
6870 ################################################################################
69- all_projects , _ = server_upload .projects .get ()
70- project = next ((p for p in all_projects if p .name == args .project ), None )
71+ import time ; time .sleep (2 ) # sad panda...something about eventually consistent model
72+ all_projects = TSC .Pager (server_upload .projects )
73+ project = next ((p for p in all_projects if p .name .lower () == args .project .lower ()), None )
7174
7275 # Create our project if it doesn't exist
7376 if project is None :
0 commit comments