def read_xml(self, buildurl): url = None try: url = fileutils.open_url(buildurl + 'api/xml') log.debug('Fetching xml from %s code:%d', url.url, url.code) if url.code != 200: log.error('Failed to get CI XML from %s (code %d)', url.url, url.code) raise Stop(20, 'Job lookup failed, is the job name correct?') ci_xml = url.read() except HTTPError as e: log.error('Failed to get CI XML (%s)', e) raise Stop(20, 'Job lookup failed, is the job name correct?') finally: if url: url.close() root = XML(ci_xml) return root
def read_downloads(dlurl): url = None parser = HtmlHrefParser() try: url = fileutils.open_url(dlurl) log.debug('Fetching html from %s code:%d', url.url, url.code) if url.code != 200: log.error('Failed to get HTML from %s (code %d)', url.url, url.code) raise Stop( 20, 'Downloads page failed, is the version correct?') parser.feed(url.read()) except HTTPError as e: log.error('Failed to get HTML from %s (%s)', dlurl, e) raise Stop(20, 'Downloads page failed, is the version correct?') finally: if url: url.close() dl_icever = {} for href in parser.hrefs: try: icever = re.search('-(ice\d+).*zip$', href).group(1) if re.match('\w+://', href): fullurl = href else: fullurl = dlurl + href try: dl_icever[icever].append(fullurl) except KeyError: dl_icever[icever] = [fullurl] log.debug('Found artifact: %s', fullurl) except AttributeError: pass return dl_icever
def read_downloads(dlurl): url = None parser = HtmlHrefParser() try: url = fileutils.open_url(dlurl) log.debug('Fetching html from %s code:%d', url.url, url.code) if url.code != 200: log.error('Failed to get HTML from %s (code %d)', url.url, url.code) raise Stop(20, 'Downloads page failed, is the version correct?') parser.feed(url.read()) except HTTPError as e: log.error('Failed to get HTML from %s (%s)', dlurl, e) raise Stop(20, 'Downloads page failed, is the version correct?') finally: if url: url.close() dl_icever = {} for href in parser.hrefs: try: icever = re.search('-(ice\d+).*zip$', href).group(1) if re.match('\w+://', href): fullurl = href else: fullurl = dlurl + href try: dl_icever[icever].append(fullurl) except KeyError: dl_icever[icever] = [fullurl] log.debug('Found artifact: %s', fullurl) except AttributeError: pass return dl_icever