Skip to content
Snippets Groups Projects
Commit d67d48f4 authored by Manuela Kuhn's avatar Manuela Kuhn
Browse files

Fixed paths comming from Windows to save on Linux

parent 6bfe7c0c
No related branches found
No related tags found
No related merge requests found
......@@ -386,7 +386,7 @@ class dataTransfer():
if len(payload) < payloadMetadata["chunkSize"] :
#indicated end of file. Leave loop
filename = self.generateTargetFilepath(targetBasePath, payloadMetadata)
fileModTime = payloadMetadata["fileModificationTime"]
fileModTime = payloadMetadata["fileModTime"]
self.log.info("New file with modification time " + str(fileModTime) + " received and saved: " + str(filename))
break
......@@ -446,7 +446,9 @@ class dataTransfer():
"""
filename = configDict["filename"]
relativePath = configDict["relativePath"]
#TODO This is due to Windows path names, check if there has do be done anything additionally to work
# e.g. check sourcePath if it's a windows path
relativePath = configDict["relativePath"].replace('\\', os.sep)
if relativePath is '' or relativePath is None:
targetPath = basePath
......
......@@ -156,7 +156,12 @@ def splitFilePath(filepath, paths):
# path = /tmp/test/source/local/testdir
# first iteration: parentDir = /tmp/test/source/local, relDir = /testdir
# second iteration: parentDir = /tmp/test/source, relDir = /local/testdir
relativePath = os.sep + relDir + relativePath
if relativePath:
relativePath = os.path.join(relDir, relativePath)
#relativePath = os.sep + relDir + relativePath
else:
relativePath = relDir
# commonPrefix = os.path.commonprefix([self.monDir,filepath]) # corresponds to sourcePath
......@@ -166,12 +171,12 @@ def splitFilePath(filepath, paths):
# the event for a file /tmp/test/source/local/file1.tif is of the form:
# {
# "sourcePath" : "/tmp/test/source"
# "relativePath": "/local"
# "relativePath": "local"
# "filename" : "file1.tif"
# }
eventMessage = {
"sourcePath" : parentDir,
"relativePath": relativePath,
"sourcePath" : os.path.normpath(parentDir),
"relativePath": os.path.normpath(relativePath),
"filename" : filename
}
......@@ -358,8 +363,9 @@ if __name__ == '__main__':
from multiprocessing import Queue
# BASE_PATH = os.path.dirname ( os.path.dirname ( os.path.dirname ( os.path.realpath ( __file__ ) )))
BASE_PATH = os.path.dirname ( os.path.dirname ( os.path.dirname ( os.path.abspath ( sys.argv[0] ) )))
BASE_PATH = os.path.dirname ( os.path.dirname ( os.path.dirname ( os.path.dirname ( os.path.abspath ( sys.argv[0] ) ))))
SHARED_PATH = BASE_PATH + os.sep + "src" + os.sep + "shared"
print SHARED_PATH
if not SHARED_PATH in sys.path:
sys.path.append ( SHARED_PATH )
......
import os
import sys
import time
import traceback
BASE_PATH = os.path.dirname ( os.path.dirname ( os.path.dirname ( os.path.realpath ( __file__ ) ) ) )
API_PATH = BASE_PATH + os.sep + "APIs"
SHARED_PATH = BASE_PATH + os.sep + "src" + os.sep + "shared"
if not API_PATH in sys.path:
sys.path.append ( API_PATH )
del API_PATH
from dataTransferAPI import dataTransfer
if not SHARED_PATH in sys.path:
sys.path.append ( SHARED_PATH )
del SHARED_PATH
import helpers
#enable logging
logfilePath = os.path.join(BASE_PATH + os.sep + "logs")
logfile = os.path.join(logfilePath, "testAPI.log")
helpers.initLogging(logfile, True, "DEBUG")
del BASE_PATH
dataPort = "50100"
print
print "==== TEST: Query for the newest filename ===="
print
query = dataTransfer("stream", useLog = True)
query.start(dataPort)
while True:
try:
[metadata, data] = query.get()
except KeyboardInterrupt:
break
except Exception as e:
print "Getting data failed."
print "Error was: " + str(e)
break
print
print "metadata of file", metadata["filename"]
print "data", str(data)[:10]
print
# try:
# query.store("/space/projects/live-viewer/data/target/testStore", result)
# except Exception as e:
# print "Storing data failed."
# print "Error was:", e
# break
query.stop()
print
print "==== TEST END: Query for the newest filename ===="
print
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment