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")
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<distribut or>[\w\ -]+)"
release_ regex = r"(?P<release> [\d\.]+ )"
codename_ regex = r"(?P<codename> [^_]+)"
official_ regex = r"(?P<official>[\w ]+)"
architecture_ regex = r"(?P<architect ure>[\w\ +]+)" Binary- \d+)"
type_regex = r"(?P<type>
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_pattern = re.compile( line_regex)
line_regex = r"Found label '%s'" % info_regex
file = open("/ var/log/ installer/ casper. log") match(line)
print match.group( "codename" )
for line in file.readlines():
match = line_pattern.
if match: