-
Notifications
You must be signed in to change notification settings - Fork 0
Repy
Repy is a turing-complete subset of Python that allows to run in a sandboxed environment.
The Python programming language is documented at docs.python.org/reference. Repy is a reduced version of the Python programming language that allows to run scripts in a sandboxed environment. Repy is part of the Seattle Testbed and has an extensive documentation in the Seattle Wiki.
- No imports, no external libraries. The
importstatement is forbidden in Repy. Some functionality from Python libraries is made available via special identifiers. (see below) - No
globalvariables. Instead Repy has a dictionarymycontextthat can be used to store global variables. - No user input via
inputorraw_input. - Some Python builtins are not available. The most important are
print-
evalandexecfile lambdareload-
reversedandsorted staticmethodsuperunicodeyield-
hasattr,getattrandsetattr
- Parameters are passed as
callargsinstead orsys.argvand start with index 0 instead of 1 (sys.argv[0]is the script itself).
echo(message) will print the message (followed by a newline) to the console.
print_exc(exception) will print an exception and a stack trace to the console.
createlock
getthreadname
createthread
exitall
sleep
randombytes
getruntime
getlasterror
tuntap_read(dev, timeout=None) will read one packet from the given network device dev and return this packet as a byte string.
The method will block until a packet arrives at the device but at most timeout seconds (forever if timeout=None). If no packet has been received before the timeout, None will be returned.
It is an error if the device does not exist.
tuntap_read_any(timeout=None) will read one packet from any network device and return it.
The return value will be a tuple (dev, packet) of the incoming device and the packet as a byte string.
The first packet that arrives at a network device will be returned.
The method will block until a packet arrives at a device but at most timeout seconds (forever if timeout=None). If no packet has been received before the timeout, (None, None) will be returned.
It is an error to call this method if no network devices exist.
tuntap_send(dev, data) will send the packet data via the network device dev. The packet must be a byte string.
It is an error if the device does not exist.
tuntap_list() will return a list of all available network devices.
tuntap_info(dev) will return a dictionary containing detailed information about the networking device dev.
The struct library is available via struct (no import needed). This library can be used to encode and decode binary data structures.
The tomato library contains implementations of protocols and nodes. This library is extensible, so please feel free to contribute.