From d696afb32c37e74bc485a8fc74aa5533c5c214ca Mon Sep 17 00:00:00 2001 From: Mark Reynolds Date: Fri, 11 Jul 2014 16:12:30 -0400 Subject: [PATCH] Ticket 47851 - Need to retrieve tmp directory path description: lib389 tets also needs tmp directory to store files created during runtime. Modify the "get" function to be able to return the data or tmp directory paths. https://fedorahosted.org/389/ticket/47851 Reviewed by: ? --- lib389/__init__.py | 20 ++++++++++++++------ lib389/_constants.py | 2 ++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/lib389/__init__.py b/lib389/__init__.py index 29d6543..702fdd5 100644 --- a/lib389/__init__.py +++ b/lib389/__init__.py @@ -1893,12 +1893,13 @@ class DirSrv(SimpleLDAPObject): """ return self.config.enable_ssl(secport, secargs) - def getDataDir(self, filename): + def getDir(self, filename, dirtype): """ - @param filename - the name of the test script calling this function + @param filename - the name of the test script calling this function + @param dirtype - Either DATA_DIR and TMP_DIR are the allowed values @return - absolute path of the dirsrvtests data directory, or 'None' on error - Return the shared data directory relative to the ticket filename. + Return the shared data/tmp directory relative to the ticket filename. The caller should always use "__file__" as the argument to this function. Get the script name from the filename that was provided: @@ -1914,9 +1915,16 @@ class DirSrv(SimpleLDAPObject): if os.path.exists(filename): script_name = os.path.basename(filename) if script_name: - data_dir = os.path.abspath(filename).replace('tickets/' + script_name, 'data/') - if data_dir: - return data_dir + if dirtype == TMP_DIR: + dir_path = os.path.abspath(filename).replace('tickets/' + script_name, 'tmp/') + elif dirtype == DATA_DIR: + dir_path = os.path.abspath(filename).replace('tickets/' + script_name, 'data/') + else: + raise ValueError("Invalid directory type (%s), acceptable values are DATA_DIR and TMP_DIR" + % dirtype) + return None + if dir_path: + return dir_path return None diff --git a/lib389/_constants.py b/lib389/_constants.py index c259ca8..86c8b99 100644 --- a/lib389/_constants.py +++ b/lib389/_constants.py @@ -149,6 +149,8 @@ PLUGIN_WHOAMI = 'whoami' # constants # DEFAULT_USER = "nobody" +DATA_DIR = "data" +TMP_DIR = "tmp" # # LOG: see https://access.redhat.com/site/documentation/en-US/Red_Hat_Directory_Server/9.0/html/Administration_Guide/Configuring_Logs.html -- 1.9.3