Exemplo n.º 1
0
def connect_and_list(hostname, username):
    out = ''
    conn = Ssh(hostname, username=username)
    conn.push_file(os.path.abspath('remote_run.sh'), '/home/davidk/')
    # ec, out, err = conn.execute_wait("ls /tmp/remote_run.sh; bash /tmp/remote_run.sh")
    conn.close()
    return out
Exemplo n.º 2
0
def connect_and_list(hostname, username):
    conn = Ssh(hostname, username=username)
    ec, out, err = conn.execute_wait("echo $HOSTNAME")
    conn.close()
    return out
Exemplo n.º 3
0
def test_push(conn, fname="test001.txt"):

    with open(fname, 'w') as f:
        f.write("Hello from parsl.ssh testing\n")

    conn.push_file(fname, "/tmp")
    ec, out, err = conn.execute_wait("ls /tmp/{0}".format(fname))
    print(ec, out, err)


def test_pull(conn, fname="test001.txt"):

    local = "foo"
    conn.pull_file("/tmp/{0}".format(fname), local)

    with open("{0}/{1}".format(local, fname), 'r') as f:
        print(f.readlines())


if __name__ == "__main__":

    libsubmit.set_stream_logger()

    # This is for testing
    conn = Ssh("midway.rcc.uchicago.edu", username="******")

    test_push(conn)
    test_pull(conn)

    conn.close()