/[gli]/trunk/src/GLIStorageDevice.py
Gentoo

Diff of /trunk/src/GLIStorageDevice.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 530 Revision 535
1import commands, string, re, os, parted 1import commands, string, os, parted
2#from decimal import Decimal
3 2
4MEGABYTE = 1024 * 1024 3MEGABYTE = 1024 * 1024
5 4
6archinfo = { 'sparc': { 'fixedparts': [ { 'minor': 3, 'type': "wholedisk" } ], 'disklabel': 'sun', 'extended': False }, 5archinfo = { 'sparc': { 'fixedparts': [ { 'minor': 3, 'type': "wholedisk" } ], 'disklabel': 'sun', 'extended': False },
7 'hppa': { 'fixedparts': [ { 'minor': 1, 'type': "boot" } ], 'disklabel': 'msdos', 'extended': False }, 6 'hppa': { 'fixedparts': [ { 'minor': 1, 'type': "boot" } ], 'disklabel': 'msdos', 'extended': False },
320 tmppart = self._partitions[part] 319 tmppart = self._partitions[part]
321 partlist.append(part) 320 partlist.append(part)
322 if tmppart.is_extended(): 321 if tmppart.is_extended():
323 for part_log in parts: 322 for part_log in parts:
324 if part_log < 4.9: continue 323 if part_log < 4.9: continue
325 tmppart_log = self._partitions[part_log]
326 partlist.append(part_log) 324 partlist.append(part_log)
327 return partlist 325 return partlist
328 326
329 ## 327 ##
330 # Returns partition info in a format suitable for passing to install_profile.set_partition_tables() 328 # Returns partition info in a format suitable for passing to install_profile.set_partition_tables()
387 ## 385 ##
388 # Utility function for raising an exception 386 # Utility function for raising an exception
389 # @param message Error message 387 # @param message Error message
390 def _error(self, message): 388 def _error(self, message):
391 "Raises an exception" 389 "Raises an exception"
392 raise "DeviceObjectError", message 390 raise GLIException("DeviceObjectError", 'fatal', 'Device', message)
393 391
394 ## 392 ##
395 # Utility function for running a command and returning it's output as a list 393 # Utility function for running a command and returning it's output as a list
396 # @param cmd Command to run 394 # @param cmd Command to run
397 def _run(self, cmd): 395 def _run(self, cmd):
514 # Returns a list of logical partitions if this is an extended partition 512 # Returns a list of logical partitions if this is an extended partition
515 def get_logicals(self): 513 def get_logicals(self):
516 if not self.is_extended(): 514 if not self.is_extended():
517 return None 515 return None
518 logicals = [] 516 logicals = []
519 start = self._start
520 parts = self._device._partitions.keys() 517 parts = self._device._partitions.keys()
521 parts.sort() 518 parts.sort()
522 for part in parts: 519 for part in parts:
523 if part < 5: continue 520 if part < 5: continue
524 logicals.append(part) 521 logicals.append(part)
699 696
700 ## 697 ##
701 # Utility function to raise an exception 698 # Utility function to raise an exception
702 # @param message Error message 699 # @param message Error message
703 def _error(self, message): 700 def _error(self, message):
704 raise "PartitionObjectError", message 701 raise GLIException("PartitionObjectError", 'fatal', 'Partition', message)
705 702
706## 703##
707# Returns a list of detected partitionable devices 704# Returns a list of detected partitionable devices
708def detect_devices(): 705def detect_devices():
709 devices = [] 706 devices = []
737 # all the devices in /dev to try and find a 734 # all the devices in /dev to try and find a
738 # devices with the same major and minor 735 # devices with the same major and minor
739 if not os.path.exists(device): 736 if not os.path.exists(device):
740 device = None 737 device = None
741 for path, dirs, files in os.walk("/dev"): 738 for path, dirs, files in os.walk("/dev"):
742 for file in files: 739 for d_file in files:
743 full_file = os.path.join(path, file) 740 full_file = os.path.join(path, d_file)
744 if not os.path.exists(full_file): 741 if not os.path.exists(full_file):
745 continue 742 continue
746 statres = os.stat(full_file) 743 statres = os.stat(full_file)
747 fmaj = os.major(statres.st_rdev) 744 fmaj = os.major(statres.st_rdev)
748 fmin = os.minor(statres.st_rdev) 745 fmin = os.minor(statres.st_rdev)

Legend:
Removed from v.530  
changed lines
  Added in v.535

  ViewVC Help
Powered by ViewVC 1.1.20