Beispiel #1
0
def initialize():
    ''' Initialize the local project directory for boss. '''
    files_written = []
    fabfile = FABFILE_PATH
    config_file = DEFAULT_CONFIG_FILE

    # If config file doesn't exist create it.
    if not fs.exists(config_file):
        config_tmpl = fs.read(BASE_PATH + '/misc/boss.yml_template')
        config_tmpl = config_tmpl.format(
            project_name=DEFAULT_CONFIG['project_name'],
            user=DEFAULT_CONFIG['user'],
            deployment_preset=DEFAULT_CONFIG['deployment']['preset'],
            deployment_base_dir=DEFAULT_CONFIG['deployment']['base_dir']
        )
        fs.write(config_file, config_tmpl)
        files_written.append(config_file)

    # If fabfile doesn't exist create it.
    if not fs.exists(fabfile):
        fabfile_tmpl = fs.read(BASE_PATH + '/misc/fabfile.py_template')
        fs.write(fabfile, fabfile_tmpl)
        files_written.append(fabfile)

    return files_written
Beispiel #2
0
def setup_boss_home():
    '''
    Sets up boss home directory on the user's local machine.
    If the directory already exists, it's skipped.
    '''
    if not fs.exists(BOSS_HOME_PATH):
        mkdir(BOSS_HOME_PATH)

    if not fs.exists(BOSS_CACHE_PATH):
        mkdir(BOSS_CACHE_PATH)
Beispiel #3
0
def initialize_config(interactive):
    '''
    Initialize a new boss.yml file.
    If the file already exists return None, else return the file.
    '''
    config_file = DEFAULT_CONFIG_FILE

    # If config already exists, return None
    if fs.exists(config_file):
        return None

    config_tmpl = fs.read(BASE_PATH + '/misc/boss.yml_template')

    if not interactive:
        tmpl_params = {
            'project_name': DEFAULT_CONFIG['project_name'],
            'user': DEFAULT_CONFIG['user'],
            'ssh_port': DEFAULT_CONFIG['port'],
            'deployment_preset': DEFAULT_CONFIG['deployment']['preset'],
            'deployment_base_dir': DEFAULT_CONFIG['deployment']['base_dir']
        }
    else:
        tmpl_params = get_initial_config_params()

    fs.write(config_file, config_tmpl.format(**tmpl_params))

    return config_file
Beispiel #4
0
def initialize_fabfile():
    '''
    Initialize a new fabfile.
    If the file already exists return None, else return the file.
    '''
    fabfile = FABFILE_PATH

    if not fs.exists(fabfile):
        fabfile_tmpl = fs.read(BASE_PATH + '/misc/fabfile.py_template')
        fs.write(fabfile, fabfile_tmpl)

        return fabfile
def test_get(server):
    ''' Test get() transfers remote file to the local. '''
    for uid in server.users:
        target_dir = tempfile.mkdtemp()
        source_file = os.path.join(target_dir, 'foo_src')
        target_file = os.path.join(target_dir, 'foo_dest')

        fs.write(source_file, 'Test get operation')
        assert not fs.exists(target_file)

        with server.client(uid) as client:
            sftp = client.open_sftp()
            remote.get(
                sftp,
                remote_path=source_file,
                local_path=target_file
            )
            assert fs.read(target_file) == 'Test get operation'
Beispiel #6
0
def test_exists(result):
    ''' Test fs.exists() works. '''
    filename = 'somefile'
    fs.exists(filename)
    result.assert_called_with(filename)