• Stars
    star
    175
  • Rank 210,334 (Top 5 %)
  • Language
    Java
  • License
    MIT License
  • Created almost 11 years ago
  • Updated 10 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Java and .NET client interface for Pyro5 protocol

Pyrolite - Pyro5 client library for Java and .NET

saythanks Build Status Maven Central NuGet

Pyrolite is written by Irmen de Jong ([email protected]). This software is distributed under the terms written in the file LICENSE.

Introduction: Pyro

This library allows your Java or .NET program to interface very easily with a Python program, using the Pyro protocol to call methods on remote objects (see https://github.com/irmen/Pyro5).

Pyrolite only implements a part of the client side Pyro library, hence its name 'lite'... For the full Pyro experience (and the ability to host servers and expose these via Pyro) you have to run Pyro itself in Python. But if you don't need Pyro's full feature set, and don't require your Java/.NET code to host Pyro objects but rather only call them, Pyrolite could be a good choice to connect Java or .NET and Python!

Pyro4 ?

If you are still using Pyro4 and want to use Pyrolite with it, you should stick to an older version of this library (versions 4.xx). The current 5.xx version only supports Pyro5.

In Github, use the pyro4-legacy branch.

Installation and usage

Precompiled libraries are available:

Some Java example code:

import net.razorvine.pyro.*;

NameServerProxy ns = NameServerProxy.locateNS(null);
PyroProxy remoteobject = new PyroProxy(ns.lookup("Your.Pyro.Object"));
Object result = remoteobject.call("pythonmethod", 42, "hello", new int[]{1,2,3});
String message = (String)result;  // cast to the type that 'pythonmethod' returns
System.out.println("result message="+message);
remoteobject.close();
ns.close();

Some C# example code:

using Razorvine.Pyro;

using( NameServerProxy ns = NameServerProxy.locateNS(null) )
{
    // this uses the statically typed proxy class:
    using( PyroProxy something = new PyroProxy(ns.lookup("Your.Pyro.Object")) )
    {
        object result = something.call("pythonmethod", 42, "hello", new int[]{1,2,3});
        string message = (string)result;  // cast to the type that 'pythonmethod' returns
        Console.WriteLine("result message="+message);
        result = something.getattr("remote_attribute");
        Console.WriteLine("remote attribute="+result);
    }
    
    // but you can also use it as a dynamic!
    using( dynamic something = new PyroProxy(ns.lookup("Your.Pyro.Object")) )
    {
        object result = something.pythonmethod(42, "hello", new int[]{1,2,3});
        string message = (string)result;  // cast to the type that 'pythonmethod' returns
        Console.WriteLine("result message="+message);
        result = something.remote_attribute;
        Console.WriteLine("remote attribute="+result);
    }
}

More examples can be found in the examples directory. You could also study the unit tests.

"Where is Pickle?"

Until version 5.0, Pyrolite included a pickle protocol implementation that allowed your Java or .NET code to read and write Python pickle files (pickle is Python's serialization format). From 5.0 onwards, this is no longer included because Pyro5 no longer uses pickle.

If you still want to read or write pickled data, have a look at the now separate pickle library: https://github.com/irmen/pickle

Required dependency: Serpent serializer

The serializer used is 'serpent' (a special serilization protocol that I designed for the Pyro library) So this requires the Razorvine.Serpent assembly (.NET) or the net.razorvine serpent artifact (serpent.jar, Java) to be available.

Serpent is a separate project (als by me), you'll have to install this dependency yourself. You can find it at: https://github.com/irmen/Serpent Download instructions are there as well.

Dealing with exceptions

Pyrolite also maps Python exceptions that may occur in the remote object. It has a rather simplistic approach:

all exceptions, including the Pyro ones (Pyro4.errors.*), are converted to PyroException objects. PyroException is a normal Java or C# exception type, and it will be thrown as a normal exception in your program. The message string is taken from the original exception. The remote traceback string is available on the PyroException object in the _pyroTraceback field.

More Repositories

1

Pyro4

Pyro 4.x - Python remote objects
Python
712
star
2

Pyro5

Pyro 5 - Python remote objects
Python
285
star
3

synthesizer

python sample mixer and sequencer, waveform synthesizer, and sound playback engine
Python
179
star
4

pyminiaudio

python interface to the miniaudio audio playback, recording, decoding and conversion library
C
156
star
5

Tale

Interactive fiction (text adventure) and Mud framework
Python
139
star
6

prog8

high level programming language and compiler targeting 6502 machines such as the C-64 and CommanderX16
Kotlin
126
star
7

pyc64

Commodore-64 simulator in pure Python
Python
78
star
8

pickle

Java and .NET implementation of Python's pickle serialization protocol
C#
66
star
9

Serpent

serializer for literal Python expressions, also .NET and Java
Java
46
star
10

bouldercaves

Boulder Caves - a Boulder Dash (tm) clone in pure python (including level editor)
Python
33
star
11

64tass

64tass - cross assembler for 6502 etc. microprocessors - by soci/singular - [git clone from the original sourceforge repo]
C
26
star
12

binaryen-interfaces

non-C programming language interfaces to the Binaryen library
Kotlin
11
star
13

cx16shell

Command line shell for the Commander X16
Lua
10
star
14

ksim65

Kotlin 6502/65C02 microprocessor simulator
Assembly
8
star
15

cx16assem

File-based 65c02 assembler for Commander-X16
Lua
7
star
16

raycaster

Ray caster engine in Python and Kotlin/JVM
Kotlin
7
star
17

pylibxmplite

Python library that provides libxmp-lite mod file decoding
C
6
star
18

rocketsimulator

python rocket landing simulation game just using tkinter
Python
5
star
19

Pyro3

Pyro 3.x (old version - unmaintained - use Pyro4 instead)
Python
4
star
20

cx16imageviewer

multi file format (iff, pcx, bmp, koala) image viewer for Commander X16
Lua
3
star
21

text-elite

python and cleand up ansi-c versions of text elite
C
2
star
22

ksim68k

m68k cpu simulator
Python
2
star
23

Elite-ships

3d model viewer for Elite's space ships
Python
2
star
24

cx16rockrunner

RockRunner - a Boulderdash(tm) clone for the Commander X16
Lua
1
star
25

mazes

some experiments with generating and solving mazes
Python
1
star
26

cx16kernel

custom CommanderX16 kernel rom
Assembly
1
star
27

cx16chess

Chess game for the Commander X16
Lua
1
star