def do_package(self, distro_name, archive_root): """Get the Changelog and urgency from the package on archive. If successful processing of the package occurs, this method sets the changelog and urgency attributes. """ dsc, changelog, copyright = read_dsc( self.package, self.version, self.component, distro_name, archive_root) self.dsc = encoding.guess(dsc) self.copyright = encoding.guess(copyright) parsed_changelog = None if changelog: parsed_changelog = parse_changelog(changelog.split('\n')) self.urgency = None self.changelog = None self.changelog_entry = None if parsed_changelog and parsed_changelog[0]: cldata = parsed_changelog[0] if 'changes' in cldata: if cldata["package"] != self.package: log.warn("Changelog package %s differs from %s" % (cldata["package"], self.package)) if cldata["version"] != self.version: log.warn("Changelog version %s differs from %s" % (cldata["version"], self.version)) self.changelog_entry = encoding.guess(cldata["changes"]) self.changelog = changelog self.urgency = cldata["urgency"] else: log.warn("Changelog empty for source %s (%s)" % (self.package, self.version))
def __init__(self, **args): for k, v in args.items(): if k == 'Binary': self.binaries = stripseq(v.split(",")) elif k == 'Section': self.section = parse_section(v) elif k == 'Urgency': urgency = v # This is to handle cases like: # - debget: 'high (actually works) # - lxtools: 'low, closes=90239' if " " in urgency: urgency = urgency.split()[0] if "," in urgency: urgency = urgency.split(",")[0] self.urgency = urgency elif k == 'Maintainer': displayname, emailaddress = parse_person(v) try: self.maintainer = ( encoding.guess(displayname), emailaddress, ) except UnicodeDecodeError: raise DisplayNameDecodingError( "Could not decode name %s" % displayname) elif k == 'Files' or k.startswith('Checksums-'): if not hasattr(self, 'files'): self.files = [] files = v.split("\n") for f in files: self.files.append(stripseq(f.split(" "))[-1]) else: self.set_field(k, v) if self.section is None: self.section = 'misc' log.warn( "Source package %s lacks section, assumed %r", self.package, self.section) if '/' in self.section: # this apparently happens with packages in universe. # 3dchess, for instance, uses "universe/games" self.section = self.section.split("/", 1)[1] AbstractPackageData.__init__(self)
def _parseDOMString(self, contents): """Return a minidom instance representing the XML contents supplied""" # Some Bugzilla sites will return pages with content that has # broken encoding. It's unfortunate but we need to guess the # encoding that page is in, and then encode() it into the utf-8 # that minidom requires. contents = encoding.guess(contents).encode("utf-8") # Since the string is utf-8 encoded and utf-8 encoded string have the # high bit set for non-ASCII characters, we can now strip out any # ASCII control characters without touching encoded Unicode # characters. bad_chars = ''.join(chr(i) for i in range(0, 32)) for char in '\n\r\t': bad_chars = bad_chars.replace(char, '') trans_map = string.maketrans(bad_chars, ' ' * len(bad_chars)) contents = contents.translate(trans_map) return minidom.parseString(contents)
def __init__(self, **args): for k, v in args.items(): if k == 'Binary': self.binaries = stripseq(v.split(",")) elif k == 'Section': self.section = parse_section(v) elif k == 'Urgency': urgency = v # This is to handle cases like: # - debget: 'high (actually works) # - lxtools: 'low, closes=90239' if " " in urgency: urgency = urgency.split()[0] if "," in urgency: urgency = urgency.split(",")[0] self.urgency = urgency elif k == 'Maintainer': displayname, emailaddress = parse_person(v) try: self.maintainer = ( encoding.guess(displayname), emailaddress, ) except UnicodeDecodeError: raise DisplayNameDecodingError( "Could not decode name %s" % displayname) elif k == 'Files': self.files = [] files = v.split("\n") for f in files: self.files.append(stripseq(f.split(" "))) else: setattr(self, k.lower().replace("-", "_"), v) if self.section is None: self.section = 'misc' log.warn( "Source package %s lacks section, assumed %r", self.package, self.section) if '/' in self.section: # this apparently happens with packages in universe. # 3dchess, for instance, uses "universe/games" self.section = self.section.split("/", 1)[1] AbstractPackageData.__init__(self)
def updateBuild(cls, vitals, slave, builder_factory, behavior_factory): """Verify the current build job status. Perform the required actions for each state. :return: A Deferred that fires when the slave dialog is finished. """ # IDLE is deliberately not handled here, because it should be # impossible to get past rescueIfLost unless the slave matches # the DB, and this method isn't called unless the DB says # there's a job. statuses = yield cls.slaveStatus(slave) status_sentence, status_dict = statuses builder_status = status_dict['builder_status'] if builder_status == 'BuilderStatus.BUILDING': # Build still building, collect the logtail. if vitals.build_queue.job.status != JobStatus.RUNNING: # XXX: This check should be removed once we confirm it's # not regularly hit. raise AssertionError( "Job not running when assigned and slave building.") vitals.build_queue.logtail = encoding.guess( str(status_dict.get('logtail'))) transaction.commit() elif builder_status == 'BuilderStatus.ABORTING': # Build is being aborted. vitals.build_queue.logtail = ( "Waiting for slave process to be terminated") transaction.commit() elif builder_status == 'BuilderStatus.WAITING': # Build has finished. Delegate handling to the build itself. builder = builder_factory[vitals.name] behavior = behavior_factory(vitals.build_queue, builder, slave) behavior.updateSlaveStatus(status_sentence, status_dict) yield behavior.handleStatus(vitals.build_queue, cls.extractBuildStatus(status_dict), status_dict) else: raise AssertionError("Unknown status %s" % builder_status)
def updateBuild(cls, vitals, slave, builder_factory, behavior_factory): """Verify the current build job status. Perform the required actions for each state. :return: A Deferred that fires when the slave dialog is finished. """ # IDLE is deliberately not handled here, because it should be # impossible to get past rescueIfLost unless the slave matches # the DB, and this method isn't called unless the DB says # there's a job. statuses = yield cls.slaveStatus(slave) status_sentence, status_dict = statuses builder_status = status_dict['builder_status'] if builder_status == 'BuilderStatus.BUILDING': # Build still building, collect the logtail. if vitals.build_queue.job.status != JobStatus.RUNNING: # XXX: This check should be removed once we confirm it's # not regularly hit. raise AssertionError( "Job not running when assigned and slave building.") vitals.build_queue.logtail = encoding.guess( str(status_dict.get('logtail'))) transaction.commit() elif builder_status == 'BuilderStatus.ABORTING': # Build is being aborted. vitals.build_queue.logtail = ( "Waiting for slave process to be terminated") transaction.commit() elif builder_status == 'BuilderStatus.WAITING': # Build has finished. Delegate handling to the build itself. builder = builder_factory[vitals.name] behavior = behavior_factory(vitals.build_queue, builder, slave) behavior.updateSlaveStatus(status_sentence, status_dict) yield behavior.handleStatus( vitals.build_queue, cls.extractBuildStatus(status_dict), status_dict) else: raise AssertionError("Unknown status %s" % builder_status)
def __init__(self, **args): for k, v in args.items(): if k == "Maintainer": self.maintainer = parse_person(v) elif k == "Essential": self.essential = (v == "yes") elif k == 'Section': self.section = parse_section(v) elif k == "Description": self.description = encoding.guess(v) summary = self.description.split("\n")[0].strip() if not summary.endswith('.'): summary = summary + '.' self.summary = summary elif k == "Installed-Size": try: self.installed_size = int(v) except ValueError: raise MissingRequiredArguments("Installed-Size is " "not a valid integer: %r" % v) else: self.set_field(k, v) if self.source: # We need to handle cases like "Source: myspell # (1:3.0+pre3.1-6)". apt-pkg kindly splits this for us # already, but sometimes fails. # XXX: dsilvers 2005-09-22: Work out why this happens and # file an upstream bug against python-apt once we've worked # it out. if self.source_version is None: match = self.source_version_re.match(self.source) if match: self.source = match.group(1) self.source_version = match.group(2) else: # XXX kiko 2005-10-18: # This is probably a best-guess and might fail. self.source_version = self.version else: # Some packages have Source, some don't -- the ones that # don't have the same package name. self.source = self.package self.source_version = self.version if (self.source_version is None or self.source_version != self.version and not valid_debian_version(self.source_version)): raise InvalidSourceVersionError( "Binary package %s (%s) refers to source package %s " "with invalid version: %s" % (self.package, self.version, self.source, self.source_version)) if self.section is None: self.section = 'misc' log.warn( "Binary package %s lacks a section, assumed %r", self.package, self.section) if self.priority is None: self.priority = 'extra' log.warn( "Binary package %s lacks valid priority, assumed %r", self.package, self.priority) AbstractPackageData.__init__(self)
def __init__(self, **args): for k, v in args.items(): if k == "Maintainer": self.maintainer = parse_person(v) elif k == "Essential": self.essential = (v == "yes") elif k == 'Section': self.section = parse_section(v) elif k == "Description": self.description = encoding.guess(v) summary = self.description.split("\n")[0].strip() if not summary.endswith('.'): summary = summary + '.' self.summary = summary elif k == "Installed-Size": try: self.installed_size = int(v) except ValueError: raise MissingRequiredArguments("Installed-Size is " "not a valid integer: %r" % v) else: setattr(self, k.lower().replace("-", "_"), v) if self.source: # We need to handle cases like "Source: myspell # (1:3.0+pre3.1-6)". apt-pkg kindly splits this for us # already, but sometimes fails. # XXX: dsilvers 2005-09-22: Work out why this happens and # file an upstream bug against python-apt once we've worked # it out. if self.source_version is None: match = self.source_version_re.match(self.source) if match: self.source = match.group(1) self.source_version = match.group(2) else: # XXX kiko 2005-10-18: # This is probably a best-guess and might fail. self.source_version = self.version else: # Some packages have Source, some don't -- the ones that # don't have the same package name. self.source = self.package self.source_version = self.version if (self.source_version is None or self.source_version != self.version and not valid_debian_version(self.source_version)): raise InvalidSourceVersionError( "Binary package %s (%s) refers to source package %s " "with invalid version: %s" % (self.package, self.version, self.source, self.source_version)) if self.section is None: self.section = 'misc' log.warn( "Binary package %s lacks a section, assumed %r", self.package, self.section) if self.priority is None: self.priority = 'extra' log.warn( "Binary package %s lacks valid priority, assumed %r", self.package, self.priority) AbstractPackageData.__init__(self)