@@ -77,8 +77,6 @@ class CentosVM(basevm.BaseVM):
self.ssh_root_check("systemctl enable docker")
self.ssh_root("poweroff")
self.wait()
- if os.path.exists(img):
- os.remove(img)
os.rename(img_tmp, img)
return 0
@@ -36,8 +36,6 @@ class FreeBSDVM(basevm.BaseVM):
sys.stderr.write("Extracting the image...\n")
subprocess.check_call(["ln", "-f", cimg, img_tmp_xz])
subprocess.check_call(["xz", "--keep", "-dvf", img_tmp_xz])
- if os.path.exists(img):
- os.remove(img)
os.rename(img_tmp, img)
if __name__ == "__main__":
@@ -36,8 +36,6 @@ class NetBSDVM(basevm.BaseVM):
sys.stderr.write("Extracting the image...\n")
subprocess.check_call(["ln", "-f", cimg, img_tmp_xz])
subprocess.check_call(["xz", "--keep", "-dvf", img_tmp_xz])
- if os.path.exists(img):
- os.remove(img)
os.rename(img_tmp, img)
if __name__ == "__main__":
@@ -38,8 +38,6 @@ class OpenBSDVM(basevm.BaseVM):
sys.stderr.write("Extracting the image...\n")
subprocess.check_call(["ln", "-f", cimg, img_tmp_xz])
subprocess.check_call(["xz", "--keep", "-dvf", img_tmp_xz])
- if os.path.exists(img):
- os.remove(img)
os.rename(img_tmp, img)
if __name__ == "__main__":
@@ -80,8 +80,6 @@ class UbuntuX86VM(basevm.BaseVM):
self.ssh_root_check("apt-get install -y libfdt-dev flex bison")
self.ssh_root("poweroff")
self.wait()
- if os.path.exists(img):
- os.remove(img)
os.rename(img_tmp, img)
return 0
Python's os.rename() will silently replace an existing file, so there's no need for the extra check and removal. Reference: https://docs.python.org/3/library/os.html#os.rename Signed-off-by: Cleber Rosa <crosa@redhat.com> --- tests/vm/centos | 2 -- tests/vm/freebsd | 2 -- tests/vm/netbsd | 2 -- tests/vm/openbsd | 2 -- tests/vm/ubuntu.i386 | 2 -- 5 files changed, 10 deletions(-)