Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hidra
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
steinbac
hidra
Commits
d67d48f4
Commit
d67d48f4
authored
9 years ago
by
Manuela Kuhn
Browse files
Options
Downloads
Patches
Plain Diff
Fixed paths comming from Windows to save on Linux
parent
6bfe7c0c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
APIs/dataTransferAPI.py
+4
-2
4 additions, 2 deletions
APIs/dataTransferAPI.py
src/sender/eventDetectors/WatchdogDetector.py
+11
-5
11 additions, 5 deletions
src/sender/eventDetectors/WatchdogDetector.py
test/API/test_windows.py
+69
-0
69 additions, 0 deletions
test/API/test_windows.py
with
84 additions
and
7 deletions
APIs/dataTransferAPI.py
+
4
−
2
View file @
d67d48f4
...
...
@@ -386,7 +386,7 @@ class dataTransfer():
if
len
(
payload
)
<
payloadMetadata
[
"
chunkSize
"
]
:
#indicated end of file. Leave loop
filename
=
self
.
generateTargetFilepath
(
targetBasePath
,
payloadMetadata
)
fileModTime
=
payloadMetadata
[
"
fileMod
ification
Time
"
]
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
...
...
This diff is collapsed.
Click to expand it.
src/sender/eventDetectors/WatchdogDetector.py
+
11
−
5
View file @
d67d48f4
...
...
@@ -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
)
...
...
This diff is collapsed.
Click to expand it.
test/API/test_windows.py
0 → 100644
+
69
−
0
View file @
d67d48f4
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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment