Esempio n. 1
0
def setup_jedihttp():
  with hmaclib.TemporaryHmacSecretFile( SECRET ) as hmac_file:
    command = [ utils.python(),
                '-u', # this flag makes stdout non buffered
                PATH_TO_JEDIHTTP,
                '--port', str( PORT ),
                '--hmac-file-secret', hmac_file.name ]
    return utils.SafePopen( command,
                            stderr = subprocess.STDOUT,
                            stdout = subprocess.PIPE )
Esempio n. 2
0
  def _StartServer( self ):
    with self._server_lock:
      self._logger.info( 'Starting JediHTTP server' )
      self._ChoosePort()
      self._GenerateHmacSecret()

      with hmaclib.TemporaryHmacSecretFile( self._hmac_secret ) as hmac_file:
        command = [ self._python_binary_path,
                    PATH_TO_JEDIHTTP,
                    '--port', str( self._jedihttp_port ),
                    '--hmac-file-secret', hmac_file.name ]

      self._logfile_stdout = LOG_FILENAME_FORMAT.format(
          port = self._jedihttp_port, std = 'stdout' )
      self._logfile_stderr = LOG_FILENAME_FORMAT.format(
          port = self._jedihttp_port, std = 'stderr' )

      with open( self._logfile_stderr, 'w' ) as logerr:
        with open( self._logfile_stdout, 'w' ) as logout:
          self._jedihttp_phandle = utils.SafePopen( command,
                                                    stdout = logout,
                                                    stderr = logerr )