Welcome to remcall’s documentation!

remcall

https://img.shields.io/pypi/v/remcall.svg https://img.shields.io/travis/luphord/remcall.svg Documentation Status

remcall (short for remote method calls) is a protocol for inter process communication (IPC) between different programming languages using object proxying as its primary method for information exchange. Communication using remcall requires the upfront definition of a schema (comprised of record and enum types and more importantly interfaces with method signatures) which then depending on the programming language is compiled or interpreted. Both communication participants are then free to implement any or none of the interfaces and reference concrete objects to the other side which will be represented using proxy objects. There is a certain distinction between a server (waiting for connections, serving and entry point) and a client (initiating a connection, performing the first method call) in remcall, but the protocol allows for method calls and object proxying in both directions. Remcall employs a binary representation for both, its schema and its communication protocol. Communcation can be layered on top of any bidirectional streams supporting binary data such as TCP sockets, stdin/out, websockets.

Installation

Stable release

To install remcall, run this command in your terminal:

$ pip install remcall

This is the preferred method to install remcall, as it will always install the most recent stable release.

If you don’t have pip installed, this Python installation guide can guide you through the process.

From sources

The sources for remcall can be downloaded from the Github repo.

You can either clone the public repository:

$ git clone git://github.com/luphord/remcall

Or download the tarball:

$ curl  -OL https://github.com/luphord/remcall/tarball/master

Once you have a copy of the source, you can install it with:

$ python setup.py install

Usage

To use remcall in a project:

import remcall

remcall

remcall package

Subpackages

remcall.codec package
Submodules
remcall.codec.base module
remcall.codec.read module
class remcall.codec.read.ReaderBase(stream)[source]

Bases: object

read_constant(bytes_const: bytes)[source]
read_float32()[source]
read_float64()[source]
read_from_stream(bytes_count: int)[source]
read_int16()[source]
read_int32()[source]
read_int64()[source]
read_int8()[source]
read_name()[source]
read_signed_integer(nbytes: int)[source]
read_string()[source]
read_struct_format(fmt)[source]
read_type_ref()[source]
read_uint16()[source]
read_uint32()[source]
read_uint64()[source]
read_uint8()[source]
read_unsigned_integer(nbytes: int)[source]
class remcall.codec.read.SchemaReader(stream)[source]

Bases: remcall.codec.read.ReaderBase

read_enum()[source]
read_interface()[source]
read_method()[source]
read_record()[source]
read_schema()[source]
remcall.codec.read.read_schema(stream)[source]
remcall.codec.read.schema_from_bytes(byt: bytes)[source]
remcall.codec.write module
class remcall.codec.write.SchemaWriter(schema, stream)[source]

Bases: remcall.codec.write.WriterBase

write_enum(enum)[source]
write_interface(interface)[source]
write_method(method)[source]
write_name(s)[source]
write_record(record)[source]
write_schema()[source]
write_to_stream(data: bytes)[source]
class remcall.codec.write.WriterBase(schema, outstream)[source]

Bases: object

write_bytes(b)[source]
write_float32(f: float)[source]
write_float64(f: float)[source]
write_int16(i: int)[source]
write_int32(i: int)[source]
write_int64(i: int)[source]
write_int8(i: int)[source]
write_method_ref(method_idx)[source]
write_signed_integer(i: int, nbytes: int)[source]
write_string(s)[source]
write_to_stream(data: bytes)[source]
write_type_ref(typ: remcall.schema.core.Type)[source]
write_uint16(i: int)[source]
write_uint32(i: int)[source]
write_uint64(i: int)[source]
write_uint8(i: int)[source]
write_unsigned_integer(i: int, nbytes: int)[source]
remcall.codec.write.schema_to_bytes(schema)[source]
remcall.codec.write.write_schema(schema, stream)[source]
Module contents
remcall.communication package
Submodules
remcall.communication.base module
remcall.communication.bridge module
class remcall.communication.bridge.Bridge(schema, instream, outstream, main, enum_record_implementation: remcall.implementation.EnumRecordImplementation)[source]

Bases: object

