[virt-tools-list] [RFC PATCH 1/2] virt-manager: prefer os.makedirs to os.mkdir when creating cache dir

Giuseppe Scrivano gscrivan at redhat.com
Fri Nov 1 16:49:20 UTC 2013


Ensure the parent directories exist when attempting to create the
cache directory.

Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1016435

Signed-off-by: Giuseppe Scrivano <gscrivan at redhat.com>
---
 virtManager/connection.py | 2 +-
 virtManager/domain.py     | 2 +-
 virtinst/cli.py           | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/virtManager/connection.py b/virtManager/connection.py
index a6eacae..313f680 100644
--- a/virtManager/connection.py
+++ b/virtManager/connection.py
@@ -316,7 +316,7 @@ class vmmConnection(vmmGObject):
         uri = self.get_uri().replace("/", "_")
         ret = os.path.join(util.get_cache_dir(), uri)
         if not os.path.exists(ret):
-            os.mkdir(ret, 755)
+            os.makedirs(ret, 0755)
         return ret
 
     def get_default_storage_format(self):
diff --git a/virtManager/domain.py b/virtManager/domain.py
index d099176..b8324d5 100644
--- a/virtManager/domain.py
+++ b/virtManager/domain.py
@@ -1649,7 +1649,7 @@ class vmmDomain(vmmLibvirtObject):
     def get_cache_dir(self):
         ret = os.path.join(self.conn.get_cache_dir(), self.get_uuid())
         if not os.path.exists(ret):
-            os.mkdir(ret, 0755)
+            os.makedirs(ret, 0755)
         return ret
 
 
diff --git a/virtinst/cli.py b/virtinst/cli.py
index 3776b07..a2add57 100644
--- a/virtinst/cli.py
+++ b/virtinst/cli.py
@@ -155,7 +155,7 @@ def setupLogging(appname, debug_stdout, do_quiet, cli_app=True):
             raise RuntimeError("No write access to directory %s" % vi_dir)
 
         try:
-            os.mkdir(vi_dir, 0751)
+            os.makedirs(vi_dir, 0751)
         except IOError, e:
             raise RuntimeError("Could not create directory %s: %s" %
                                (vi_dir, e))
-- 
1.8.3.1




More information about the virt-tools-list mailing list