]> git-server-git.apps.pok.os.sepia.ceph.com Git - remoto.git/commitdiff
update the docs
authorAlfredo Deza <alfredo@deza.pe>
Fri, 4 Oct 2013 17:01:22 +0000 (13:01 -0400)
committerAlfredo Deza <alfredo@deza.pe>
Fri, 4 Oct 2013 17:01:22 +0000 (13:01 -0400)
README.rst

index d51f969349967af6321e89520ee64f1e66fb64ac..2bba175c8fb30ebcb339b3d4f518f047073a11a4 100644 (file)
@@ -76,3 +76,44 @@ characters removed.
 
 This is useful if you need to process the information back locally, as opposed
 to just firing and forgetting (while logging, like ``process.run``).
+
+
+Remote Functions
+================
+
+To execute remote functions (ideally) you would need to define them in a module
+and add the following to the end of that module::
+
+    if __name__ == '__channelexec__':
+        for item in channel:
+            channel.send(eval(item))
+
+
+If you had a function in a module named ``foo`` that looks like this::
+
+    import os
+
+    def listdir(path):
+        return os.listdir(path)
+
+To be able to execute that ``listdir`` function remotely you would need to pass
+the module to the connection object and then call that function::
+
+    >>> import foo
+    >>> conn = Connection('hostname')
+    >>> remote_foo = conn.import_module(foo)
+    >>> remote_foo.listdir('.')
+    ['.bash_logout',
+     '.profile',
+     '.veewee_version',
+     '.lesshst',
+     'python',
+     '.vbox_version',
+     'ceph',
+     '.cache',
+     '.ssh']
+
+Note that functions to be executed remotely **cannot** accept objects as
+arguments, just normal Python data structures, like tuples, lists and
+dictionaries. Also safe to use are ints and strings.
+