Revision 0ae01e26 image_creator/disk.py

b/image_creator/disk.py
1 1
#!/usr/bin/env python
2 2

  
3 3
from image_creator.util import get_command
4
from image_creator import FatalError
4 5
from clint.textui import progress
5 6

  
6 7
import stat
......
109 110

  
110 111
def progress_generator(label=''):
111 112
    position = 0;
112
    for i in progress.bar(range(100),''):
113
    for i in progress.bar(range(100),label):
113 114
        if i < position:
114 115
            continue
115 116
        position = yield
......
139 140
    def enable(self):
140 141
        """Enable a newly created DiskDevice"""
141 142

  
142
        self.progressbar = progress_generator()
143
        self.progressbar = progress_generator("VM lauch: ")
143 144
        self.progressbar.next()
144 145
        eh = self.g.set_event_callback(self.progress_callback, guestfs.EVENT_PROGRESS)
145 146
        self.g.launch()
......
151 152
        
152 153
        roots = self.g.inspect_os()
153 154
        if len(roots) == 0:
154
            raise DiskError("No operating system found")
155
            raise FatalError("No operating system found")
155 156
        if len(roots) > 1:
156
            raise DiskError("Multiple operating systems found")
157
            raise FatalError("Multiple operating systems found")
157 158

  
158 159
        self.root = roots[0]
159 160
        self.ostype = self.g.inspect_get_type(self.root)
......
174 175
        total = array[3]
175 176

  
176 177
        assert self.progress_bar is not None
177

  
178
        print 'posisition/total: %s/%s' % (position, total)
178 179
        self.progress_bar.send((position * 100)//total)
179 180

  
180 181
        if position == total:
......
214 215
        dev = self.g.part_to_dev(self.root)
215 216
        parttype = self.g.part_get_parttype(dev)
216 217
        if parttype != 'msdos':
217
            raise DiskError("You have a %s partition table. "
218
            raise FatalError("You have a %s partition table. "
218 219
                "Only msdos partitions are supported" % parttype)
219 220

  
220 221
        last_partition = self.g.part_list(dev)[-1]
221 222

  
222 223
        if last_partition['part_num'] > 4:
223
            raise DiskError("This disk contains logical partitions. "
224
            raise FatalError("This disk contains logical partitions. "
224 225
                "Only primary partitions are supported.")
225 226

  
226 227
        part_dev = "%s%d" % (dev, last_partition['part_num'])

Also available in: Unified diff