from telepythy import Remote h = Remote('localhost') def getfile(filename="/etc/hosts"): return open(filename).read() try: print(h.run(getfile)) h.close() except Exception as e: print("Handled Exception...") print(e)
from telepythy import Remote def do_remote_thing(dir='/'): import os print "I am remote!" return os.listdir(dir) server = 'localhost' s = Remote(server) try: dir_list = s.run( do_remote_thing, dir="/usr" ) except Exception as e: print 'I even handle remote exceptions! %s'%e for dir in dir_list: print(dir)
from telepythy import Remote def do_remote_thing(dir='/'): import os print("I am remote!") return os.listdir(dir) s = Remote('localhost') try: dir_list = s.run( do_remote_thing, dir="/usr" ) except Exception as e: print('I even handle remote exceptions! %s'%e) for dir in dir_list: print(dir)
from telepythy import Remote h = Remote('localhost') def getfile(filename="/etc/hosts"): return open(filename).read() try: print h.run(getfile) h.close() except Exception as e: print "Handled Exception..." print e