def update(self): """ Update each existing package md5checksum and size attribute.""" for name in self.keys(): fullname = os.path.join(self._filepath, name) if os.path.exists(fullname): result = self[name] result['md5checksum'] = unicode(fileutils.getmd5(fullname)) result['size'] = unicode(os.path.getsize(fullname)) self[name] = result
def is_valid(self, checkmd5=True, checkPath=True): """ Run the validation mechanism. """ status = os.path.join(os.path.dirname(self._filename), 'HYDRASTATUS.xml') if os.path.exists(status): hydraxml = xml.dom.minidom.parse(open(status, "r")) for t in hydraxml.getElementsByTagName('state')[0].childNodes: if t.nodeType == t.TEXT_NODE: if t.nodeValue != 'Ready': LOGGER.error("HYDRASTATUS.xml is not ready") return False if checkPath: if os.path.basename(self.location) != self.release: LOGGER.error("Release doesn't match.") return False if os.path.basename(os.path.dirname(self.location)) != self.product: LOGGER.error("Product doesn't match.") return False if os.path.basename(os.path.dirname(os.path.dirname(self.location))) != self.service: LOGGER.error("Service doesn't match.") return False for name in self.keys(): path = os.path.join(self.location, name) if not os.path.exists(path): LOGGER.error("%s doesn't exist." % path) return False try: LOGGER.debug("Trying to open %s" % path) content_file = open(path) content_file.read(1) except IOError: LOGGER.error("%s is not available yet" % path) return False if checkmd5 and self[name].has_key('md5checksum'): if self[name]['md5checksum'] != None: if fileutils.getmd5(path).lower() != self[name]['md5checksum']: LOGGER.error("%s md5checksum missmatch." % path) return False for sp in self.servicepacks: for name in sp.files: path = os.path.join(self.location, name) if not os.path.exists(path): LOGGER.error("%s doesn't exist." % path) return False for name in sp.instructions: path = os.path.join(self.location, name) if not os.path.exists(path): LOGGER.error("%s doesn't exist." % path) return False dependency = self.get_dependsof() if dependency != None: return ValidateReleaseMetadata(dependency.filename).is_valid(checkmd5) return True