Exemplo n.º 1
0
def performEvent(monitor, sequence):
    """
    Performs an event on the specified monitor.

    If the event has previous events leading up to it, these get performed
    first. Each event is performed and a delay of 'steptime' is waited.
    'steptime' is a configuration value in the general section and is
    in seconds.

    After the last event is performed, a snapshot is taken and returned.
    """
    with monitor:
        # Perform the event sequence
        for e in sequence:
            e.perform(monitor)
            time.sleep(steptime)

        return monitor.take_snapshot()
Exemplo n.º 2
0
                    yield e

def load_state(monitor, efg_file):
    cache_file = '%s.cache' % efg_file
    if os.path.exists(cache_file):
        try:
            # reload cache file
            log.info('loading cache file from %s' % cache_file)
            return parser.load(cache_file)
        except Exception, e:
            log.exception(e)

    # initial snapshot
    log.info('taking initial snapshot')
    with monitor:
        initial = monitor.take_snapshot()
    return global_state(digraph(), initial)

@requires_monitor(interrupt_ripper)
def main(monitors, cfg):
    efg_file = cfg.get('general', 'efg_file')

    state, lock = load_state(monitors[0], efg_file), threading.Lock()

    config_loc = cfg.get('general', 'configuration')
    ignored_patterns = []
    try:
        ignored_patterns = parser.load(config_loc)
    except Exception, e:
        # Some error happened when reading the configuration file
        log.exception(e)