From 8262b6a880c63adf7e6789403693272ac264e392 Mon Sep 17 00:00:00 2001
From: Manuela Kuhn <manuela.kuhn@desy.de>
Date: Wed, 24 Feb 2016 17:07:53 +0100
Subject: [PATCH] Exchanged "/" with os.sep

---
 conf/dataManager.conf          |  4 ++--
 src/DataManager.py             | 10 ++++++----
 src/sender/DataDispatcher.py   | 15 ++++++++++-----
 src/sender/InotifyxDetector.py |  8 ++++----
 src/sender/SignalHandler.py    |  4 +++-
 src/sender/TaskProvider.py     | 12 +++++++-----
 src/sender/WatchdogDetector.py |  6 +++---
 7 files changed, 35 insertions(+), 24 deletions(-)

diff --git a/conf/dataManager.conf b/conf/dataManager.conf
index d22a9a53..17938025 100644
--- a/conf/dataManager.conf
+++ b/conf/dataManager.conf
@@ -8,10 +8,10 @@ localTarget         = /space/projects/live-viewer/data/target
 #localTarget         = /home/kuhnm/Arbeit/live-viewer/data/target
 #localTarget         = /gpfs
 
-# Type of event detector to use (options are: inotifyx)
+# Type of event detector to use (options are: inotifyx, watchdog)
 #eventDetectorType   = inotifyx
 eventDetectorType   = watchdog
-# Event type of files to be monitored (options are: "IN_CLOSE_WRITE", "IN_MOVED_TO", ...)
+# Event type of files to be monitored (options are: IN_CLOSE_WRITE, IN_MOVED_TO, ...)
 monitoredEventType  = IN_CLOSE_WRITE
 #monitoredEventType  = IN_MOVED_TO
 # Subdirectories of watchDir to be monitored
diff --git a/src/DataManager.py b/src/DataManager.py
index 2a5ac816..33a4d9a7 100644
--- a/src/DataManager.py
+++ b/src/DataManager.py
@@ -271,8 +271,10 @@ if __name__ == '__main__':
         from shutil import copyfile
         from subprocess import call
 
+
+        logfile = BASE_PATH + os.sep "logs" + os.sep + "dataManager_test.log"
         #enable logging
-        helpers.initLogging(BASE_PATH + "/logs/dataManager_test.log", verbose=True, onScreenLogLevel="debug")
+        helpers.initLogging(logfile, verbose=True, onScreenLogLevel="debug")
 
         class Test_Receiver_Stream():
             def __init__(self, comPort, fixedRecvPort, receivingPort, receivingPort2):
@@ -344,8 +346,8 @@ if __name__ == '__main__':
         testPr = Process ( target = Test_Receiver_Stream, args = (comPort, fixedRecvPort, receivingPort, receivingPort2))
         testPr.start()
 
-        sourceFile = BASE_PATH + "/test_file.cbf"
-        targetFileBase = BASE_PATH + "/data/source/local/raw/"
+        sourceFile = BASE_PATH + os.sep + "test_file.cbf"
+        targetFileBase = BASE_PATH + os.sep + "data" + os.sep + "source" + os.sep + "local" + os.sep + "raw" + os.sep
         i = 100
 
 
@@ -371,7 +373,7 @@ if __name__ == '__main__':
                 else:
                     pass
     except Exception as e:
-        self.log.error("Exception detected: " + str(e))
+        logging.error("Exception detected: " + str(e))
     finally:
         if test:
             testPr.terminate()
diff --git a/src/sender/DataDispatcher.py b/src/sender/DataDispatcher.py
index 3c59e37e..c204a6d3 100644
--- a/src/sender/DataDispatcher.py
+++ b/src/sender/DataDispatcher.py
@@ -390,11 +390,16 @@ if __name__ == '__main__':
     import time
     from shutil import copyfile
 
+    logfile = BASE_PATH + os.sep + "logs" + os.sep + "dataDispatcher.log"
+
     #enable logging
