def __init__(self, file_path, parsed): """Creates a new ServiceYamlInfo. Args: file_path: str, The full path the file that was parsed. parsed: appinfo.AppInfoExternal, parsed Application Configuration. """ super(ServiceYamlInfo, self).__init__(file_path, parsed) self.module = parsed.module # All env: 2 apps are hermetic. All vm: false apps are not hermetic except # for those with (explicit) env: 1 and runtime: custom. vm: true apps are # hermetic IFF they don't use static files. if util.IsFlex(parsed.env): self.is_hermetic = True elif util.IsStandard(parsed.env): self.is_hermetic = parsed.runtime == 'custom' elif parsed.vm: for urlmap in parsed.handlers: if urlmap.static_dir or urlmap.static_files: self.is_hermetic = False break else: self.is_hermetic = True else: self.is_hermetic = False if util.IsStandard(parsed.env) and self.is_hermetic: self.env = util.Environment.STANDARD self.runtime = parsed.runtime elif parsed.runtime == 'vm' or self.is_hermetic: self.env = util.Environment.FLEXIBLE self.runtime = parsed.GetEffectiveRuntime() self._UpdateManagedVMConfig() else: self.env = util.Environment.STANDARD self.runtime = parsed.runtime
def FromFile(file_path): """Parses the given service file. Args: file_path: str, The full path to the service file. Raises: YamlParseError: If the file is not a valid Yaml-file. YamlValidationError: If validation of parsed info fails. Returns: A ServiceYamlInfo object for the parsed file. """ try: parsed = _YamlInfo._ParseYaml(file_path, appinfo_includes.Parse) except (yaml_errors.Error, appinfo_errors.Error) as e: raise YamlParseError(file_path, e) if parsed.runtime == 'vm': vm_runtime = parsed.GetEffectiveRuntime() else: vm_runtime = None if parsed.runtime == 'python': raise YamlValidationError( 'Service [{service}] uses unsupported Python 2.5 runtime. ' 'Please use [runtime: python27] instead.'.format( service=(parsed.service or ServiceYamlInfo.DEFAULT_SERVICE_NAME))) elif parsed.runtime == 'python-compat': raise YamlValidationError( '"python-compat" is not a supported runtime.') elif parsed.runtime == 'custom' and not parsed.env: raise YamlValidationError( 'runtime "custom" requires that env be explicitly specified.' ) if parsed.vm: log.warning(MANAGED_VMS_DEPRECATION_WARNING) if (util.IsFlex(parsed.env) and parsed.beta_settings and parsed.beta_settings.get('enable_app_engine_apis')): log.warning(APP_ENGINE_APIS_DEPRECATION_WARNING) if util.IsFlex(parsed.env) and vm_runtime == 'python27': raise YamlValidationError( 'The "python27" is not a valid runtime in env: flex. ' 'Please use [python] instead.') if util.IsFlex(parsed.env) and vm_runtime == 'python-compat': log.warning( '[runtime: {}] is deprecated. Please use [runtime: python] ' 'instead. See {} for more info.'.format( vm_runtime, UPGRADE_FLEX_PYTHON_URL)) for warn_text in parsed.GetWarnings(): log.warning('In file [{0}]: {1}'.format(file_path, warn_text)) if (util.IsStandard(parsed.env) and parsed.runtime == 'python27' and HasLib(parsed, 'ssl', '2.7')): log.warning(PYTHON_SSL_WARNING) _CheckIllegalAttribute(name='application', yaml_info=parsed, extractor_func=lambda yaml: yaml.application, file_path=file_path, msg=HINT_PROJECT) _CheckIllegalAttribute(name='version', yaml_info=parsed, extractor_func=lambda yaml: yaml.version, file_path=file_path, msg=HINT_VERSION) return ServiceYamlInfo(file_path, parsed)