The MIMIC Python API is an optional Update Wizard package, and requires the use of the Python 2.7 or later. Python is already installed on Linux platforms, but will have to be installed on the other platforms. MIMIC has been tested with Python 2.7.3 and upto 3.8 on Linux, and Python 2.7 and 3.5.1 on Windows.
The Hello, World! program for the Python MIMIC API is these commands typed into the mimicsh.py shell:
% ./mimicsh.py MIMIC Python API shell Copyright (c) 2012-2013 Gambit Communications, Inc. Type "help;" for online help. mimicsh-python>>> session.cfg_new() mimicsh-python>>> session.cfg_load('agent.cfg') mimicsh-python>>> agent = session.get_agent(1) mimicsh-python>>> agent.start() mimicsh-python>>>
While you are doing this, notice how your MIMICview reacts to each command - it synchronizes with the simulator to keep up with the latest state. When the first agent turns green, it has synchronized to your state. You have seen that you can control MIMIC from any number of clients using the MIMIC API.
You can also do this non-interactively by saving these 4 commands into a file, and running mimicsh.py with the --script option:
% cat > hello.py session.cfg_new() session.cfg_load('agent.cfg') agent = session.get_agent(1) agent.start() ^D % ./mimicsh.py --script hello.py
These example programs with source code show different usage of the Python API to control MIMIC:
The TestApp.py program is an small test program to exercise the MIMIC API.
The tkdemo.py sample program uses the TkInter GUI framework to implement the equivalent of the tkdemo.mtcl Tcl script.
The mimicdthreads.py client displays MIMICD thread statistics to determine performance of MIMICD threads. You can download it with Update Wizard.
Another optional Update Wizard patch is this MIMICview clone implemented in Python.
The Python API has been tested against Jython using version 2.2.1 on both Windows Vista and Linux (Fedora Core 8).
A performance test of the Python API in a Jython environment shows a significant loss in response time as compared to a native Python enviroment.