Fix sorted for devices.

netsetup
Mike Hiretsky 14 years ago
parent 2e97619872
commit 4c2bd780dd

@ -116,7 +116,7 @@ class fillVars(object, glob_attr):
devices = filter( lambda x: not reWrongDevice.search(x),
listdir('/sys/block'))
device_hash = {}
for mapnum,device in enumerate(sorted(devices)):
for mapnum,device in enumerate(sorted(devices,key=self.separateDevice)):
device_hash[device] = {}
device_hash[device]['map'] = mapnum
if device in usbdevices:
@ -253,14 +253,20 @@ class fillVars(object, glob_attr):
disk_hash[dev]['format'] = dictFormatList[dev]
return disk_hash
def separateDevice(self,device):
return map(lambda x: int(x) if x.isdigit() else x,
re.findall('\d+|\D+',device))
def get_os_disk_dev(self):
"""List of available partition devices"""
return sorted(self.Get('os_disk_hash').keys())
return sorted(self.Get('os_disk_hash').keys(),
key=self.separateDevice)
def getAttributeFromHash(self,var,attr):
hash = self.Get(var)
return map(lambda x: hash[x][attr] if attr in hash[x] else "",
sorted(hash.keys()))
sorted(hash.keys(),
key=self.separateDevice))
def get_os_install_disk_id(self):
"""List id for partition after installation"""
@ -315,13 +321,15 @@ class fillVars(object, glob_attr):
else:
return mount_point
return map(lambda x: getMountPoint(x),
sorted(self.Get('os_disk_hash').keys()))
sorted(self.Get('os_disk_hash').keys(),
key=self.separateDevice))
def get_os_disk_mount(self):
"""List mounted points for current operation system"""
disk_hash = self.Get('os_disk_hash')
return map(lambda x: isFstabMount(x) or "",
sorted(self.Get('os_disk_hash').keys()))
sorted(self.Get('os_disk_hash').keys(),
key=self.separateDevice))
def get_os_disk_format(self):
"""List filesystem for partition devices"""
@ -353,7 +361,8 @@ class fillVars(object, glob_attr):
def get_os_device_dev(self):
"""Devices"""
return sorted(self.Get('os_device_hash').keys())
return sorted(self.Get('os_device_hash').keys(),
key=self.separateDevice)
def get_os_device_type(self):
"""Device type (hdd,cdrom,usb-flash)"""
@ -378,7 +387,8 @@ class fillVars(object, glob_attr):
self.Get('os_install_disk_mount'),
self.Get('os_install_disk_format'),
self.Get('os_install_disk_options'))),
lambda x,y: cmp(x[1],y[1]))
lambda x,y: cmp(self.separateDevice(x[1]),
self.separateDevice(y[1])))
if self.Get('os_install_scratch') == "on":
devicesForFstab = filter(lambda x:x[1] != "/", devicesForFstab)

@ -1171,6 +1171,9 @@ class cl_install(color_print, SignalInterrupt):
substitution = lambda data,mp: data
else:
substitution = lambda data,mp: data if mp == '/' else ""
separateDevice = lambda device: map(
lambda x: int(x) if x.isdigit() else x,
re.findall('\d+|\D+',device))
# update variables by new hash
new_mount, new_format, new_isformat, new_options= \
reduce(lambda x,y:[x[0]+[substitution(devMount[y]['mountPoint'],
@ -1181,7 +1184,7 @@ class cl_install(color_print, SignalInterrupt):
devMount[y]['mountPoint'])],
x[3]+[substitution(devMount[y]['options'],
devMount[y]['mountPoint'])]],
sorted(devMount.keys()),[[]]*4)
sorted(devMount.keys(),key=separateDevice),[[]]*4)
map(lambda x:self.clVars.Set(x[0],x[1],True),
(('os_install_disk_mount',new_mount),

Loading…
Cancel
Save