- file = open("/proc/partitions")
- partitions = file.readlines()
- file.close()
- file = open("/proc/mounts")
- mounts = file.readlines()
- file.close()
- not_mounted = False
- for part in partitions:
- res = re.sub("\s+", " ", part).strip().split(" ")
- if res and len(res) == 4:
- if len(res[3]) == 3 and res[3][:2] == "sd":
- device = "/dev/" + res[3]
- print "found device %s"%device
- not_mounted = True
- for line in mounts:
- if line.split()[1].startswith('/autofs'):
- continue
- if line.startswith(device):
- print line
- not_mounted = False
- break
- if not_mounted == True:
- break
-
- if not_mounted == True:
- print "Umounted partitions found."
- InfoText = _("umounted partitions found.!\nDo you want to open DeviceManager and set mount point?\n\n(Open 'Menu->Setup->System -> Harddisk -> DeviceManager'\n and press MENU button to deactivate this check.)")
- AddNotificationWithCallback(
- boundFunction(callBackforDeviceManager, session),
- MessageBox, InfoText, timeout = 60, default = False
- )
+ notMountable_dev = ""
+ for blockdev in listdir("/sys/block"):
+ devpath = "/sys/block/" + blockdev
+ dev = int(readFile(devpath + "/dev").split(':')[0])
+ if dev in (7, 31) or blockdev[0:2] != 'sd': # 7: loop, 31 : mtdblock
+ continue
+ partitions = []
+ notMountable_partitions = []
+ for partition in listdir(devpath):
+ if not partition.startswith(blockdev):
+ continue
+ partitions.append(partition)
+ if os.access('/autofs/'+partition,0) is False:
+ notMountable_partitions.append(partition)
+ if len(partitions) == 0 or len(notMountable_partitions) != 0:
+ if notMountable_dev != "":
+ notMountable_dev += ' '
+ notMountable_dev += blockdev
+
+ if notMountable_dev != "":
+# print "Not mountable partitions found."
+ InfoText = _("Not mountable devices found.! (%s)\nDo you want to open DeviceManager and do initialize or format this device?\n\n(Open 'Menu->Setup->System -> Harddisk -> DeviceManager'\n and press MENU button to deactivate this check.)"%notMountable_dev)
+ AddNotificationWithCallback(
+ boundFunction(callBackforDeviceManager, session),
+ MessageBox, InfoText, timeout = 60, default = False
+ )