def stop(self): if not running_on_rpi(): return self._mock_stop() try: run_cmd('sudo systemctl stop trainer_tools') return True except: return False
def restart(self): if not running_on_rpi(): return self._mock_restart() try: run_cmd('sudo systemctl restart trainer_tools') return True except: return False
def restart(self): if not running_on_rpi(): print('Mocking system restart') return self._mock_restart() try: run_cmd('sudo reboot') return True except: return False
def shutdown(self): if not running_on_rpi(): print('Mocking system shutdown') return self._mock_shutdown() try: run_cmd('sudo shutdown -h now') return True except: return False
def running(self): if not running_on_rpi(): return self._mock_is_running try: output = run_cmd('sudo systemctl status trainer_tools') m = self._SVC_STATUS_RE.search(output) if m == None or len(m.groups()) == 0: return False return m.groups()[0].lower() == 'active' except: return False