-    helpers.initLogging(BASE_PATH + "/logs/dataDispatcher.log", verbose=True, onScreenLogLevel="debug")
+    helpers.initLogging(logfile, verbose=True, onScreenLogLevel="debug")
+
+    sourceFile = BASE_PATH + os.sep + "test_file.cbf"
+    targetFile = BASE_PATH + os.sep + "data" + os.sep + "source" + os.sep + "local" + os.sep + "raw" + os.sep "100.cbf"
 
 
-    copyfile(BASE_PATH + "/test_file.cbf", BASE_PATH + "/data/source/local/raw/100.cbf")
+    copyfile(sourceFile, targetFile)
     time.sleep(0.5)
 
 
@@ -403,7 +408,7 @@ if __name__ == '__main__':
     receivingPort2 = "6006"
     chunkSize     = 10485760 ; # = 1024*1024*10 = 10 MiB
 
-    localTarget   = BASE_PATH + "/data/target"
+    localTarget   = BASE_PATH + os.sep + "data" + os.sep + "target"
     fixedStreamId = False
     fixedStreamId = "zitpcx19282:6006"
 
@@ -429,8 +434,8 @@ if __name__ == '__main__':
 
 
     metadata = {
-            "sourcePath"  : BASE_PATH + "/data/source",
-            "relativePath": "/local/raw",
+            "sourcePath"  : BASE_PATH + os.sep +"data" + os.sep + "source",
+            "relativePath": os.sep + "local" + os.sep + "raw",
             "filename"    : "100.cbf"
             }
     targets = [['zitpcx19282:6005', 1], ['zitpcx19282:6006', 0]]
diff --git a/src/sender/InotifyxDetector.py b/src/sender/InotifyxDetector.py
index ae5bfa5b..4028f275 100644
--- a/src/sender/InotifyxDetector.py
+++ b/src/sender/InotifyxDetector.py
@@ -319,7 +319,7 @@ if __name__ == '__main__':
     import helpers
 
 
-    logfilePath = BASE_PATH + "/logs/inotifyDetector.log"
+    logfilePath = BASE_PATH + os.sep + "logs" + os.sep + "inotifyDetector.log"
     verbose     = True
     onScreen    = "debug"
 
