def create_bar(): with sudo(user='******'), cd('/srv/'): if exists('/tmp/foo'): mkdir('/tmp/foo/bar') else: print('/tmp/foo does not exist') ls('tamer')
def configure_mod_tile(): with sudo(user='******'): mkdir('/srv/tilery/tmp/tiles') mkdir('/srv/tilery/renderd') with sudo(), cd('/etc/apache2/'): put('remote/tile.load', 'mods-available/tile.load') put('remote/tile.conf', 'mods-available/tile.conf') put('remote/apache.conf', 'sites-enabled/000-default.conf') put('remote/ports.conf', 'ports.conf') run('a2enmod tile')
def configure_munin(): psql_plugins = [ 'postgres_autovacuum', 'postgres_bgwriter', 'postgres_checkpoints', 'postgres_connections_db', 'postgres_users', 'postgres_xlog', 'nginx_status', 'nginx_request'] with sudo(), cd('/etc/munin'): put('remote/munin.conf', 'munin.conf') for plugin in Path('remote/munin').glob('*'): put(plugin, f'plugins/{plugin.name}') run(f'chmod +x plugins/{plugin.name}') for name in psql_plugins: run(f'ln --symbolic --force /usr/share/munin/plugins/{name} ' f'plugins/{name}') run('ln --symbolic --force /usr/share/munin/plugins/postgres_size_ ' 'plugins/postgres_size_tilery') restart(services='munin-node')
def test_cd(): with cd('/tmp'): res = run('pwd') assert res.stdout == '/tmp\r\n'
def test_get_with_cd(remotefile): with cd('/tmp'): data = BytesIO() get('usinetestget', data) assert data.read().decode() == 'foobarééœ'
def test_put_with_cd(connection): remote = 'usinetestput' with cd('/tmp'): put(str(Path(__file__).parent / 'test.txt'), remote) assert run(f'cat {remote}').stdout == 'foobarώ\r\n' run(f'rm {remote}')