acknowledge_disconnect()[source]
call_method(method, this, args_dict)[source]
disconnect()[source]
return_method(request_id: int, return_type: remcall.schema.core.Type, return_value)[source]
remcall.communication.proxy module
class remcall.communication.proxy.MethodProxy(interface, method, bridge, name_converter)[source]

Bases: object

class remcall.communication.proxy.ProxyFactory(schema, bridge, name_converter)[source]

Bases: object

class remcall.communication.proxy.ProxyType[source]

Bases: object

remcall.communication.proxy.create_proxy_class(interface, bridge, name_converter)[source]
remcall.communication.proxy.create_proxy_classes(schema, bridge)[source]
remcall.communication.proxy.create_proxy_classes_dict(schema, bridge, name_converter)[source]
remcall.communication.receive module
class remcall.communication.receive.Receiver(schema, instream, get_object, return_method_result, acknowledge_disconnect, name_converter)[source]

Bases: remcall.codec.read.ReaderBase

mainloop()[source]
process_method_call()[source]
process_method_return()[source]
process_next()[source]
read_enum_value(typ: remcall.schema.core.Type)[source]
read_from_stream(bytes_count: int)[source]
read_method_ref()[source]
read_object(typ: remcall.schema.core.Type)[source]
read_object_ref(typ: remcall.schema.core.Type)[source]
read_request_id()[source]
read_value(typ: remcall.schema.core.Type)[source]
receive_and_check_schema()[source]
wait_for_method_return(request_id, return_type)[source]
remcall.communication.send module
class remcall.communication.send.Sender(schema, outstream, get_id_for_object)[source]

Bases: remcall.codec.write.WriterBase

acknowledge_disconnect()[source]
call_method(method, this, args_dict)[source]
disconnect()[source]
noop()[source]
request_schema()[source]
return_method(request_id, return_type, return_value)[source]
send_schema()[source]
write_enum_value(enum_value)[source]
write_object_ref(obj)[source]
write_record_value(val)[source]
write_request_id(request_id=None)[source]
write_to_stream(data: bytes)[source]
write_value(typ, value)[source]
remcall.communication.store module
class remcall.communication.store.IdStore[source]

Bases: object

contains_object(obj)[source]
delete_object(obj)[source]
get_id_for_object(obj)[source]
class remcall.communication.store.ReferenceStore(is_client, proxy_factory)[source]

Bases: object

get_id_for_implementation_object(obj)[source]
get_id_for_object(obj)[source]
get_id_for_proxy_object(obj)[source]
get_implementation_object(key: int)[source]
get_object(key: int, typ: remcall.schema.core.Type)[source]
get_proxy_object(key: int, typ: remcall.schema.core.Type)[source]
next_object_id()[source]
object_id_sign
Module contents
remcall.schema package
Submodules
remcall.schema.base module
remcall.schema.base.assert_name(name: str)[source]
remcall.schema.core module
class remcall.schema.core.Type(name: str)[source]

Bases: object

is_declared
resolve_type_references(type_ref_lookup)[source]
sort_key
type_order = -1
class remcall.schema.core.Array(typ: remcall.schema.core.Type)[source]

Bases: remcall.schema.core.Type

type_order = 3
class remcall.schema.core.Primitive(name: str)[source]

Bases: remcall.schema.core.Type

class remcall.schema.core.Enum(name: str, values: Iterable[str])[source]

Bases: remcall.schema.core.Type

is_declared
pretty_print() → str[source]
type_order = 0
class remcall.schema.core.Record(name: str, fields: Iterable[Tuple[Union[remcall.schema.core.Type, remcall.schema.typeref.TypeRef], str]])[source]

Bases: remcall.schema.core.Type

is_declared
pretty_print() → str[source]
resolve_type_references(type_ref_lookup: Mapping[remcall.schema.typeref.TypeRef, remcall.schema.core.Type]) → None[source]
type_order = 1
class remcall.schema.core.Method(name: str, arguments: Iterable[Tuple[Union[remcall.schema.core.Type, remcall.schema.typeref.TypeRef], str]], return_type: remcall.schema.core.Type)[source]

Bases: object

