This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Project URLs:

Description

The erlport Python library implements Erlang external term format and Erlang port protocol for easier integration of Python and Erlang.

The library exports the following classes and functions:

  • Port(packet=1, use_stdio=False, compressed=False) - class implementing port which connects with the corresponding Erlang port. See open_port/2 for description of packet and use_stdio arguments. compressed is the zlib compression level or True for the default of 6.
  • Protocol() - class which simplifies creation of request-response protocols.
  • Atom(str) - class which represents an Erlang atom.
  • String(unicode | list) - class representing an Erlang string. Must be used as a wrapper if Unicode string expected instead of a list.
  • BitBinary(str) - class representing an Erlang bitstring whose length in bits is not a multiple of 8.
  • decode(str) - function to convert binary data into a term.
  • encode(term, compressed=False) - function to convert a term into the external format. compressed is the zlib compression level or True for the default of 6.
  • IncompleteData - exception raised by decode() in case of incomplete input data.

Installation

Prerequisites:

  • Erlang >= R11B-4
  • Python >= 2.4

To install the library use easy_install from setuptools package like this:

$ easy_install erlport

Examples

See examples directory in the source distribution for additional examples.

For simple request-response protocol use Port and Protocol on the Python side like this:

from erlport import Port, Protocol

class HelloProtocol(Protocol):

    def handle_hello(self, name):
        return "Hello, %s" % name

if __name__ == "__main__":
    proto = HelloProtocol()
    proto.run(Port(use_stdio=True))

On the Erlang side function hello() can be called like this:

-module(hello).
-export([hello/1]).

hello(Name) ->
    Port = open_port({spawn, "python -u hello.py"}, [{packet, 1}, binary]),
    port_command(Port, term_to_binary({hello, Name})),
    receive
        {Port, {data, Data}} ->
            binary_to_term(Data)
    end.

Test it in the Erlang shell:

1> c(hello).
{ok,hello}
2> hello:hello("Bob").
"Hello, Bob"

Notes for Windows users

  • It seems Erlang’s open_port function ignores nouse_stdio option on Windows. So the Port class must be instantiated with use_stdio=True argument.
  • Python must be ran with -u option to open stdin/stdout in binary mode.

Feedback

Please report bugs, offer suggestions or feedback at:

Release History

Release History

0.6

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.5

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.4

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.3

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
erlport-0.6-py2.6.egg (15.5 kB) Copy SHA256 Checksum SHA256 2.6 Egg Apr 26, 2010
erlport-0.6.tar.gz (13.2 kB) Copy SHA256 Checksum SHA256 Source Apr 26, 2010

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting