FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Ubuntu > Ubuntu Masters Of The Universe

 
 
LinkBack Thread Tools
 
Old 02-11-2009, 11:53 PM
David Cantrell
 
Default Remove partedUtils.get_partition_drive()

This function is just returns the device name without the /dev/
at the beginning. No need for a function.
---
autopart.py | 2 +-
fsset.py | 2 +-
iscsi.py | 2 +-
partIntfHelpers.py | 4 ++--
partedUtils.py | 4 ----
partitions.py | 4 ++--
6 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/autopart.py b/autopart.py
index b1c7644..d6fda51 100644
--- a/autopart.py
+++ b/autopart.py
@@ -1160,7 +1160,7 @@ def doClearPartAction(anaconda, partitions, diskset):
partitions.deleteDependentRequests(old)
partitions.removeRequest(old)

- drive = partedUtils.get_partition_drive(part)
+ drive = part.geometry.device.path[5:]
delete = partRequests.DeleteSpec(drive, part.geom.start,
part.geom.end)
partitions.addDelete(delete)
diff --git a/fsset.py b/fsset.py
index 89f099b..18b8fe2 100644
--- a/fsset.py
+++ b/fsset.py
@@ -1647,7 +1647,7 @@ MAILADDR root

if dev.getName() != "RAIDDevice":
part = partedUtils.get_partition_by_name(diskset.disks, bootDev)
- drive = partedUtils.get_partition_drive(part)
+ drive = part.geometry.device.path[5:]

# on EFI systems, *only* /boot/efi should be marked bootable
# similarly, on pseries, we really only want the PReP partition
diff --git a/iscsi.py b/iscsi.py
index a4d301e..7fa8d40 100644
--- a/iscsi.py
+++ b/iscsi.py
@@ -583,7 +583,7 @@ class iscsi(object):
req.device)
if not part:
continue
- drive = partedUtils.get_partition_drive(part)
+ drive = part.geometry.device.path[5:]
if drive not in root_drives:
root_drives.append(drive)

diff --git a/partIntfHelpers.py b/partIntfHelpers.py
index d57b208..d133992 100644
--- a/partIntfHelpers.py
+++ b/partIntfHelpers.py
@@ -203,7 +203,7 @@ def doDeletePartitionByRequest(intf, requestlist, partition,
if request.getPreExisting():
if isinstance(request, partRequests.PartitionSpec):
# get the drive
- drive = partedUtils.get_partition_drive(partition)
+ drive = partition.geometry.device.path[5:]

if partition.type & parted.PARTITION_EXTENDED:
requestlist.deleteAllLogicalPartitions(partition)
@@ -347,7 +347,7 @@ def doEditPartitionByRequest(intf, requestlist, part):
part.geom.start),
end = partedUtils.end_sector_to_cyl(part.geom.dev,
part.geom.end),
- drive = [ partedUtils.get_partition_drive(part) ])
+ drive = [ part.geometry.device.path[5:] ])

return ("NEW", request)
elif part.type & parted.PARTITION_EXTENDED:
diff --git a/partedUtils.py b/partedUtils.py
index c170368..0a109a4 100644
--- a/partedUtils.py
+++ b/partedUtils.py
@@ -208,10 +208,6 @@ def set_partition_file_system_type(part, fstype):
print("Failed to set partition type to ",fstype.getName())
pass

-def get_partition_drive(partition):
- """Return the device name for disk that PedPartition partition is on."""
- return "%s" %(partition.geom.dev.path[5:])
-
def get_max_logical_partitions(disk):
if not disk.type.check_feature(parted.DISK_TYPE_EXTENDED) :
return 0
diff --git a/partitions.py b/partitions.py
index fc4c554..b98a374 100644
--- a/partitions.py
+++ b/partitions.py
@@ -420,7 +420,7 @@ class Partitions:
start = part.geom.start
end = part.geom.end
size = partedUtils.getPartSizeMB(part)
- drive = partedUtils.get_partition_drive(part)
+ drive = part.geometry.device.path[5:]

