in WAF/WAF-Enhanced-Replicator/waffun.py [0:0]
def getHomeConfig():
'''
Checks operating system, the existence of home directory.
In case it does not exist, creates it and also returns the corresponding UUID
to be considered during logging and template creation.
'''
home = os.path.expanduser('~')
if ("linux" in sys.platform) or ("darwin" in sys.platform):
separator = "/"
elif ("win32" in sys.platform) or ("win64" in sys.platform):
separator = "\\"
home = home + separator + ".wafer"
if not os.path.exists(home):
try:
os.mkdir(home)
except:
print("Unable to create configuration directory! Check permissions or disk usage on " + home + ".\n", file=sys.stderr)
sys.exit (-1)
templatesDir = home + separator + "templates"
if not os.path.exists(templatesDir):
try:
os.mkdir(templatesDir)
except:
print("Unable to create templates directory " + templatesDir + "! Check permissions or disk usage.\n", file=sys.stderr)
sys.exit (-1)
logsDir = home + separator + "logs"
if not os.path.exists(logsDir):
try:
os.mkdir(logsDir)
except:
print("Unable to create logs directory " + logsDir + "! Check permissions or disk usage.\n", file=sys.stderr)
sys.exit (-1)
uniqueId = str(uuid.uuid4())
uniqueLogName = logsDir + separator + "wafer-log-" + uniqueId + ".log"
if os.path.exists(uniqueLogName):
while os.path.exists(uniqueLogName):
uniqueId = str(uuid.uuid4())
uniqueLogName = logsDir + separator + "wafer-log-" + uniqueId + ".log"
uniqueTemplateName = templatesDir + separator + "wafer-tf-" + uniqueId + ".tf"
uniqueZipFile = home + separator + "wafer-pkg-" + uniqueId + ".zip"
return ([uniqueLogName, uniqueTemplateName, uniqueZipFile])