Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 5
0
 def start_script(self, start_script=None):
     if cherrypy.request.method == 'GET':
         return self._current_script()
     elif cherrypy.request.method == 'POST':
         if not start_script in self._start_scripts.keys():
             raise cherrypy.HTTPError(405)
         if start_script == self._current_script():
             return  # Nothing to do
         run_cmd('sudo systemctl stop trainer_tools')
         if os.path.exists('start_script'):
             os.unlink('start_script')
         os.symlink(self._start_scripts[start_script], 'start_script')
         run_cmd('sudo systemctl start trainer_tools')
     else:
         raise cherrypy.HTTPError(405)
Exemplo n.º 6
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