summaryrefslogtreecommitdiffstats
path: root/scripts/lib/wic
diff options
context:
space:
mode:
authorEd Bartosh <ed.bartosh@linux.intel.com>2016-04-28 13:58:05 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-05-06 10:31:12 +0100
commit4daf903fb0398ee47825edf7d59d97beded9774f (patch)
treee4c3c54e6334b2c1ae05d3e2b1170a16dd6e3d12 /scripts/lib/wic
parentd03cbac7960c8f39019f2f428647e8100ddc5da0 (diff)
downloadpoky-4daf903fb0398ee47825edf7d59d97beded9774f.tar.gz
wic: get rid of inheritance Disk->DiskImage
There is no need in this inheritance as DiskImage class is used only in one module and no other classes are inherited. (From OE-Core rev: 5af1d9bedc2c961eb91faf80251f24c3df754d76) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/wic')
-rw-r--r--scripts/lib/wic/utils/fs_related.py43
1 files changed, 9 insertions, 34 deletions
diff --git a/scripts/lib/wic/utils/fs_related.py b/scripts/lib/wic/utils/fs_related.py
index 2658dcfc20..22aa294fa0 100644
--- a/scripts/lib/wic/utils/fs_related.py
+++ b/scripts/lib/wic/utils/fs_related.py
@@ -32,47 +32,22 @@ def makedirs(dirname):
32 if err.errno != errno.EEXIST: 32 if err.errno != errno.EEXIST:
33 raise 33 raise
34 34
35class Disk: 35class DiskImage():
36 """
37 Generic base object for a disk.
38 """
39 def __init__(self, size, device=None):
40 self._device = device
41 self._size = size
42
43 def create(self):
44 pass
45
46 def cleanup(self):
47 pass
48
49 def get_device(self):
50 return self._device
51 def set_device(self, path):
52 self._device = path
53 device = property(get_device, set_device)
54
55 def get_size(self):
56 return self._size
57 size = property(get_size)
58
59
60class DiskImage(Disk):
61 """ 36 """
62 A Disk backed by a file. 37 A Disk backed by a file.
63 """ 38 """
64 def __init__(self, image_file, size): 39 def __init__(self, device, size):
65 Disk.__init__(self, size) 40 self.size = size
66 self.image_file = image_file 41 self.device = device
42 self.created = False
67 43
68 def exists(self): 44 def exists(self):
69 return os.path.exists(self.image_file) 45 return os.path.exists(self.device)
70 46
71 def create(self): 47 def create(self):
72 if self.device is not None: 48 if self.created:
73 return 49 return
74 # create sparse disk image 50 # create sparse disk image
75 cmd = "truncate %s -s %s" % (self.image_file, self.size) 51 cmd = "truncate %s -s %s" % (self.device, self.size)
76 exec_cmd(cmd) 52 exec_cmd(cmd)
77 53 self.created = True
78 self.device = self.image_file