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 > Redhat > Fedora Development

 
 
LinkBack Thread Tools
 
Old 11-30-2010, 07:09 PM
David Lehman
 
Default Make FileDevice.path more consistent.

Ensure that FileDevice is instantiated with a fully qualified path and
that a FileDevice with no parents doesn't have extra slashes in its
path.
---
pyanaconda/storage/devices.py | 16 ++++++++++------
1 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/pyanaconda/storage/devices.py b/pyanaconda/storage/devices.py
index 85bfa1e..86c40af 100644
--- a/pyanaconda/storage/devices.py
+++ b/pyanaconda/storage/devices.py
@@ -3454,6 +3454,9 @@ class FileDevice(StorageDevice):
parents -- a list of required devices (Device instances)
exists -- indicates whether this is an existing device
"""
+ if not path.startswith("/"):
+ raise ValueError("FileDevice requires an absolute path")
+
StorageDevice.__init__(self, path, format=format, size=size,
exists=exists, parents=parents)

@@ -3467,25 +3470,26 @@ class FileDevice(StorageDevice):

@property
def path(self):
- path = self.name
root = ""
try:
status = self.parents[0].format.status
except (AttributeError, IndexError):
- status = False
-
- if status:
+ # either this device has no parents or something is wrong with
+ # the first one
+ status = (os.access(self.name, os.R_OK) and
+ self.parents in ([], None))
+ else:
# this is the actual active mountpoint
root = self.parents[0].format._mountpoint
# trim the mountpoint down to the chroot since we already have
# the otherwise fully-qualified path
mountpoint = self.parents[0].format.mountpoint
- if mountpoint.endswith("/"):
+ while mountpoint.endswith("/"):
mountpoint = mountpoint[:-1]
if mountpoint:
root = root[:-len(mountpoint)]

- return os.path.normpath("%s/%s" % (root, path))
+ return os.path.normpath("%s%s" % (root, self.name))

def setup(self, intf=None, orig=False):
StorageDevice.setup(self, orig=orig)
--
1.7.3.2

_______________________________________________
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 07:50 PM.

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