Esempio n. 1
0
  def __init__(self, basepath, options):
    self.basepath = os.path.abspath(basepath)
    self.options = options
    if not hasattr(self.options, 'no_symlinks'):

      self.options.no_symlinks = True

    java_home, exec_suffix = java_utils.JavaHomeAndSuffix()
    self.java_command = os.path.join(java_home, 'bin', 'java' + exec_suffix)
    self.javac_command = os.path.join(java_home, 'bin', 'javac' + exec_suffix)

    self._ValidateXmlFiles()

    self.app_engine_web_xml = self._ReadAppEngineWebXml()
    self.app_engine_web_xml.app_root = self.basepath
    if self.options.app_id:
      self.app_engine_web_xml.app_id = self.options.app_id
    if self.options.version:
      self.app_engine_web_xml.version_id = self.options.version
    quickstart = xml_parser_utils.BooleanValue(
        self.app_engine_web_xml.beta_settings.get('java_quickstart', 'false'))
    if quickstart:
      web_xml_str, _ = java_quickstart.quickstart_generator(self.basepath)
      webdefault_xml_str = java_quickstart.get_webdefault_xml()
      web_xml_str = java_quickstart.remove_mappings(
          web_xml_str, webdefault_xml_str)
      self.web_xml = web_xml_parser.WebXmlParser().ProcessXml(web_xml_str)
    else:
      self.web_xml = self._ReadWebXml()
    def __init__(self, basepath, options):
        self.basepath = os.path.abspath(basepath)
        self.options = options
        if not hasattr(self.options, 'no_symlinks'):

            self.options.no_symlinks = True

        java_home, exec_suffix = java_utils.JavaHomeAndSuffix()
        self.java_command = os.path.join(java_home, 'bin',
                                         'java' + exec_suffix)
        self.javac_command = os.path.join(java_home, 'bin',
                                          'javac' + exec_suffix)

        self._ValidateXmlFiles()

        self.app_engine_web_xml = self._ReadAppEngineWebXml()
        self.app_engine_web_xml.app_root = self.basepath
        if self.options.app_id:
            self.app_engine_web_xml.app_id = self.options.app_id
        if self.options.version:
            self.app_engine_web_xml.version_id = self.options.version
        quickstart = xml_parser_utils.BooleanValue(
            self.app_engine_web_xml.beta_settings.get('java_quickstart',
                                                      'false'))
        if quickstart:
            web_xml_str, _ = java_quickstart.quickstart_generator(
                self.basepath)
            webdefault_xml_str = java_quickstart.get_webdefault_xml()
            web_xml_str = java_quickstart.remove_mappings(
                web_xml_str, webdefault_xml_str)
            self.web_xml = web_xml_parser.WebXmlParser().ProcessXml(
                web_xml_str)
        else:
            self.web_xml = self._ReadWebXml()
  def __init__(self, basepath, options):
    self.basepath = os.path.abspath(basepath)
    self.options = options
    if not hasattr(self.options, 'no_symlinks'):

      self.options.no_symlinks = True



    java_home, exec_suffix = java_utils.JavaHomeAndSuffix()
    self.java_command = os.path.join(java_home, 'bin', 'java' + exec_suffix)
    self.javac_command = os.path.join(java_home, 'bin', 'javac' + exec_suffix)

    self._ValidateXmlFiles()

    self.app_engine_web_xml = self._ReadAppEngineWebXml()
    if self.app_engine_web_xml.env in ['flex', 'flexible']:
      raise ConfigurationError(
          'Flex environment is not supported with this tool.'
          ' Please use the Cloud SDK to perform a deployment.')
    self.app_engine_web_xml.app_root = self.basepath
    if self.options.app_id:
      self.app_engine_web_xml.app_id = self.options.app_id
    if self.options.version:
      self.app_engine_web_xml.version_id = self.options.version
    quickstart = xml_parser_utils.BooleanValue(
        self.app_engine_web_xml.beta_settings.get('java_quickstart', 'false'))
    if quickstart:
      web_xml_str, _ = java_quickstart.quickstart_generator(self.basepath)
      webdefault_xml_str = java_quickstart.get_webdefault_xml()
      web_xml_str = java_quickstart.remove_mappings(
          web_xml_str, webdefault_xml_str)
      self.web_xml = web_xml_parser.WebXmlParser().ProcessXml(web_xml_str)
    else:
      self.web_xml = self._ReadWebXml()
