Path: blob/main/tools/contributed/sumopy/agilepy/lib_misc/runner.py
169689 views
# Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo1# Copyright (C) 2016-2025 German Aerospace Center (DLR) and others.2# SUMOPy module3# Copyright (C) 2012-2021 University of Bologna - DICAM4# This program and the accompanying materials are made available under the5# terms of the Eclipse Public License 2.0 which is available at6# https://www.eclipse.org/legal/epl-2.0/7# This Source Code may also be made available under the following Secondary8# Licenses when the conditions for such availability set forth in the Eclipse9# Public License 2.0 are satisfied: GNU General Public License, version 210# or later which is available at11# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html12# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later1314# @file runner.py15# @author Joerg Schweizer16# @date 2012171819class Runner:20"""Class to manage the execution of processes in a script.21The class initialized with the following list of tasks:22[23('taskname1', True|False),24('taskname2', True|False),25:26:27]28The first argument is the task name, the second is whether the task should be executed or not.2930"""3132def __init__(self, tasks):33self._tasknames = []34self._taskinfos = []35self._taskindex = -136for taskname, info in tasks:37self._tasknames.append(taskname)38self._taskinfos.append(info)3940def has_task(self, taskname):41"""Returns True if taskname must be executed"""42if self._tasknames.count(taskname) > 0:43ind = self._tasknames.index(taskname)4445# check if info foresees this task46if self._taskinfos[ind]: # could be modified in the future47self._taskindex = ind48return True4950else:51return False5253else:54return False5556def get_index_current(self):57"""58Returns index of currently executed task59"""60return self._taskindex6162def format_task_current(self):63# print 'format_task_current',self._taskindex,self._tasknames64return "%03d_%s" % (self._taskindex, self._tasknames[self._taskindex])656667