spec = partRequests.PreexistingPartitionSpec(ptype,
size = size,
@@ -1698,7 +1698,7 @@ class Partitions:
request = self.getRequestByDeviceName(partName)
self.removeRequest(request)
if request.preexist:
- drive = partedUtils.get_partition_drive(partition)
+ drive = partition.geometry.device.path[5:]
delete = partRequests.DeleteSpec(drive, partition.geom.start,
partition.geom.end)
self.addDelete(delete)
--
1.6.1.3

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 02-12-2009, 01:05 AM
Jeremy Katz
 
Default Remove partedUtils.get_partition_drive()

On Wednesday, February 11 2009, David Cantrell said:
> This function is just returns the device name without the /dev/
> at the beginning. No need for a function.

While technically there's no need for a function, using one keeps us
from scattering information on the exact object structure everywhere.
Which means that if it changes, there's less places to have to adapt

Yes, we're bad about it in other places but we should probably make a
concerted effort not to be making direct, deep accesses into objects as they
always seem to come back and bite us eventually :/

Jeremy

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 02-12-2009, 01:28 AM
David Cantrell
 
Default Remove partedUtils.get_partition_drive()

Jeremy Katz wrote:

On Wednesday, February 11 2009, David Cantrell said:

This function is just returns the device name without the /dev/
at the beginning. No need for a function.


While technically there's no need for a function, using one keeps us
from scattering information on the exact object structure everywhere.
Which means that if it changes, there's less places to have to adapt


Yes, we're bad about it in other places but we should probably make a
concerted effort not to be making direct, deep accesses into objects as they
always seem to come back and bite us eventually :/


Not a problem, I'll just exclude this one when I merge.

Looking back at this particular patch, I think this was when I was going
through partedUtils.py trying to get rid of unnecessary things and/or
move things ot pyparted.


--
David Cantrell <dcantrell@redhat.com>
Red Hat / Honolulu, HI

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 02-12-2009, 04:16 AM
David Lehman
 
Default Remove partedUtils.get_partition_drive()

On Wed, 2009-02-11 at 14:53 -1000, David Cantrell wrote:
> This function is just returns the device name without the /dev/
> at the beginning. No need for a function.
> ---
> diff --git a/autopart.py b/autopart.py
> index b1c7644..d6fda51 100644
> --- a/autopart.py
> +++ b/autopart.py
> @@ -1160,7 +1160,7 @@ def doClearPartAction(anaconda, partitions, diskset):
> partitions.deleteDependentRequests(old)
> partitions.removeRequest(old)
>
> - drive = partedUtils.get_partition_drive(part)
> + drive = part.geometry.device.path[5:]

We could improve readability by using os.path.basename instead of the
slice. The same is true throughout the patch.


_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 02-12-2009, 04:36 AM
David Cantrell
 
Default Remove partedUtils.get_partition_drive()

David Lehman wrote:

On Wed, 2009-02-11 at 14:53 -1000, David Cantrell wrote:

This function is just returns the device name without the /dev/
at the beginning. No need for a function.
---
diff --git a/autopart.py b/autopart.py
index b1c7644..d6fda51 100644
--- a/autopart.py
+++ b/autopart.py
@@ -1160,7 +1160,7 @@ def doClearPartAction(anaconda, partitions, diskset):
partitions.deleteDependentRequests(old)
partitions.removeRequest(old)

- drive = partedUtils.get_partition_drive(part)

+ drive = part.geometry.device.path[5:]


We could improve readability by using os.path.basename instead of the
slice. The same is true throughout the patch.


Good point, I'll change it in get_partition_name() and post a new patch.

--
David Cantrell <dcantrell@redhat.com>
Red Hat / Honolulu, HI

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 02-12-2009, 07:12 PM
David Cantrell
 
Default Remove partedUtils.get_partition_drive()

David Cantrell wrote:

David Lehman wrote:

On Wed, 2009-02-11 at 14:53 -1000, David Cantrell wrote:

This function is just returns the device name without the /dev/
at the beginning. No need for a function.
---
diff --git a/autopart.py b/autopart.py
index b1c7644..d6fda51 100644
--- a/autopart.py
+++ b/autopart.py
@@ -1160,7 +1160,7 @@ def doClearPartAction(anaconda, partitions,
diskset):

partitions.deleteDependentRequests(old)
partitions.removeRequest(old)

- drive = partedUtils.get_partition_drive(part)

+ drive = part.geometry.device.path[5:]


We could improve readability by using os.path.basename instead of the
slice. The same is true throughout the patch.


Good point, I'll change it in get_partition_name() and post a new patch.



New patch attached.

--
David Cantrell <dcantrell@redhat.com>
Red Hat / Honolulu, HI
>From d754b55a984e7e311cbe49ee4d54df178d7bd61c Mon Sep 17 00:00:00 2001
From: David Cantrell <dcantrell@redhat.com>
Date: Thu, 12 Feb 2009 09:00:28 -1000
Subject: [PATCH 03/47] Use os.path.basename in partedUtils.get_partition_drive()

Use os.path.basename rather than slicing the string.
---
partedUtils.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/partedUtils.py b/partedUtils.py
index c170368..f7dab92 100644
--- a/partedUtils.py
+++ b/partedUtils.py
@@ -210,7 +210,7 @@ def set_partition_file_system_type(part, fstype):

def get_partition_drive(partition):
"""Return the device name for disk that PedPartition partition is on."""
- return "%s" %(partition.geom.dev.path[5:])
+ return os.path.basename(partition.geom.dev.path)

def get_max_logical_partitions(disk):
if not disk.type.check_feature(parted.DISK_TYPE_EXTENDED) :
--
1.6.1.3

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 02-12-2009, 07:24 PM
Chris Lumens
 
Default Remove partedUtils.get_partition_drive()

> >From d754b55a984e7e311cbe49ee4d54df178d7bd61c Mon Sep 17 00:00:00 2001
> From: David Cantrell <dcantrell@redhat.com>
> Date: Thu, 12 Feb 2009 09:00:28 -1000
> Subject: [PATCH 03/47] Use os.path.basename in partedUtils.get_partition_drive()
>
> Use os.path.basename rather than slicing the string.
> ---
> partedUtils.py | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/partedUtils.py b/partedUtils.py
> index c170368..f7dab92 100644
> --- a/partedUtils.py
> +++ b/partedUtils.py
> @@ -210,7 +210,7 @@ def set_partition_file_system_type(part, fstype):
>
> def get_partition_drive(partition):
> """Return the device name for disk that PedPartition partition is on."""
> - return "%s" %(partition.geom.dev.path[5:])
> + return os.path.basename(partition.geom.dev.path)
>
> def get_max_logical_partitions(disk):
> if not disk.type.check_feature(parted.DISK_TYPE_EXTENDED) :

What happens when partition.geom.dev.path is /dev/cciss/wherever?

- Chris

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 02-12-2009, 07:37 PM
David Cantrell
 
Default Remove partedUtils.get_partition_drive()

Chris Lumens wrote:

>From d754b55a984e7e311cbe49ee4d54df178d7bd61c Mon Sep 17 00:00:00 2001
From: David Cantrell <dcantrell@redhat.com>
Date: Thu, 12 Feb 2009 09:00:28 -1000
Subject: [PATCH 03/47] Use os.path.basename in partedUtils.get_partition_drive()

Use os.path.basename rather than slicing the string.
---
partedUtils.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/partedUtils.py b/partedUtils.py
index c170368..f7dab92 100644
--- a/partedUtils.py
+++ b/partedUtils.py
@@ -210,7 +210,7 @@ def set_partition_file_system_type(part, fstype):

def get_partition_drive(partition):

"""Return the device name for disk that PedPartition partition is on."""
- return "%s" %(partition.geom.dev.path[5:])
+ return os.path.basename(partition.geom.dev.path)

def get_max_logical_partitions(disk):

if not disk.type.check_feature(parted.DISK_TYPE_EXTENDED) :


What happens when partition.geom.dev.path is /dev/cciss/wherever?


Oh piss, right, leave it to Compaq to make things not fun.

--
David Cantrell <dcantrell@redhat.com>
Red Hat / Honolulu, HI

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 02-12-2009, 08:12 PM
David Cantrell
 
Default Remove partedUtils.get_partition_drive()

David Cantrell wrote:

Chris Lumens wrote:

>From d754b55a984e7e311cbe49ee4d54df178d7bd61c Mon Sep 17 00:00:00 2001
From: David Cantrell <dcantrell@redhat.com>
Date: Thu, 12 Feb 2009 09:00:28 -1000
Subject: [PATCH 03/47] Use os.path.basename in
partedUtils.get_partition_drive()


Use os.path.basename rather than slicing the string.
---
partedUtils.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/partedUtils.py b/partedUtils.py
index c170368..f7dab92 100644
--- a/partedUtils.py
+++ b/partedUtils.py
@@ -210,7 +210,7 @@ def set_partition_file_system_type(part, fstype):

def get_partition_drive(partition):
"""Return the device name for disk that PedPartition partition
is on."""

- return "%s" %(partition.geom.dev.path[5:])
+ return os.path.basename(partition.geom.dev.path)

def get_max_logical_partitions(disk):

if not disk.type.check_feature(parted.DISK_TYPE_EXTENDED) :


What happens when partition.geom.dev.path is /dev/cciss/wherever?


Oh piss, right, leave it to Compaq to make things not fun.



Taking get_partition_drive() to:

return partition.geometry.device.path[5:]

--
David Cantrell <dcantrell@redhat.com>
Red Hat / Honolulu, HI

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 

Thread Tools




All times are GMT. The time now is 06:50 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org