class remcall.schema.core.Interface(name: str, methods: Iterable[remcall.schema.core.Method])[source]

Bases: remcall.schema.core.Type

is_declared
methods_sorted
pretty_print() → str[source]
resolve_type_references(type_ref_lookup: Mapping[remcall.schema.typeref.TypeRef, remcall.schema.core.Type]) → None[source]
type_order = 2
class remcall.schema.core.Schema(label, types, bytes_method_ref=2, bytes_object_ref=4, sha256_digest=None)[source]

Bases: object

declared_types
enums
enums_sorted
interfaces
interfaces_sorted
iter_declared_types
method_lookup
method_table
method_to_interface
pretty_print()[source]
records
records_sorted
type_schemas
type_table
remcall.schema.typeref module
class remcall.schema.typeref.TypeRef(type_ref: int)[source]

Bases: object

Represents temporary type references by an integer; to be resolved to actual types later

Module contents

Submodules

remcall.error module

exception remcall.error.DuplicateMethodReturnValue(request_id)[source]

Bases: remcall.error.RemcallError

exception remcall.error.DuplicateRegistrationForMethodReturn(request_id)[source]

Bases: remcall.error.RemcallError

exception remcall.error.MethodNotAvailable(method, impl_method_name, this)[source]

Bases: remcall.error.RemcallError

exception remcall.error.MissingMethodReturnValueEvent(request_id)[source]

Bases: remcall.error.RemcallError

exception remcall.error.RemcallError[source]

Bases: Exception

exception remcall.error.UnknownCommand(command)[source]

Bases: remcall.error.RemcallError

exception remcall.error.UnknownImplementationObjectReference(key)[source]

Bases: remcall.error.RemcallError

exception remcall.error.UnknownProxyObject(obj)[source]

Bases: remcall.error.RemcallError

exception remcall.error.UnknownType(typ)[source]

Bases: remcall.error.RemcallError

exception remcall.error.WrongNumberOfBytesRead(bytes_requested, bytes_read, offset)[source]

Bases: remcall.error.RemcallError

remcall.generate module

class remcall.generate.CSharphCodeGenerator(schema, namespace='Remcall.Generated', name_converter=<remcall.naming.CSharpNameConverter object>)[source]

Bases: object

dedent()[source]
indent()[source]
indent_chars = '\t'
linebreak()[source]
scalartypename(typ)[source]
type_names = {Primitive("void"): 'void', Primitive("boolean"): 'bool', Primitive("int8"): 'SByte', Primitive("uint8"): 'byte', Primitive("int16"): 'Int16', Primitive("uint16"): 'UInt16', Primitive("int32"): 'Int32', Primitive("uint32"): 'UInt32', Primitive("int64"): 'Int64', Primitive("uint64"): 'UInt64', Primitive("float32"): 'float', Primitive("float64"): 'double', Primitive("string"): 'string', Primitive("date"): 'DateTime', Primitive("time"): 'Time', Primitive("datetime"): 'DateTime'}
typename(typ)[source]
write_enum(enum)[source]
write_interface(interface)[source]
write_method(method)[source]
write_record(record)[source]
write_schema(fp)[source]
writeline(s)[source]

remcall.implementation module

class remcall.implementation.EnumRecordImplementation(schema, name_converter)[source]

Bases: object

class remcall.implementation.RecordType[source]

Bases: object

remcall.implementation.create_enum_implementation(enum, name_converter)[source]
remcall.implementation.create_record_implementation(record, name_converter)[source]

remcall.naming module

class remcall.naming.CSharpNameConverter[source]

Bases: remcall.naming.IdentityNameConverter

interface_name(name)[source]
parameter_name(name)[source]
class remcall.naming.IdentityNameConverter[source]

Bases: object

enum_field_name(name)[source]
enum_name(name)[source]
interface_name(name)[source]
method_name(name)[source]
parameter_name(name)[source]
record_field_name(name)[source]
record_name(name)[source]
type_name(typ: remcall.schema.core.Type)[source]
class remcall.naming.PythonNameConverter[source]

Bases: remcall.naming.IdentityNameConverter

