def create(self, intf=None): """ Create the device. """ if self.exists: raise PartitionError("device already exists", self.name) w = None if intf: w = intf.progressWindow( _("General", "Creating device %s") % (self.path, )) try: self.createParents() self.setupParents() self.disk.format.addPartition(self.partedPartition) try: self.disk.format.commit() except DiskLabelCommitError, msg: part = self.disk.format.partedDisk.getPartitionByPath( self.path) self.disk.format.removePartition(part) raise PartitionError, msg if not self.isExtended: # Ensure old metadata which lived in freespace so did not get # explictly destroyed by a destroyformat action gets wiped Format(device=self.path, exists=True).destroy()