def validate_object(schema, obj, name): sobj = None for root in dput.core.SCHEMA_DIRS: if sobj is not None: logger.debug("Skipping %s" % (root)) continue logger.debug("Loading schema %s from %s" % (schema, root)) spath = "%s/%s.json" % ( root, schema ) try: if os.path.exists(spath): sobj = json.load(open(spath, 'r')) else: logger.debug("No such config: %s" % (spath)) except ValueError as e: raise DputConfigurationError("syntax error in %s: %s" % ( spath, e )) if sobj is None: logger.critical("Schema not found: %s" % (schema)) raise DputConfigurationError("No such schema: %s" % (schema)) try: import validictory validictory.validate(obj, sobj) except ImportError: pass except validictory.validator.ValidationError as e: err = str(e) error = "Error with config file %s - %s" % ( name, err ) ex = InvalidConfigError(error) ex.obj = obj ex.root = e ex.config_name = name ex.sdir = dput.core.SCHEMA_DIRS ex.schema = schema raise ex
def check_supported_distribution(changes, profile, interface): """ The ``supported-distribution`` checker is a stock dput checker that checks packages intended for upload for a valid upload distribution. Profile key: supported-distribution """ suite = changes['Distribution'] if profile.get('codenames'): if '-' in suite: release, pocket = suite.split('-', 1) else: release, pocket = suite, 'release' codenames = profile['codenames'] if codenames == 'ubuntu': distro_info = UbuntuDistroInfo() pockets = profile['supported-distribution'] logger.critical(pockets) if pocket not in pockets['known']: raise UnknownDistribution("Unkown pocket: %s" % pocket) if pocket not in pockets['allowed']: raise UnknownDistribution( "Uploads aren't permitted to pocket: %s" % pocket) elif codenames == 'debian': distro_info = DebianDistroInfo() else: raise UnknownDistribution("distro-info doesn't know about %s" % codenames) try: codename = distro_info.codename(release, default=release) if codename not in distro_info.all: raise UnsupportedDistribution('Unknown release %s' % release) if codename not in distro_info.supported(): raise UnsupportedDistribution('Unsupported release %s' % release) except DistroDataOutdated: logger.warn('distro-info is outdated, ' 'unable to check supported releases')