Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You can't avoid serialization if there is no shared memory. There are only bytes on the wire. You could use a library that hides it from you e.g., with <a href="http://codespeak.net/execnet/" rel="nofollow"><code>execnet</code></a> module:</p> <pre><code>#!/usr/bin/env python import execnet gw = execnet.makegateway("ssh=user@host") channel = gw.remote_exec(""" import dbus, sys bus = dbus.SystemBus() remote_object = bus.get_object('daemon.location', '/daemon') controller = dbus.Interface(remote_object, 'daemon.path') channel.send(controller.getValue()) """) tuple_ = channel.receive() print tuple_ print tuple_[0] </code></pre> <p>But it easy to parse simple tuple values yourself using <a href="http://docs.python.org/dev/library/ast#ast.literal_eval" rel="nofollow"><code>ast.literal_eval()</code></a> from stdlib:</p> <pre><code>#fabfile.py import ast from fabric.api import run def getcontroller(): """Return controller value.""" cmd = """ import dbus, sys bus = dbus.SystemBus() remote_object = bus.get_object('daemon.location', '/daemon') controller = dbus.Interface(remote_object, 'daemon.path') print repr(controller.getValue()) """ #NOTE: you must escape all quotation marks output = run('python -c "%s"' % cmd) tuple_ = ast.literal_eval(output) print tuple_[0] </code></pre> <p>Example: <code>$ fab getcontroller -H user@host</code></p> <p>Here I've used <a href="http://fabfile.org" rel="nofollow"><code>fabric</code></a> to run the command on remote host.</p> <p>You could use JSON as a serialization format if the other end doesn't produce Python literals:</p> <pre><code>&gt;&gt;&gt; import json &gt;&gt;&gt; t = (1, "a") &gt;&gt;&gt; json.dumps(t) '[1, "a"]' &gt;&gt;&gt; json.loads(_) [1, u'a'] &gt;&gt;&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload