Beispiel #1
0
    contact        = settings.CONTACT_NAME,
    workbook_list  = ',</li><br><li>'.join(workbooks))

  sendEmail(settings.CONTACT_EMAIL, email, subj, body, isHTML=True)

################################################################################
# Downloading and deleting Reports
################################################################################
if not tabcmd_installed():
  print "tabcmd not found"
  exit()

for report in sorted(records, key = lambda rec: rec['url_namespace']):
  tableau_login(settings.TABADMIN_USER, settings.TABADMIN_PASSWORD,
    report['url_namespace'])
  path_concat(settings.ARCHIVE_LOCATION, url_to_file_name(report['workbook'],'twb'))

  get_cmd = [
      'tabcmd', 'get', '/workbooks/{0}.twb'.format(report['repository_url']),
      '-f',report_uri,
      '--timeout', '600']
  print "Executing: {0}".format(subprocess.list2cmdline(get_cmd))
  if tabcmd_installed(): subprocess.call(get_cmd)

  if os.path.exists(report_uri):
    delete_cmd = ['tabcmd', 'delete',
      '--workbook', report['workbook'],
      '--project', report['project'],
      '--timeout', '600']
    print "Executing: {0}".format(subprocess.list2cmdline(delete_cmd))
    if tabcmd_installed(): subprocess.call(delete_cmd)
################################################################
if not (args.skip_tabcmd):
    if site == 'default':
        subprocess.call([
            tabcmd, 'login', '-s', server, '-u', username, '-p', password,
            '--no-prompt', '--no-certcheck'
        ])
    else:
        subprocess.call([
            tabcmd, 'login', '-s', server, '-t', site, '-u', username, '-p',
            password, '--no-prompt', '--no-certcheck'
        ])

    for row in sub.sub_rows:
        absolute_save_path = path_concat(save_path,
                                         url_to_file_name(row.url()))
        if not (os.path.isfile(absolute_save_path)):
            subprocess.call([
                tabcmd, 'export',
                row.url(), '-f', absolute_save_path, '--png', '--pagesize',
                'unspecified', '--width', '1200', '--height', '800',
                '--timeout', '300', '--no-certcheck'
            ])
        row.saved_path = absolute_save_path
# ################################################################

#Sending Emails
################################################################
if SMTP_SSL:
    smtp_conn = smtplib.SMTP_SSL(smtp_server, smtp_server_port)
    smtp_conn.login(SMTP_USERNAME, SMTP_PASSWORD)
    take_top = args.take_top
else:
    take_top = 99999
sub = Subscription(csvpath, take_top)


# Actually creating the files
################################################################
if not(args.skip_tabcmd):
    if site == 'default':
        subprocess.call([tabcmd, 'login', '-s', server, '-u', username, '-p', password, '--no-prompt', '--no-certcheck'])
    else:
        subprocess.call([tabcmd, 'login', '-s', server,'-t', site, '-u', username, '-p', password, '--no-prompt', '--no-certcheck'])

    for row in sub.sub_rows:
        absolute_save_path = path_concat(save_path, url_to_file_name(row.url()))
        if not(os.path.isfile(absolute_save_path)):
            res = 1
            while res == 1:
                res = subprocess.call([tabcmd, 'export', row.url(), '-f', absolute_save_path, '--png', '--pagesize', 'unspecified', '--width', '1200', '--height', '800', '--timeout', '300', '--no-certcheck'])

        row.saved_path = absolute_save_path
# ################################################################

#Sending Emails
################################################################
if not (args.skip_email):
    if SMTP_SSL:
        smtp_conn = smtplib.SMTP_SSL(smtp_server, smtp_server_port)
        smtp_conn.login(SMTP_USERNAME, SMTP_PASSWORD)
    else:
	take_top = args.take_top
else:
	take_top = 99999
sub = Subscription(csvpath, take_top)


#Actually creating the files
################################################################
if not(args.skip_tabcmd):
	if site == 'default':
		subprocess.call([tabcmd, 'login', '-s', server, '-u', username, '-p', password, '--no-prompt'])
	else:
		subprocess.call([tabcmd, 'login', '-s', server,'-t', site, '-u', username, '-p', password, '--no-prompt'])

	for row in sub.sub_rows:
		absolute_save_path = path_concat(save_path, url_to_file_name(row.url()))
		if not(os.path.isfile(absolute_save_path)):
			subprocess.call([tabcmd, 'export', row.url(), '-f', absolute_save_path, '--png', '--pagesize', 'unspecified', '--timeout', '300'])
		row.saved_path = absolute_save_path		
# ################################################################

#Sending Emails
################################################################
if SMTP_SSL:
	smtp_conn = smtplib.SMTP_SSL(smtp_server, smtp_server_port)
	smtp_conn.login(SMTP_USERNAME, SMTP_PASSWORD)
else:
	smtp_conn = smtplib.SMTP(smtp_server, smtp_server_port)

for email in sub.unique_emails():
	#Overrides
        contact=settings.CONTACT_NAME,
        workbook_list=",</li><br><li>".join(workbooks),
    )

    sendEmail(settings.CONTACT_EMAIL, email, subj, body, isHTML=True)

################################################################################
# Downloading and deleting Reports
################################################################################
if not tabcmd_installed():
    print "tabcmd not found"
    exit()

for report in sorted(records, key=lambda rec: rec["url_namespace"]):
    tableau_login(settings.TABADMIN_USER, settings.TABADMIN_PASSWORD, report["url_namespace"])
    path_concat(settings.ARCHIVE_LOCATION, url_to_file_name(report["workbook"], "twb"))

    get_cmd = [
        "tabcmd",
        "get",
        "/workbooks/{0}.twb".format(report["repository_url"]),
        "-f",
        report_uri,
        "--timeout",
        "600",
    ]
    print "Executing: {0}".format(subprocess.list2cmdline(get_cmd))
    if tabcmd_installed():
        subprocess.call(get_cmd)

    if os.path.exists(report_uri):