Source code for spinn_front_end_common.utilities.globals_variables

# Copyright (c) 2017-2019 The University of Manchester
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from pacman.executor import injection_decorator

_failed_state = None
_simulator = None


[docs]def get_simulator(): global _simulator, _failed_state if _simulator is None: if _failed_state is None: raise ValueError("You must import one of the simulator classes " "before calling get_simulator") return _failed_state return _simulator
[docs]def get_not_running_simulator(): global _simulator, _failed_state if _simulator is None: if _failed_state is None: raise ValueError("You must import one of the simulator classes " "before calling get_simulator") return _failed_state _simulator.verify_not_running() return _simulator
[docs]def set_simulator(new_simulator): global _simulator, _failed_state if _failed_state is None: raise ValueError("Unexpected call to set_simulator before " "set_failed_state") _simulator = new_simulator
[docs]def unset_simulator(): global _simulator _simulator = None injection_decorator._instances = list()
[docs]def has_simulator(): global _simulator return _simulator is not None
[docs]def set_failed_state(new_failed_state): # pylint: disable=unidiomatic-typecheck global _failed_state if _failed_state is None: _failed_state = new_failed_state elif type(new_failed_state) != type(_failed_state): raise ValueError("You may only setup/init one type of simulator")