4
4
# By default, all content is published to the Default project on the Default site.
5
5
####
6
6
7
- import tableauserverclient as TSC
8
7
import argparse
9
8
import getpass
10
- import logging
11
9
import glob
10
+ import logging
11
+ import tableauserverclient as TSC
12
+
12
13
13
14
14
15
def main ():
15
16
parser = argparse .ArgumentParser (description = 'Initialize a server with content.' )
16
17
parser .add_argument ('--server' , '-s' , required = True , help = 'server address' )
17
18
parser .add_argument ('--datasources-folder' , '-df' , required = True , help = 'folder containing datasources' )
18
19
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' )
20
21
parser .add_argument ('--project' , '-p' , required = False , default = 'Default' , help = 'project to use' )
21
22
parser .add_argument ('--username' , '-u' , required = True , help = 'username to sign into server' )
22
23
parser .add_argument ('--logging-level' , '-l' , choices = ['debug' , 'info' , 'error' ], default = 'error' ,
@@ -42,32 +43,34 @@ def main():
42
43
################################################################################
43
44
print ("Checking to see if we need to create the site..." )
44
45
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 )
47
48
48
49
# Create the site if it doesn't exist
49
50
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 (" " , "" ),
52
53
admin_mode = TSC .SiteItem .AdminMode .ContentAndUsers )
53
54
server .sites .create (new_site )
54
55
else :
55
- print ("Site {0} exists. Moving on..." ).format (args .site )
56
+ print ("Site {0} exists. Moving on..." ).format (args .site_id )
56
57
57
58
################################################################################
58
59
# Step 3: Sign-in to our target site
59
60
################################################################################
60
61
print ("Starting our content upload..." )
61
62
server_upload = TSC .Server (args .server )
62
- tableau_auth .site = args .site
63
+
64
+ tableau_auth .site_id = args .site_id
63
65
64
66
with server_upload .auth .sign_in (tableau_auth ):
65
67
66
68
################################################################################
67
69
# Step 4: Create the project we need only if it doesn't exist
68
70
################################################################################
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 )
71
74
72
75
# Create our project if it doesn't exist
73
76
if project is None :
0 commit comments