@@ -328,7 +328,7 @@ if __name__ == '__main__':
 
     config = {
             "eventDetectorType" : "inotifyx",
-            "monDir"            : BASE_PATH + "/data/source",
+            "monDir"            : BASE_PATH + os.sep + "data" + os.sep + "source",
             "monEventType"      : "IN_CLOSE_WRITE",
             "monSubdirs"        : ["commissioning", "current", "local"],
             "monSuffixes"       : [".tif", ".cbf"]
@@ -336,8 +336,8 @@ if __name__ == '__main__':
 
     eventDetector = InotifyxDetector(config)
 
-    sourceFile = BASE_PATH + "/test_file.cbf"
-    targetFileBase = BASE_PATH + "/data/source/local/raw/"
+    sourceFile = BASE_PATH + os.sep + "test_file.cbf"
+    targetFileBase = BASE_PATH + os.sep + "data" + os.sep + "source" + os.sep + "local" + os.sep + "raw" + os.sep
 
     i = 100
     while True:
diff --git a/src/sender/SignalHandler.py b/src/sender/SignalHandler.py
index 688a1e4e..8693dfa7 100644
--- a/src/sender/SignalHandler.py
+++ b/src/sender/SignalHandler.py
@@ -370,8 +370,10 @@ if __name__ == '__main__':
             self.requestFwSocket.close(0)
             self.context.destroy()
 
+    BASE_PATH = os.path.dirname ( os.path.dirname ( os.path.dirname ( os.path.realpath ( __file__ ) )))
 
-    helpers.initLogging("/space/projects/live-viewer/logs/signalHandler.log", verbose=True, onScreenLogLevel="debug")
+    logfile = BASE_PATH + os.sep + "logs" + os.sep + "signalHandler.log"
+    helpers.initLogging(logfile, verbose=True, onScreenLogLevel="debug")
 
 
     whiteList     = ["localhost", "zitpcx19282"]
diff --git a/src/sender/TaskProvider.py b/src/sender/TaskProvider.py
index 0dcdac77..176a60bb 100644
--- a/src/sender/TaskProvider.py
+++ b/src/sender/TaskProvider.py
@@ -234,12 +234,14 @@ if __name__ == '__main__':
             self.requestFwSocket.close(0)
             self.context.destroy()
 
+    logfile = BASE_PATH + os.sep + "logs" + os.sep + "taskProvider.log"
+
     #enable logging
-    helpers.initLogging(BASE_PATH + "/logs/taskProvider.log", verbose=True, onScreenLogLevel="debug")
+    helpers.initLogging(logfile, verbose=True, onScreenLogLevel="debug")
 
 #    eventDetectorConfig = {
 #            "eventDetectorType"   : "inotifyx",
-#            "monDir"              : BASE_PATH + "/data/source",
+#            "monDir"              : BASE_PATH + os.sep + "data" + os.sep + "source",
 #            "monEventType"        : "IN_CLOSE_WRITE",
 #            "monSubdirs"          : ["commissioning", "current", "local"],
 #            "monSuffixes"         : [".tif", ".cbf"]
@@ -247,7 +249,7 @@ if __name__ == '__main__':
 
     eventDetectorConfig = {
             "eventDetectorType" : "watchdog",
-            "monDir"            : BASE_PATH + "/data/source",
+            "monDir"            : BASE_PATH + os.sep + "data" + os.sep + "source",
             "monEventType"      : "IN_CLOSE_WRITE",
             "monSubdirs"        : ["commissioning", "current", "local"],
             "monSuffixes"       : [".tif", ".cbf"],
@@ -270,8 +272,8 @@ if __name__ == '__main__':
     routerSocket.connect(connectionStr)
     logging.info("=== routerSocket connected to " + connectionStr)
 
-    sourceFile = BASE_PATH + "/test_file.cbf"
-    targetFileBase = BASE_PATH + "/data/source/local/raw/"
+    sourceFile = BASE_PATH + os.sep + "test_file.cbf"
+    targetFileBase = BASE_PATH + os.sep + "data" + os.sep + "source" + os.sep + "local" + os.sep + "raw" + os.sep
 
     i = 100
     try:
diff --git a/src/sender/WatchdogDetector.py b/src/sender/WatchdogDetector.py
index c66e7136..b55b7ca9 100644
--- a/src/sender/WatchdogDetector.py
+++ b/src/sender/WatchdogDetector.py
@@ -337,7 +337,7 @@ if __name__ == '__main__':
     import helpers
 
 
-    logfilePath = BASE_PATH + "/logs/watchdogDetector.log"
+    logfilePath = BASE_PATH + os.sep + "logs" + os.sep + "watchdogDetector.log"
     verbose     = True
     onScreen    = "debug"
 
@@ -346,7 +346,7 @@ if __name__ == '__main__':
 
     config = {
             #TODO normpath to make insensitive to "/" at the end
-            "monDir"         : BASE_PATH + "/data/source",
+            "monDir"         : BASE_PATH + os.sep + "data" + os.sep + "source",
             "monEventType"   : "ON_CLOSE",
 #            "monEventType"   : "IN_CREATE",
             "monSubdirs"     : ["commissioning", "current", "local"],
@@ -355,7 +355,7 @@ if __name__ == '__main__':
             }
 
     sourceFile = BASE_PATH + "/test_file.cbf"
-    targetFileBase = BASE_PATH + "/data/source/local/raw/"
+    targetFileBase = BASE_PATH + os.sep + "data" + os.sep + "source" + os.sep + "local" + os.sep + "raw" + os.sep
 
     eventDetector = WatchdogDetector(config)
 
-- 
GitLab