|
Lines 1-5
Link Here
|
| 1 |
import commands, string, re, os, parted |
1 |
import commands, string, os, parted |
| 2 |
from decimal import Decimal |
2 |
from decimal import Decimal |
|
|
3 |
from GLIUtility import * |
| 3 |
|
4 |
|
| 4 |
MEGABYTE = 1024 * 1024 |
5 |
MEGABYTE = 1024 * 1024 |
| 5 |
|
6 |
|
|
Lines 315-321
Link Here
|
| 315 |
parts.sort() |
316 |
parts.sort() |
| 316 |
partlist = [] |
317 |
partlist = [] |
| 317 |
tmppart = None |
318 |
tmppart = None |
| 318 |
tmppart_log = None |
|
|
| 319 |
for part in parts: |
319 |
for part in parts: |
| 320 |
if archinfo[self._arch]['extended'] and part > Decimal("4.1"): break |
320 |
if archinfo[self._arch]['extended'] and part > Decimal("4.1"): break |
| 321 |
tmppart = self._partitions[part] |
321 |
tmppart = self._partitions[part] |
|
Lines 323-329
Link Here
|
| 323 |
if tmppart.is_extended(): |
323 |
if tmppart.is_extended(): |
| 324 |
for part_log in parts: |
324 |
for part_log in parts: |
| 325 |
if part_log < Decimal("4.9"): continue |
325 |
if part_log < Decimal("4.9"): continue |
| 326 |
tmppart_log = self._partitions[part_log] |
|
|
| 327 |
partlist.append(part_log) |
326 |
partlist.append(part_log) |
| 328 |
return partlist |
327 |
return partlist |
| 329 |
|
328 |
|
|
Lines 390-396
Link Here
|
| 390 |
# @param message Error message |
389 |
# @param message Error message |
| 391 |
def _error(self, message): |
390 |
def _error(self, message): |
| 392 |
"Raises an exception" |
391 |
"Raises an exception" |
| 393 |
raise "DeviceObjectError", message |
392 |
raise GLIException("DeviceObjectError", 'fatal', 'Device', message) |
| 394 |
|
393 |
|
| 395 |
## |
394 |
## |
| 396 |
# Utility function for running a command and returning it's output as a list |
395 |
# Utility function for running a command and returning it's output as a list |
|
Lines 470-483
Link Here
|
| 470 |
if type == "ntfs": |
469 |
if type == "ntfs": |
| 471 |
min_bytes = int(commands.getoutput("ntfsresize -f --info " + dev_node + " | grep -e '^You might resize' | sed -e 's/You might resize at //' -e 's/ bytes or .\+//'")) |
470 |
min_bytes = int(commands.getoutput("ntfsresize -f --info " + dev_node + " | grep -e '^You might resize' | sed -e 's/You might resize at //' -e 's/ bytes or .\+//'")) |
| 472 |
self._min_mb_for_resize = int(min_bytes / MEGABYTE) + 1 |
471 |
self._min_mb_for_resize = int(min_bytes / MEGABYTE) + 1 |
| 473 |
self._resizeable == True |
472 |
self._resizeable = True |
| 474 |
elif type == "ext2" or type == "ext3": |
473 |
elif type == "ext2" or type == "ext3": |
| 475 |
block_size = string.strip(commands.getoutput("dumpe2fs -h " + dev_node + r" 2>&1 | grep -e '^Block size:' | sed -e 's/^Block size:\s\+//'")) |
474 |
block_size = string.strip(commands.getoutput("dumpe2fs -h " + dev_node + r" 2>&1 | grep -e '^Block size:' | sed -e 's/^Block size:\s\+//'")) |
| 476 |
free_blocks = string.strip(commands.getoutput("dumpe2fs -h " + dev_node + r" 2>&1 | grep -e '^Free blocks:' | sed -e 's/^Free blocks:\s\+//'")) |
475 |
free_blocks = string.strip(commands.getoutput("dumpe2fs -h " + dev_node + r" 2>&1 | grep -e '^Free blocks:' | sed -e 's/^Free blocks:\s\+//'")) |
| 477 |
free_bytes = int(block_size * free_blocks) |
476 |
free_bytes = int(block_size * free_blocks) |
| 478 |
# can't hurt to pad (the +50) it a bit since this is really just a guess |
477 |
# can't hurt to pad (the +50) it a bit since this is really just a guess |
| 479 |
self._min_mb_for_resize = self._mb - int(free_bytes / MEGABYTE) + 50 |
478 |
self._min_mb_for_resize = self._mb - int(free_bytes / MEGABYTE) + 50 |
| 480 |
self._resizeable == True |
479 |
self._resizeable = True |
| 481 |
else: |
480 |
else: |
| 482 |
parted_part = self._device._parted_disk.get_partition(int(self._minor)) |
481 |
parted_part = self._device._parted_disk.get_partition(int(self._minor)) |
| 483 |
try: |
482 |
try: |
|
Lines 517-523
Link Here
|
| 517 |
if not self.is_extended(): |
516 |
if not self.is_extended(): |
| 518 |
return None |
517 |
return None |
| 519 |
logicals = [] |
518 |
logicals = [] |
| 520 |
start = self._start |
|
|
| 521 |
parts = self._device._partitions.keys() |
519 |
parts = self._device._partitions.keys() |
| 522 |
parts.sort() |
520 |
parts.sort() |
| 523 |
for part in parts: |
521 |
for part in parts: |
|
Lines 702-708
Link Here
|
| 702 |
# Utility function to raise an exception |
700 |
# Utility function to raise an exception |
| 703 |
# @param message Error message |
701 |
# @param message Error message |
| 704 |
def _error(self, message): |
702 |
def _error(self, message): |
| 705 |
raise "PartitionObjectError", message |
703 |
raise GLIException("PartitionObjectError", 'fatal', 'Partition', message) |
| 706 |
|
704 |
|
| 707 |
## |
705 |
## |
| 708 |
# Returns a list of detected partitionable devices |
706 |
# Returns a list of detected partitionable devices |
|
Lines 740-747
Link Here
|
| 740 |
if not os.path.exists(device): |
738 |
if not os.path.exists(device): |
| 741 |
device = None |
739 |
device = None |
| 742 |
for path, dirs, files in os.walk("/dev"): |
740 |
for path, dirs, files in os.walk("/dev"): |
| 743 |
for file in files: |
741 |
for d_file in files: |
| 744 |
full_file = os.path.join(path, file) |
742 |
full_file = os.path.join(path, d_file) |
| 745 |
if not os.path.exists(full_file): |
743 |
if not os.path.exists(full_file): |
| 746 |
continue |
744 |
continue |
| 747 |
statres = os.stat(full_file) |
745 |
statres = os.stat(full_file) |