disks: delete existing test file, if necessary

This commit is contained in:
Johannes Keyser 2017-06-05 19:26:01 +02:00 committed by James Valleroy
parent 8ae6fbbd4c
commit 62aa3ce26a
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808

View File

@ -53,6 +53,9 @@ class Disk():
directory = os.path.dirname(os.path.realpath(__file__))
disk_file = os.path.join(directory, 'temp_disk.img')
if os.path.isfile(disk_file):
os.remove(disk_file)
command = 'dd if=/dev/zero of={file} bs=1M count={size}' \
.format(size=self.size, file=disk_file)
subprocess.run(command.split(), stderr=subprocess.DEVNULL, check=True)