def run_worker_installer()

in assets/scripts/SilentInstaller.py [0:0]


def run_worker_installer(options, secrets):
    ''' Runs the worker installer.exe, and checks for the exit code. Return the installer version. '''

    worker_setup_exit_codes = {
        1: 'Worker Setup: Setup failed to initialize.',
        30: 'Worker Setup: Node configuration file provided was invalid',
        40: 'Worker Setup: Admin username or password provided were invalid',
        }
    worker_log_file = tempfile.NamedTemporaryFile(prefix='TableauWorkerInstaller_', suffix='.log', delete=False);
    worker_log_file_full_path = worker_log_file.name
    worker_log_file.close()

    worker_installer_args = [
        '/VERYSILENT',          # No progress GUI, message boxes still possible
        '/SUPPRESSMSGBOXES',    # No message boxes. Only has an effect when combined with '/SILENT' or '/VERYSILENT'.
        '/ACCEPTEULA',
        '/LOG=' + worker_log_file_full_path,
        '/DIR=' + options.installDir,
        '/DATADIR=' + options.dataDir,
        '/BOOTSTRAPFILE=' + options.nodeConfigurationFile
    ]

    my_env = os.environ.copy()
    my_env['TableauAdminUser'] = secrets['local_admin_user'] if isinstance(secrets['local_admin_user'], str) else secrets['local_admin_user'].encode('utf-8')
    my_env['TableauAdminPassword'] = secrets['local_admin_pass'] if isinstance(secrets['local_admin_pass'], str) else secrets['local_admin_pass'].encode('utf-8')

    try:
        run_command(options.installer, worker_installer_args, environment=my_env, show_args=True)

    except ExitCodeError as ex:
        if(ex.exit_code == 1 or ex.exit_code == 30 or ex.exit_code == 40):
            print_error(worker_setup_exit_codes[ex.exit_code])
        else:
            print_error('Unknown exit code from the Worker Setup installer: %d' % ex.exit_code)

        # print the last 5 lines from the worker Setup log
        print_error_lines(worker_log_file_full_path)