enum_field_name(name)[source]
method_name(name)[source]
parameter_name(name)[source]
record_field_name(name)[source]
type_name(typ: remcall.schema.core.Type)[source]

remcall.util module

class remcall.util.QueueStream(name=None)[source]

Bases: object

flush()[source]
read(size: int)[source]
stream_counter = 0
write(data: bytes)[source]
class remcall.util.TypeWrapper(typ, name_converter)[source]

Bases: object

Wraps a core.Type and provides a nice annotation for Signature instances

remcall.util.view_hex(b: bytes)[source]

Module contents

Remcall (short for remote method calls) is a protocol for inter process communication (IPC) between different programming languages using object proxying as its primary method for information exchange. Communication using remcall requires the upfront definition of a schema (comprised of record and enum types and more importantly interfaces with method signatures) which then depending on the programming language is compiled or interpreted. Both communication participants are then free to implement any or none of the interfaces and reference concrete objects to the other side which will be represented using proxy objects. There is a certain distinction between a server (waiting for connections, serving and entry point) and a client (initiating a connection, performing the first method call) in remcall, but the protocol allows for method calls and object proxying in both directions. Remcall employs a binary representation for both, its schema and its communication protocol. Communcation can be layered on top of any bidirectional streams supporting binary data such as TCP sockets, stdin/out, websockets.

Contributing

Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.

You can contribute in many ways:

Types of Contributions

Report Bugs

Report bugs at https://github.com/luphord/remcall/issues.

If you are reporting a bug, please include:

  • Your operating system name and version.
  • Any details about your local setup that might be helpful in troubleshooting.
  • Detailed steps to reproduce the bug.

Fix Bugs

Look through the GitHub issues for bugs. Anything tagged with “bug” and “help wanted” is open to whoever wants to implement it.

Implement Features

Look through the GitHub issues for features. Anything tagged with “enhancement” and “help wanted” is open to whoever wants to implement it.

Write Documentation

remcall could always use more documentation, whether as part of the official remcall docs, in docstrings, or even on the web in blog posts, articles, and such.

Submit Feedback

The best way to send feedback is to file an issue at https://github.com/luphord/remcall/issues.

If you are proposing a feature:

  • Explain in detail how it would work.
  • Keep the scope as narrow as possible, to make it easier to implement.
  • Remember that this is a volunteer-driven project, and that contributions are welcome :)

Get Started!

Ready to contribute? Here’s how to set up remcall for local development.

  1. Fork the remcall repo on GitHub.

  2. Clone your fork locally:

    $ git clone git@github.com:your_name_here/remcall.git
    
  3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:

    $ mkvirtualenv remcall
    $ cd remcall/
    $ python setup.py develop
    
  4. Create a branch for local development:

    $ git checkout -b name-of-your-bugfix-or-feature
    

    Now you can make your changes locally.

  5. When you’re done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox:

    $ flake8 remcall tests
    $ python setup.py test or py.test
    $ tox
    

    To get flake8 and tox, just pip install them into your virtualenv.

  6. Commit your changes and push your branch to GitHub:

    $ git add .
    $ git commit -m "Your detailed description of your changes."
    $ git push origin name-of-your-bugfix-or-feature
    
  7. Submit a pull request through the GitHub website.

Pull Request Guidelines

Before you submit a pull request, check that it meets these guidelines:

  1. The pull request should include tests.
  2. If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in README.rst.
  3. The pull request should work for Python 2.7, 3.4, 3.5 and 3.6, and for PyPy. Check https://travis-ci.org/luphord/remcall/pull_requests and make sure that the tests pass for all supported Python versions.

Tips

To run a subset of tests:

$ python -m unittest tests.test_remcall

Deploying

A reminder for the maintainers on how to deploy. Make sure all your changes are committed (including an entry in HISTORY.rst). Then run:

$ bumpversion patch # possible: major / minor / patch
$ git push
$ git push --tags

Travis will then deploy to PyPI if tests pass.

Credits

Development Lead

Contributors

None yet. Why not be the first?

History

0.1.0 (not yet)

  • First release on PyPI.

Indices and tables