I am looking for a possibility to do something like this:
import paramiko, Pyro4
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect('machine1', username='user1')
stdin,stdout,stderr = ssh.exec_command("python server.py")
uri = stdout.readlines()[-1]
ssh.close()
worker = Pyro4.Proxy(uri)
worker.do_some_stuff()
# server.py
import Pyro4
class Worker(object):
def do_some_stuff():
....
worker = Worker()
daemon=Pyro4.Daemon()
uri=daemon.register(worker)
daemon.requestLoop()
print uri
So i want to log into a machine start a PyroServer / Daemon and return the uri over ssh. After this step i want to execute a function on the remote object. Unfortunately if I start a Pyroserver it doesn't run in the background so I don't get any return value from stdout. What would be the best way to do this ? I am pretty new to the pyro library so maybe there is some more elegant way to this, thank you.