MIMIC Python API Guide

  1. Table of Contents
  2. Requirements
  3. 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.

  4. Class Reference
  5. The Python API is modelled after the Java API. All classes and methods have the same name as in Java, except that Python programming constructs are used. Click here for the generated Java reference documentation.

  6. Hello, World!
  7. 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
    
    

  8. Examples
  9. These example programs with source code show different usage of the Python API to control MIMIC:

  10. Jython
    • 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.