- globals()['loadedmodules'] = file('/tmp/loadedmodules', 'w')
- for slot in sorted(devices.keys()):
- dev = devices[slot]
- modules = pcimap.get(dev)
- base = (dev[4] & 0xff0000) >> 16
- if len(modules) == 0:
- if base == 0x01 or base == 0x02:
- # storage or network device, in that order
- missing.append((slot, dev))
- else:
- if base == 0x01:
- storage_devices += 1
- elif base == 0x02:
- network_devices += 1
-
- # FIXME: This needs improved logic in the case of multiple matching modules
- for module in modules:
- if module not in blacklisted_modules:
- print now(),"pl_hwinit: found and loading module %s (%s)" % (module, slot)
- modprobe(module)
-
- if network_devices == 0:
- print now(),"pl_hwinit: no supported network devices found!"
- print now(),"pl_hwinit: the following devices were found, but have no driver:"
- print now(),"pl_hwinit: ", "\npl_hwinit: ".join(missing)
-
- # XXX: could check for storage devices too, but older kernels have a lot of that built-in
-
- # sd_mod won't get loaded automatically
- print now(),"pl_hwinit: loading sd_mod"
- modprobe("sd_mod")
-
- # load usb_storage to support node conf files on flash disks
- print now(),"pl_hwinit: loading usb_storage"
- modprobe("usb_storage")
-
- print now(),"pl_hwinit: loading floppy device driver"
- modprobe("floppy","floppy=0,allowed_drive_mask")
+ with open('/tmp/loadedmodules', 'w') as loadedmodules:
+ for slot in sorted(devices.keys()):
+ dev = devices[slot]
+ modules = pcimap.get(dev)
+ base = (dev[4] & 0xff0000) >> 16
+ if len(modules) == 0:
+ if base == 0x01 or base == 0x02:
+ # storage or network device, in that order
+ missing.append((slot, dev))
+ else:
+ if base == 0x01:
+ storage_devices += 1
+ elif base == 0x02:
+ network_devices += 1
+
+ # FIXME: This needs improved logic in the case of multiple matching modules
+ for module in modules:
+ if module not in blacklisted_modules:
+ verbose_message("pl_hwinit: found and loading module {} (%s)" % (module, slot))
+ modprobe(module, loadedmodules)
+
+ if network_devices == 0:
+ verbose_message("pl_hwinit: no supported network devices found!")
+ verbose_message("pl_hwinit: the following devices were found, but have no driver:")
+ lines = [ "{} x {}".format(slot, dev) for slot, dev in missing ]
+ for line in lines:
+ verbose_message("pl_hwinit: missing " + line)
+
+ # XXX: could check for storage devices too, but older kernels have a lot of that built-in
+
+ # sd_mod won't get loaded automatically
+ verbose_message("pl_hwinit: loading sd_mod")
+ modprobe("sd_mod", loadedmodules)
+
+ # load usb_storage to support node conf files on flash disks
+ verbose_message("pl_hwinit: loading usb_storage")
+ modprobe("usb_storage", loadedmodules)
+
+ verbose_message("pl_hwinit: loading floppy device driver")
+ modprobe("floppy", loadedmodules, "floppy=0,allowed_drive_mask")