Example #1
0
def test_drop():
    with filetext('name,balance\nAlice,100\nBob,200', extension='csv') as fn:
        with tmpfile('csv') as target:
            scsv = SSH(CSV)(target, hostname='localhost')

            assert not os.path.exists(target)

            conn = sftp(**scsv.auth)
            conn.put(fn, target)

            assert os.path.exists(target)

            drop(scsv)
            drop(scsv)

            assert not os.path.exists(target)
Example #2
0
def test_drop():
    with filetext('name,balance\nAlice,100\nBob,200', extension='csv') as fn:
        with tmpfile('csv') as target:
            scsv = SSH(CSV)(target, hostname='localhost')

            assert not os.path.exists(target)

            conn = sftp(**scsv.auth)
            conn.put(fn, target)

            assert os.path.exists(target)

            drop(scsv)
            drop(scsv)

            assert not os.path.exists(target)
Example #3
0
def accounts_ssh():
    """ Three csv files on the remote host in a directory """
    dirname = str(uuid.uuid1())
    conn = sftp(**auth)
    conn.mkdir(dirname)
    with filetext(accounts_1_csv) as fn:
        conn.put(fn, dirname + '/accounts.1.csv')
    with filetext(accounts_2_csv) as fn:
        conn.put(fn, dirname + '/accounts.2.csv')
    with filetext(accounts_3_csv) as fn:
        conn.put(fn, dirname + '/accounts.3.csv')

    filenames = [dirname + '/accounts.%d.csv' % i for i in [1, 2, 3]]
    uris = ['ssh://ubuntu@%s:%s' % (host, fn) for fn in filenames]

    try:
        yield 'ssh://ubuntu@%s:%s/*.csv' % (host, dirname), uris
    finally:
        for fn in filenames:
            conn.remove(fn)
        conn.rmdir(dirname)
def accounts_ssh():
    """ Three csv files on the remote host in a directory """
    dirname = str(uuid.uuid1())
    conn = sftp(**auth)
    conn.mkdir(dirname)
    with filetext(accounts_1_csv) as fn:
        conn.put(fn, dirname + '/accounts.1.csv')
    with filetext(accounts_2_csv) as fn:
        conn.put(fn, dirname + '/accounts.2.csv')
    with filetext(accounts_3_csv) as fn:
        conn.put(fn, dirname + '/accounts.3.csv')

    filenames = [dirname + '/accounts.%d.csv' % i for i in [1, 2, 3]]
    uris = ['ssh://ubuntu@%s:%s' % (host, fn) for fn in filenames]

    try:
        yield 'ssh://ubuntu@%s:%s/*.csv' % (host, dirname),  uris
    finally:
        for fn in filenames:
            conn.remove(fn)
        conn.rmdir(dirname)