Esempio n. 4
0
    def _parse_java_configuration(self, app_engine_web_xml_path):
        """Parse appengine-web.xml and web.xml.

    Args:
      app_engine_web_xml_path: A string containing the full path of the
          .../WEB-INF/appengine-web.xml file. The corresponding
          .../WEB-INF/web.xml file must also be present.

    Returns:
      A tuple where the first element is the parsed appinfo.AppInfoExternal
      object and the second element is a list of the paths of the files that
      were used to produce it, namely the input appengine-web.xml file and the
      corresponding web.xml file.
    """
        with open(app_engine_web_xml_path) as f:
            app_engine_web_xml_str = f.read()
        app_engine_web_xml = (app_engine_web_xml_parser.AppEngineWebXmlParser(
        ).ProcessXml(app_engine_web_xml_str))

        quickstart = xml_parser_utils.BooleanValue(
            app_engine_web_xml.beta_settings.get('java_quickstart', 'false'))

        web_inf_dir = os.path.dirname(app_engine_web_xml_path)
        if quickstart:
            app_dir = os.path.dirname(web_inf_dir)
            web_xml_str, web_xml_path = java_quickstart.quickstart_generator(
                app_dir)
            webdefault_xml_str = java_quickstart.get_webdefault_xml()
            web_xml_str = java_quickstart.remove_mappings(
                web_xml_str, webdefault_xml_str)
        else:
            web_xml_path = os.path.join(web_inf_dir, 'web.xml')
            with open(web_xml_path) as f:
                web_xml_str = f.read()

        has_jsps = False
        for _, _, filenames in os.walk(self.application_root):
            if any(f.endswith('.jsp') for f in filenames):
                has_jsps = True
                break

        web_xml = web_xml_parser.WebXmlParser().ProcessXml(
            web_xml_str, has_jsps)
        app_yaml_str = yaml_translator.TranslateXmlToYamlForDevAppServer(
            app_engine_web_xml, web_xml, self.application_root)
        config = appinfo.LoadSingleAppInfo(app_yaml_str)
        return config, [app_engine_web_xml_path, web_xml_path]
  def _parse_java_configuration(self, app_engine_web_xml_path):
    """Parse appengine-web.xml and web.xml.

    Args:
      app_engine_web_xml_path: A string containing the full path of the
          .../WEB-INF/appengine-web.xml file. The corresponding
          .../WEB-INF/web.xml file must also be present.

    Returns:
      A tuple where the first element is the parsed appinfo.AppInfoExternal
      object and the second element is a list of the paths of the files that
      were used to produce it, namely the input appengine-web.xml file and the
      corresponding web.xml file.
    """
    with open(app_engine_web_xml_path) as f:
      app_engine_web_xml_str = f.read()
    app_engine_web_xml = (
        app_engine_web_xml_parser.AppEngineWebXmlParser().ProcessXml(
            app_engine_web_xml_str))

    quickstart = xml_parser_utils.BooleanValue(
        app_engine_web_xml.beta_settings.get('java_quickstart', 'false'))

    web_inf_dir = os.path.dirname(app_engine_web_xml_path)
    if quickstart:
      app_dir = os.path.dirname(web_inf_dir)
      web_xml_str, web_xml_path = java_quickstart.quickstart_generator(app_dir)
      webdefault_xml_str = java_quickstart.get_webdefault_xml()
      web_xml_str = java_quickstart.remove_mappings(
          web_xml_str, webdefault_xml_str)
    else:
      web_xml_path = os.path.join(web_inf_dir, 'web.xml')
      with open(web_xml_path) as f:
        web_xml_str = f.read()

    has_jsps = False
    for _, _, filenames in os.walk(self.application_root):
      if any(f.endswith('.jsp') for f in filenames):
        has_jsps = True
        break

    web_xml = web_xml_parser.WebXmlParser().ProcessXml(web_xml_str, has_jsps)
    app_yaml_str = yaml_translator.TranslateXmlToYamlForDevAppServer(
        app_engine_web_xml, web_xml, self.application_root)
    config = appinfo.LoadSingleAppInfo(app_yaml_str)
    return config, [app_engine_web_xml_path, web_xml_path]
Esempio n. 6
0
    def __init__(self, basepath, options):
        self.basepath = os.path.abspath(basepath)
        self.options = options
        if not hasattr(self.options, 'no_symlinks'):

            self.options.no_symlinks = True

        java_home, exec_suffix = java_utils.JavaHomeAndSuffix()
        self.java_command = os.path.join(java_home, 'bin',
                                         'java' + exec_suffix)
        self.javac_command = os.path.join(java_home, 'bin',
                                          'javac' + exec_suffix)

        self._ValidateXmlFiles()

        self.app_engine_web_xml = self._ReadAppEngineWebXml()
        if self.app_engine_web_xml.env in ['flex', 'flexible']:
            raise ConfigurationError(
                'Flex environment is not supported with this tool.'
                ' Please use the Cloud SDK to perform a deployment.')
        self.app_engine_web_xml.app_root = self.basepath
        if self.options.app_id:
            self.app_engine_web_xml.app_id = self.options.app_id
        if self.options.version:
            self.app_engine_web_xml.version_id = self.options.version
        quickstart = xml_parser_utils.BooleanValue(
            self.app_engine_web_xml.beta_settings.get('java_quickstart',
                                                      'false'))
        if quickstart:
            web_xml_str, _ = java_quickstart.quickstart_generator(
                self.basepath)
            webdefault_xml_str = java_quickstart.get_webdefault_xml()
            web_xml_str = java_quickstart.remove_mappings(
                web_xml_str, webdefault_xml_str)
            self.web_xml = web_xml_parser.WebXmlParser().ProcessXml(
                web_xml_str)
        else:
            self.web_xml = self._ReadWebXml()