Tableau workbook not displaying tabs from source file when migrated through Python Scipt -


as part of assignment, have been asked migrate tableau worksheet through python script. migration successful not tabs source file in output worksheet after migration. below images describe position....

screenshot 1:

enter image description here

screenshot 2:

enter image description here

'''  created on sep 12, 2016    @author: johnsoja  '''  import argparse  import utils  import os    dev_server="http://ftc-wberfapp202"  dev_user="sys_dev_erfadmin"  dev_pwd="xyz"    stg_server="https://ftc-wberfapp501"  stg_user="sys_dev_erfadmin"  stg_pwd="xyz"    prod_server="https://ptc-wberfapp101"  prod_user="sys_pr_erf_admin"  prod_pwd="xyz"    scriptdir = "e:\\program files\\tableau\\tableau server\\10.1\\bin\\";  tabcmdlogincmd = "tabcmd login -s {0} -t {1} -u {2} -p {3} --cookie";  downloadfilecmd = "tabcmd \"{0}\" -f \"{1}\" ";  publishfilecmd ="tabcmd publish \"{0}\"  -r \"{1}\" --overwrite ";  tabcmdlogoutcmd = "tabcmd logout";  tmpfilelocation = "e:\\tableau_deployment_application_svn\\approved\\";  tmpdatasourcelocation = "e:\\tableau_deployment_application_svn\\datasources\\";    '''  read config file data sources migrated.  '''  def readdatasourceconfig(configfilename):      print('reading config file name ({0})'.format(configfilename))      utils = utils.configutil()      datasources = utils.configsections(configfilename)      datasourcesdict = dict()      datasourcenames = []      datasource in datasources:          print("datasources migrate ({0})".format(datasource))          dictionary = utils.configsectionmap(configfilename, datasource)          datasourcesdict[datasource] = dictionary          datasourcenm, connectionnm = datasource.split(":")          datasourcenames.append(datasourcenm)      return datasourcesdict, datasourcenames  '''  read config file data sources migrated.  '''  def readworkbookconfig(configfilename):      print('reading config file name ({0})'.format(configfilename))      workbookprops = []      open(configfilename) file:          line in file:              line = line.strip()               workbookprops.append(line)      print(workbookprops)      return workbookprops                    def getworkbooksfromsourcesite(source_server,source_username,source_password,source_site,source_project,datasourcenames,workbookprops):      token, site_id, user_id = utils.restapiutils.sign_in(source_site,source_server,source_username,source_password)      workbooks = utils.restapiutils.query_workbooks(token, site_id, source_project);         datasources = utils.restapiutils.query_datasources(token, site_id)      return workbooks, datasources                def uploadworkbookstodestinationsite(dest_server,dest_username,dest_password,dest_site,dest_project,workbooks,datasources,datasourcenames,workbookprops,update_ds):      os.chdir(scriptdir)      print("********************")      print("logging tableau server")      tabcmdlogincmdfrmt = tabcmdlogincmd.format(dest_server,dest_site,dest_username,dest_password)      tabcmdlogincmdfrmt = tabcmdlogincmdfrmt+" --no-certcheck "      print(tabcmdlogincmdfrmt)      utils.commons.runcommand(tabcmdlogincmdfrmt)                   workbook in workbooks:          workbook_name=workbook.get("contenturl")          workbook_full_name=workbook.get("name")          if workbook_name in workbookprops:              workbookfile = "/workbooks/"+workbook_name+".twbx"              outputworkbookfile = tmpfilelocation+workbook_name+".twbx"              publishfilecmdfrmt=publishfilecmd.format(outputworkbookfile, dest_project,dest_username,dest_password)              print(publishfilecmdfrmt)              utils.commons.runcommand(publishfilecmdfrmt+" --no-certcheck ")      print("********************")      print("completed publishing workbooks")      utils.commons.runcommand(tabcmdlogoutcmd)      return workbooks, datasources    def stringcomp(str_1, str_0):      if(str_1 none):          str_1 = ""      if(str_0 none):          str_0 = ""      return str_1.lower() == str_0.lower()    def usage():      print('\n usage function: \n')      print('nonprod-staging-prod-loader -a -f <location of erf<stg/prod>migration.properties> -s <sitename> -p <projectname>')    if __name__ == '__main__':      pass        parser = argparse.argumentparser()      parser.add_argument('-a', '--all')      parser.add_argument('-f', '--filepath')      parser.add_argument('-s', '--sitename', required=true)      parser.add_argument('-d', '--destsitename', required=true)      parser.add_argument('-p', '--projectname', required=true)      parser.add_argument('-t', '--target', required=true)      parser.add_argument('-u', '--updatedatasource')      args = parser.parse_known_args()[0]            if(args.target=="prod"):          source_server = dev_server          source_username = dev_user          source_password = dev_pwd          source_site = args.sitename          source_project = args.projectname                dest_server = prod_server          dest_username = prod_user          dest_password = prod_pwd          dest_site = args.destsitename          dest_project = args.projectname          update_ds=args.updatedatasource          print("moving site {0} server {1} server {2}".format(source_site, stg_server, prod_server))          dest_ds_properties = "e:\\tableau_deployment_application_svn\\migrationconfigs\\ds.prod.properties";          dest_wkbk_properties = "e:\\tableau_deployment_application_svn\\migrationconfigs\\wkbk.properties";            if(args.target=="stg"):          source_server = dev_server          source_username = dev_user          source_password = dev_pwd          source_site = args.sitename          source_project = args.projectname                dest_server = stg_server          dest_username = stg_user          dest_password = stg_pwd          dest_site =  args.destsitename          dest_project = args.projectname          update_ds=args.updatedatasource          print("moving site {0} server {1} server {2}".format(dest_site, dev_server, stg_server))          dest_ds_properties = "e:\\tableau_deployment_application_svn\\migrationconfigs\\ds.prod.properties";          dest_wkbk_properties = "e:\\tableau_deployment_application_svn\\migrationconfigs\\wkbk.properties";        datasourceprops, datasourcenames = readdatasourceconfig(dest_ds_properties);      ##print("data source names properties")      ##print(datasourcenames)      workbookprops = readworkbookconfig(dest_wkbk_properties);              workbooks, datasources = getworkbooksfromsourcesite(source_server,source_username,source_password,source_site,source_project,datasourcenames,workbookprops)            workbooks, datasources = uploadworkbookstodestinationsite(dest_server,dest_username,dest_password,dest_site,dest_project,workbooks,datasources,datasourcenames,workbookprops,update_ds)                  print("completed migration!!!!")   

this happening because have not specified --tabbed option in tabcmd publish command. change line of code:

publishfilecmd ="tabcmd publish \"{0}\"  -r \"{1}\" --overwrite "; 

to

publishfilecmd ="tabcmd publish \"{0}\"  -r \"{1}\" --overwrite --tabbed"; 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -