From 6ec9b7e897e489794afc5e63a27560ee36c924b9 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Fri, 11 Apr 2008 08:52:40 +0000 Subject: [PATCH] bugfix for when the provided filename is local (dirname returns "") --- PLC/Methods/GetBootMedium.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) 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 -- 2.47.0