From da48a28de7461bd46ef777a2ab2f5ca0e5c1185c Mon Sep 17 00:00:00 2001 From: Javier Jardon Date: Mon, 23 Mar 2015 23:02:57 +0000 Subject: simple-network: Add functionn to create a path if it doesnt exist Change-Id: If011a5518fd30914c89b00099b9d05cff5cd3959 --- simple-network.configure | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/simple-network.configure b/simple-network.configure index 42bf1b82..b4988125 100755 --- a/simple-network.configure +++ b/simple-network.configure @@ -27,6 +27,7 @@ for DHCP import os import sys +import errno import cliapp import morphlib @@ -256,6 +257,16 @@ class SimpleNetworkConfigurationExtension(cliapp.Application): return output_stanza + def make_sure_path_exists(self, path): + try: + os.makedirs(path) + except OSError as e: + if e.errno == errno.EEXIST and os.path.isdir(path): + pass + else: + raise SimpleNetworkError("Unable to create directory '%s'" + % path) + def status(self, **kwargs): '''Provide status output. -- cgit v1.2.1