1. VectorLinux Core
  2. vinstall

Commits

Rodrigo Bistolfi  committed f0c06a0

Test for parted.Disk() instance beofre setting flags

  • Participants
  • Parent commits 54bda36
  • Branches master

Comments (0)

Files changed (1)

File vinstall/backend/partitioning.py

View file
  • Ignore whitespace
         self.disk = disk
         self.last_used_sector = 2048
         self.dirty = False
-        self.disk._disk.setFlag(1)
+        if self.disk._disk:
+            self.disk._disk.setFlag(1)
         LOG.debug("Partitioning %s" % disk)
 
     def has_partition_table(self):
         """Find if there is a partition table. PTs start at position 0x1BE and
         contains 4 entries of 16 bytes, one for each partition
-        
+
         """
         with open(self.disk._device.path) as f:
             f.seek(0x1BE)
 
     def partitions_number(self):
         """Return the number of partitions in disk
-        
+
         """
         return len(self.disk._disk.partitions)
 
     def add_partition(self,  size=0, units='MB'):
-        """Add a partition to the disk.  
+        """Add a partition to the disk.
         Args:  size = partition size
                units = partition units (MB, GB, MiB, GiB), (defaults to MiB)
 
                     start_marker = max(i.start, 2048)
 		    self.dirty = True
                 else:
-                    start_marker = self.last_used_sector + 1	
+                    start_marker = self.last_used_sector + 1
                 LOG.debug("Start: %s" % start_marker)
                 break
         else:
         """Finalize changes to the disk.  This needs to be called
         after creating partitions or deleting partitions to make sure
         the changes are actually written to the disk.
-        
+
         """
         LOG.debug("Commiting changes")
         self.disk._disk.commit()
         p.add_partition(size=5)
         p.write_changes()
         self.assertTrue(p.has_partition_table())
-    
+
     def test_delete_all_partitions(self):
         device = parted.Device(self.path)
         disk = media.Disk()