From 0c0f6ee81bd89be5bfcc892b60889b0fc0830c4f Mon Sep 17 00:00:00 2001 From: brent s Date: Sun, 18 Aug 2019 22:28:52 -0400 Subject: [PATCH] fixed! no more messages about missing UUID --- sys/BootSync/bootsync.py | 44 ++++++++-------------- sys/BootSync/prep.txt | 80 ++++++++++++++++++++-------------------- 2 files changed, 56 insertions(+), 68 deletions(-) diff --git a/sys/BootSync/bootsync.py b/sys/BootSync/bootsync.py index fd39c37..774ba1b 100755 --- a/sys/BootSync/bootsync.py +++ b/sys/BootSync/bootsync.py @@ -14,26 +14,6 @@ import psutil from lxml import etree - # def get_file_kernel_ver(self, kpath): - # # Gets the version of a kernel file. - # kpath = os.path.abspath(os.path.expanduser(kpath)) - # _kinfo = {} - # with open(kpath, 'rb') as f: - # _m = magic.detect_from_content(f.read()) - # for i in _m.name.split(','): - # l = i.strip().split() - # # Note: this only grabs the version number. - # # If we want to get e.g. the build user/machine, date, etc., - # # then we need to join l[1:]. - # # We technically don't even need a dict, either. We can just iterate. - # # TODO. - # _kinfo[l[0].lower()] = (l[1] if len(l) > 1 else None) - # if 'version' not in _kinfo: - # raise RuntimeError('Cannot deterimine the version of {0}'.format( - # kpath)) - # else: - # return (_kinfo['version']) - class BootSync(object): def __init__(self, cfg = None, *args, **kwargs): if not cfg: @@ -117,7 +97,13 @@ class BootSync(object): d = dict(map(lambda i: i.split('='), line)) if d.get('TYPE') == 'squashfs': continue - self.blkids[d['DEVNAME']] = d.get('PARTUUID', d['UUID']) + try: + self.blkids[d['DEVNAME']] = d.get('UUID', d['PARTUUID']) + except KeyError: + try: + self.blkids[d['DEVNAME']] = d['UUID'] + except KeyError: + continue c = subprocess.run(['/usr/bin/findmnt', '--json', '-T', '/boot'], @@ -233,14 +219,16 @@ class BootSync(object): disk = os.path.abspath(os.path.expanduser(esp.attrib['path'])) with open(os.path.join(mount, 'grub/grub.cfg'), 'w') as f: for line in _grubcfg.splitlines(): - # if re.search(r'^\s*search\s+(.*)\s(-u|--fs-uuid)', line): - # pass - i = re.sub(r'(?