コード例 #1
0
ファイル: runner.py プロジェクト: behara/AquaIntegration
def run_script(script, remote=True):
    ''' Run a script. '''
    custom_scripts = _get_config()['scripts']

    # If the script is not defined raise error.
    if not is_script_defined(script):
        raise RuntimeError('Missing script "{}"'.format(script))

    needs_notification = should_notify(script)

    if needs_notification:
        notif.send(RUNNING_SCRIPT_STARTED, {
            'script': script,
            'user': shell.get_user(),
            'stage': shell.get_stage()
        })

        # Get the command defined in the script.
    script_cmd = custom_scripts[script]

    info_text = 'Running {}\n{}'.format(
        cyan(script), cyan('> ' + script_cmd)
    )
    host_info(info_text, remote=remote)

    # Run a custom script defined in the config.
    with hide('running'):
        run(script_cmd, remote)

    if needs_notification:
        notif.send(RUNNING_SCRIPT_FINISHED, {
            'script': script,
            'user': shell.get_user(),
            'stage': shell.get_stage()
        })
コード例 #2
0
ファイル: buildman.py プロジェクト: samirpdl/boss
def setup_remote(quiet=True):
    ''' Setup remote environment before we can proceed with the deployment process. '''
    base_dir = get_deploy_dir()
    release_dir = get_release_dir()
    current_path = get_current_path()
    build_history_path = get_builds_file()
    preset = get_config()['deployment']['preset']
    did_setup = False
    stage = shell.get_stage()

    # If the release directory does not exist, create it.
    if not fs.exists(release_dir):
        remote_info('Setting up {} server for {} deployment'.format(
            stage, preset))
        remote_info('Creating the releases directory {}'.format(
            cyan(release_dir)))
        fs.mkdir(release_dir, nested=True)

        # Add build history file.
        remote_info('Creating new build meta file {}'.format(
            cyan(build_history_path)))
        save_history(merge(INITIAL_BUILD_HISTORY, {'preset': preset}))

        # Setup a default web page for web deployment.
        if preset == presets.WEB:
            setup_default_html(base_dir)

        did_setup = True

    if not did_setup and not quiet:
        remote_info('Remote already setup for deployment')

    return (release_dir, current_path)
コード例 #3
0
def sync(branch=None):
    ''' Sync the changes on the branch with the remote (origin). '''
    remote_info('Fetching the latest changes.')
    git.fetch()
    branch = branch or git.current_branch()
    remote_info('Checking out to {}.'.format(cyan(branch)))
    git.checkout(branch, True)
    remote_info('Synchronizing with the latest changes.')
    git.sync(branch)
コード例 #4
0
def default_status_message(status, **params):
    ''' Default status callback function for DirectoryUploader. '''
    message = green(DEFAULT_MESSAGES[status])
    blank = '\r' + (' ' * 50) + '\r'  # Blank padding to clear the output line
    result = blank + message

    if status == PREPARING:
        result = '\n' + result

    elif status == PREPARING_TO_UPLOAD:
        result = blank + '{} [{}]'.format(message,
                                          cyan(size_unit(params['total'])))

    elif status == UPLOADING:
        sent = params['sent']
        total = params['total']
        progress = (sent * 100.0 / total)
        result = blank + '{} [{}] - {:.2f}%'.format(
            message, cyan(size_unit(total)), progress)

    elif status == DONE:
        result += '\n\n'

    return result
コード例 #5
0
ファイル: buildman.py プロジェクト: samirpdl/boss
def setup_default_html(base_dir):
    ''' Setup default html web page on the remote host. '''
    current_path = base_dir + CURRENT_BUILD_LINK
    html_path = BASE_PATH + '/misc/default_html'
    remote_html_path = base_dir + DEFAULT_HTML_PATH

    remote_info('Setting up the default web page')
    fs.upload_dir(html_path, base_dir)

    # Point the current sym link to the default web page.
    fs.update_symlink(remote_html_path, current_path)

    remote_info('Remote is setup and is ready for deployment.')
    remote_print(('Deployed build will point to {0}.\n' +
                  'For serving the latest build, ' +
                  'please set your web server document root to {0}.').format(
                      cyan(current_path)))