From: Thierry Parmentelat Date: Fri, 11 Apr 2008 08:52:40 +0000 (+0000) Subject: bugfix for when the provided filename is local (dirname returns "") X-Git-Tag: PLCAPI-dummynet-1~6 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=6ec9b7e897e489794afc5e63a27560ee36c924b9;p=plcapi.git bugfix for when the provided filename is local (dirname returns "") --- diff --git a/PLC/Methods/GetBootMedium.py b/PLC/Methods/GetBootMedium.py index 9f76de1b..6b8ea185 100644 --- a/PLC/Methods/GetBootMedium.py +++ b/PLC/Methods/GetBootMedium.py @@ -288,6 +288,8 @@ class GetBootMedium(Method): nodename = temp ### handle filename + # allow to set filename to None or any other empty value + if not filename: filename='' filename = filename.replace ("%d",self.WORKDIR) filename = filename.replace ("%n",nodename) filename = filename.replace ("%s",suffix) @@ -308,11 +310,14 @@ class GetBootMedium(Method): ### we can now safely create the file, ### either we are admin or under a controlled location - if not os.path.exists(os.path.dirname(filename)): - try: - os.makedirs (os.path.dirname(filename),0777) - except: - raise PLCPermissionDenied, "Could not create dir %s"%os.path.dirname(filename) + filedir=os.path.dirname(filename) + # dirname does not return "." for a local filename like its shell counterpart + if filedir: + if not os.path.exists(filedir): + try: + os.makedirs (dirname,0777) + except: + raise PLCPermissionDenied, "Could not create dir %s"%dirname ### generic media