Path: blob/main/tests/complex/sumo-gui/pyautogui_start_stop/runner.py
169686 views
#!/usr/bin/env python1# Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2# Copyright (C) 2008-2025 German Aerospace Center (DLR) and others.3# This program and the accompanying materials are made available under the4# terms of the Eclipse Public License 2.0 which is available at5# https://www.eclipse.org/legal/epl-2.0/6# This Source Code may also be made available under the following Secondary7# Licenses when the conditions for such availability set forth in the Eclipse8# Public License 2.0 are satisfied: GNU General Public License, version 29# or later which is available at10# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later1213# @file runner.py14# @author Michael Behrisch15# @date 2010-10-261617from __future__ import absolute_import1819import os20import subprocess21import sys22import time23import warnings24warnings.filterwarnings("ignore", category=ResourceWarning) # pyscreeze leaves files open25import pyautogui # noqa2627if "SUMO_HOME" in os.environ:28sys.path.append(os.path.join(os.environ["SUMO_HOME"], "tools"))29import sumolib # noqa303132PLAY = os.path.join("data", "play.png")33STOP = os.path.join("data", "stop.png")343536def findAndClick(obj):37positionOnScreen = pyautogui.locateOnScreen(obj, minSearchTime=3, confidence=0.9)38pyautogui.moveTo(positionOnScreen)39pyautogui.click()404142guisimBinary = sumolib.checkBinary('sumo-gui')43for run in range(3):44p = subprocess.Popen([guisimBinary, "-Q", "-c", "sumo.sumocfg"])45time.sleep(1)46findAndClick(PLAY)47time.sleep(10)48for step in range(3):49findAndClick(STOP)50time.sleep(1)51findAndClick(PLAY)52time.sleep(1)53p.wait()545556