Comment 1 for bug 364649

Revision history for this message
Marc Tardif (cr3) wrote :

For desktop installations, which are probably the most common, I have found the following code useful to extract the disk information from the casper.log:

        # Found label 'Ubuntu 8.04.1 _Hardy Heron_ - Release amd64 (20080702.1)'
        distributor_regex = r"(?P<distributor>[\w\-]+)"
        release_regex = r"(?P<release>[\d\.]+)"
        codename_regex = r"(?P<codename>[^_]+)"
        official_regex = r"(?P<official>[\w ]+)"
        architecture_regex = r"(?P<architecture>[\w\+]+)"
        type_regex = r"(?P<type>Binary-\d+)"
        date_regex = r"(?P<date>[^\)]+)"

        info_regex = r"%s %s _%s_ - %s %s (%s )?\(%s\)" % (distributor_regex,
            release_regex, codename_regex, official_regex, architecture_regex,
            type_regex, date_regex)
        line_regex = r"Found label '%s'" % info_regex
        line_pattern = re.compile(line_regex)

        file = open("/var/log/installer/casper.log")
        for line in file.readlines():
            match = line_pattern.match(line)
            if match:
                print match.group("codename")