def get_info(self): """Parse launchpad page HTML for mirror information Ideally, launchpadlib would be used to get mirror information, but the Launchpad API doesn't support access to archivemirror statuses.""" try: launch_html = get_text(self._launch_url) except URLGetTextError as err: stderr.write("connection to %s: %s\n" % (self._launch_url, err)) self._data_queue.put_nowait((self._url, None)) else: info = self.__parse_mirror_html(launch_html) if "Status" not in info: stderr.write(("Unable to parse status info from %s\n" % self._launch_url)) self._data_queue.put_nowait((self._url, None)) return # Launchpad has more descriptive "unknown" status. # It's trimmed here to match statuses list if "unknown" in info["Status"]: info["Status"] = "unknown" self._data_queue.put((self._url, info))
def get_mirrors(mirrors_url): """Fetch list of Ubuntu mirrors""" stderr.write("Getting list of mirrors...") try: mirrors_list = get_text(mirrors_url) except URLGetTextError as err: exit("Error getting list from %s:\n\t%s" % (mirrors_url, err)) stderr.write("done.\n") return mirrors_list.splitlines()
def get_launchpad_urls(self): """Obtain mirrors' corresponding launchpad URLs""" stderr.write("Getting list of launchpad URLs...") try: self._launchpad_html = get_text(self._launchpad_url) except URLGetTextError as err: stderr.write( ("%s: %s\nUnable to retrieve list of launchpad sites\n" "Reverting to latency only" % (self._launchpad_url, err))) self.abort_launch = True else: stderr.write("done.\n") self.__parse_launchpad_list()