From 853b77956aef628ae7cc525547cc311c3714c0b5 Mon Sep 17 00:00:00 2001 From: Manuela Kuhn <manuela.kuhn@desy.de> Date: Wed, 24 Feb 2016 10:52:29 +0100 Subject: [PATCH] Added watchdog option to config --- conf/dataManager.conf | 5 ++++- src/shared/helperScript.py | 29 ++++++++--------------------- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/conf/dataManager.conf b/conf/dataManager.conf index 2932b123..5f6d72f1 100644 --- a/conf/dataManager.conf +++ b/conf/dataManager.conf @@ -9,7 +9,8 @@ localTarget = /space/projects/live-viewer/data/target #localTarget = /gpfs # Type of event detector to use (options are: inotifyx) -eventDetectorType = inotifyx +#eventDetectorType = inotifyx +eventDetectorType = watchdog # Event type of files to be monitored (options are: "IN_CLOSE_WRITE", "IN_MOVED_TO", ...) monitoredEventType = IN_CLOSE_WRITE #monitoredEventType = IN_MOVED_TO @@ -17,6 +18,8 @@ monitoredEventType = IN_CLOSE_WRITE monitoredSubdirs = ["commissioning", "current", "local"] # The formats to be monitored, files in an other format will be be neglected monitoredFormats = [".tif", ".cbf"] +# Time (in seconds) since last modification after which a file will be seen as closed +timeTillClosed = 2 # List of hosts allowed to connect whitelist = ["localhost", "zitpcx19282", "zitpcx22614", "haspp11eval01", "it-hpc-cxi03"] diff --git a/src/shared/helperScript.py b/src/shared/helperScript.py index 38de6d0f..6c0856fc 100644 --- a/src/shared/helperScript.py +++ b/src/shared/helperScript.py @@ -88,6 +88,7 @@ class FakeSecHead(object): else: return self.fp.readline() + # http://code.activestate.com/recipes/541096-prompt-the-user-for-confirmation/ def confirm(prompt=None, resp=False): """prompts for yes or no response from the user. Returns True for yes and @@ -140,7 +141,6 @@ def confirm(prompt=None, resp=False): def checkEventDetectorType(eDType, supportedTypes): - #check if directory is empty if eDType in supportedTypes: logging.debug("Event detector '" + eDType + "' is ok.") else: @@ -168,14 +168,8 @@ def checkDirEmpty(dirPath): logging.info("All elements of directory " + str(dirPath) + " were removed.") - - def checkSubDirExistance(dirPath, subDirs): - """ - abort if dir does not exist - :return: - """ dirPath = os.path.normpath(dirPath) dirsToCheck = [dirPath + os.sep + directory for directory in subDirs] noSubdir = True @@ -192,29 +186,22 @@ def checkSubDirExistance(dirPath, subDirs): def checkDirExistance(dirPath): - """ - abort if dir does not exist - - :return: - """ + # Check directory path for existance. + # Exits if it does not exist - #check directory path for existance. exits if it does not exist if not os.path.exists(dirPath): logging.error("Dir '%s' does not exist. Abort." % str(dirPath)) sys.exit(1) def checkLogFileWritable(filepath, filename): - #error if logfile cannot be written + # Exits if logfile cannot be written try: - fullPath = os.path.join(filepath, filename) - logFile = open(fullPath, "a") + logfullPath = os.path.join(filepath, filename) + logFile = open(logfullPath, "a") except: - print "Unable to create the logfile """ + str(fullPath) - print """Please specify a new target by setting the following arguments: ---logfileName ---logfilePath -""" + print "Unable to create the logfile " + str(logfullPath) + print "Please specify a new target by setting the following arguments:\n--logfileName\n--logfilePath" sys.exit(1) -- GitLab