Esempio n. 1
0
 def VerifyRequiredEntriesPresent(self):
     if not all([
             self.app_engine_web_xml.app_id,
             self.app_engine_web_xml.version_id,
             GetRuntime(), self.app_engine_web_xml.threadsafe_value_provided
     ]):
         raise AppEngineConfigException('Missing required fields')
Esempio n. 2
0
 def ErrorHandlerPath(self, error_handler):
     name = error_handler.name
     if name.startswith('/'):
         name = name[1:]
     if name not in self.static_files:
         raise AppEngineConfigException(
             'No static file found for error handler: %s, out of %s' %
             (name, self.static_files))
     return name
 def VerifyRequiredEntriesPresent(self):
     required = {
         'runtime': self.GetRuntime(),
         'threadsafe': self.app_engine_web_xml.threadsafe_value_provided,
     }
     missing = [field for (field, value) in required.items() if not value]
     if missing:
         raise AppEngineConfigException('Missing required fields: %s' %
                                        ', '.join(missing))
Esempio n. 4
0
    def ErrorHandlerPath(self, error_handler):
        """Returns the relative path name for the given error handler.

    Args:
      error_handler: an app_engine_web_xml.ErrorHandler.

    Returns:
      the relative path name for the handler.

    Raises:
      AppEngineConfigException: if the named file is not an existing static
        file.
    """
        name = error_handler.name
        if not name.startswith('/'):
            name = '/' + name
        path = '__static__' + name
        if path not in self.static_files:
            raise AppEngineConfigException(
                'No static file found for error handler: %s, out of %s' %
                (name, self.static_files))
        return path
Esempio n. 5
0
    def TranslateErrorHandlers(self):
        """Translates error handlers specified in appengine-web.xml to yaml."""
        if not self.app_engine_web_xml.static_error_handlers:
            return []
        statements = ['error_handlers:']
        for error_handler in self.app_engine_web_xml.static_error_handlers:
            name = error_handler.name
            if not name.startswith('/'):
                name = '/' + name

            if ('__static__' + name) not in self.static_files:
                raise AppEngineConfigException(
                    'No static file found for error handler: %s, out of %s' %
                    (name, self.static_files))
            statements.append('- file: __static__%s' % name)
            if error_handler.code:
                statements.append('  error_code: %s' % error_handler.code)
            mime_type = self.web_xml.GetMimeTypeForPath(name)
            if mime_type:
                statements.append('  mime_type: %s' % mime_type)

        return statements