Using XML-RPC with Python3 is really simple. Calling system.version on http://localhost/RCP2 is as simple as:

import xmlrpc.client

proxy = xmlrpc.client.ServerProxy("http://localhost/RPC2")

However, the default client is missing many features, like handling proxies. Using requests for the underlying connection allows for greater control of the http request.

The xmlrpc client allows to change the underlying transport class by a custom class. In order to use requests, we create a simple Transport class:

import requests
import xmlrpc.client

class RequestsTransport(xmlrpc.client.Transport):

    def request(self, host, handler, data, verbose=False):
        # set the headers, including the user-agent
        headers = {"User-Agent": "my-user-agent",
                   "Content-Type": "text/xml",
                   "Accept-Encoding": "gzip"}
        url = "https://%s%s" % (host, handler)
            response = None
            response =, data=data, headers=headers)
            return self.parse_response(response)
        except requests.RequestException as e:
            if response is None:
                raise xmlrpc.client.ProtocolError(url, 500, str(e), "")
                raise xmlrpc.client.ProtocolError(url, response.status_code,
                                                  str(e), response.headers)

    def parse_response(self, resp):
        Parse the xmlrpc response.
        p, u = self.getparser()
        return u.close()

To use this Transport class, we should use:

proxy = xmlrpc.client.ServerProxy(uri, transport=RequestsTransport())

We can now use requests to:

  • use proxies
  • skip ssl verification (on a development server) or adding the right certificate chain
  • set the headers
  • set the timeouts
  • ...

See the documentation or an example for more information.

A common mistake with jinja2

ven. 05 mai 2017 by Rémi Duraffort

Jinja2 is a powerful templating engine for Python.

Inside LAVA, we use Jinja2 to generate configuration files for every boards that we support.

The configuration is generated from a template that does inherit from a base template.

For instance, for a beaglebone-black called bbb-01, the template inheritance tree is the …

read more

Logging for ser2net

mer. 22 juin 2016 by Rémi Duraffort

Today, I was debugging an strange issue in LAVA while trying to boot a board.

I was under the impression that the board was not receiving all the u-boot commands that LAVA was sending.

The serial connection is accessible on the network by ser2net.

I discovered that ser2net can log …

read more