Пример #1
0
 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
Пример #2
0
 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
Пример #3
0
 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
Пример #4
0
 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
Пример #5
0
 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