net.razorvine.pyro.PyroException Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pyrolite Show documentation
Show all versions of pyrolite Show documentation
This library allows your Java program to interface very easily with the Python world. It uses the Pyro protocol to call methods on remote objects. (See https://pyro5.readthedocs.io/).
Pyrolite only implements part of the client side Pyro library, hence its name 'lite'... So if you don't need Pyro's full feature set, Pyrolite may be a good choice to connect java or .NET and python.
Version 5.0 changes: support Pyro5 wire protocol. Dropped support of Pyro4 (stick to version 4.xx for that).
package net.razorvine.pyro;
import java.util.HashMap;
import java.util.List;
/**
* Exception thrown when something is wrong in Pyro.
*
* @author Irmen de Jong ([email protected])
*/
public class PyroException extends RuntimeException {
private static final long serialVersionUID = 5164503665621511957L;
public String _pyroTraceback;
public PyroException(String message, Throwable cause) {
super(message, cause);
}
public PyroException(String message) {
super(message);
}
/**
* called by the Unpickler to restore state
*/
public void __setstate__(HashMap, ?> args) {
Object tb=args.get("_pyroTraceback");
// if the traceback is a list of strings, create one string from it
Class> componentType = tb.getClass().getComponentType();
if(componentType!=null) {
StringBuilder sb=new StringBuilder();
for(Object line: (Object[])tb) {
sb.append(line);
}
_pyroTraceback=sb.toString();
}
else if(tb instanceof List) {
StringBuilder sb=new StringBuilder();
for(Object line: (List>)tb) {
sb.append(line);
}
_pyroTraceback=sb.toString();
} else {
_pyroTraceback=(String)tb;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy