This repository was archived by the owner on Jun 27, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 95
Main method
joshreich edited this page Dec 5, 2014
·
5 revisions
Every Pyretic program must have a main method and import at minimum the Pyretic core library. The main method must return an instance of Pyretic's Policy class (or any descendant class). See here for some basic Pyretic policies and combinators.
For example, one of the simplest Pyretic programs you can write is
from pyretic.lib.corelib import *
def main():
return flood()
Generally you will probably want to import the Pyretic standard library as well (contains some useful functions for setting breakpoints, helpful print functions, and some convience filter policies).
from pyretic.lib.std import *
In a more advanced example, a main function can take input in the normal way
def main(clients, servers):
from pyretic.modules.mac_learner import mac_learner
num_clients = int(clients)
num_servers = int(servers)
print "clients %d" % num_clients
print "servers %d" % num_servers
...