]> git.llucax.com Git - software/pymin.git/commitdiff
Use os.makedirs to create directories instead of exec mkdir (refs #22).
authorLeandro Lucarella <llucax@gmail.com>
Mon, 12 May 2008 15:29:53 +0000 (12:29 -0300)
committerLeandro Lucarella <llucax@gmail.com>
Mon, 12 May 2008 15:29:53 +0000 (12:29 -0300)
Also check for errors creating the new diretory.

pymin/services/vpn/__init__.py

index 3b5046efbf5626cd1af7dccaf64a9d0ab936fd4d..fa5d5ce485bf011b31c49571e182a5db3a8f63b9 100644 (file)
@@ -1,6 +1,7 @@
 # vim: set encoding=utf-8 et sw=4 sts=4 :
 
 import os
+import errno
 import signal
 from os import path
 import logging ; log = logging.getLogger('pymin.services.vpn')
@@ -144,9 +145,14 @@ class VpnHandler(Restorable, ConfigWriter,
                                     path.join(self._config_writer_cfg_dir,
                                                 v.vpn_src ,'hosts'))
                         #first create the directory for the vpn
-                        call(('mkdir', '-p', path.join(
-                                            self._config_writer_cfg_dir,
-                                            v.vpn_src, 'hosts')))
+                        try:
+                            os.makedirs(path.join(self._config_writer_cfg_dir,
+                                                  v.vpn_src, 'hosts'))
+                        except (IOError, OSError), e:
+                            if e.errno != errno.EEXIST:
+                                raise HandlerError(u"Can't create VPN config "
+                                                   "directory '%s' (%s)'"
+                                                    % (e.filename, e.strerror))
                         #this command should generate 2 files inside the vpn
                         #dir, one rsa_key.priv and one rsa_key.pub
                         #for some reason debian does not work like this