Beispiel #1
0
 def handle_spawn(self, json_message):
     if self._proc is not None:
         # spawn can only be called once
         return
     command = self.build_command(json_message)
     _LOGGER.info("Running command '%s'", ' '.join(shlex_quote(x) for x in command))
     self._proc = tornado.process.Subprocess(command,
                                             stdout=tornado.process.Subprocess.STREAM,
                                             stderr=subprocess.STDOUT,
                                             stdin=tornado.process.Subprocess.STREAM)
     self._proc.set_exit_callback(self._proc_on_exit)
     tornado.ioloop.IOLoop.current().spawn_callback(self._redirect_stdout)
Beispiel #2
0
 def on_message(self, message):
     if USING_HASSIO_AUTH or USING_PASSWORD:
         if self.get_secure_cookie('authenticated') != cookie_authenticated_yes:
             return
     if self.proc is not None:
         return
     command = self.build_command(message)
     _LOGGER.info(u"Running command '%s'", ' '.join(shlex_quote(x) for x in command))
     self.proc = tornado.process.Subprocess(command,
                                            stdout=tornado.process.Subprocess.STREAM,
                                            stderr=subprocess.STDOUT)
     self.proc.set_exit_callback(self.proc_on_exit)
     tornado.ioloop.IOLoop.current().spawn_callback(self.redirect_stream)