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
597941b7
Commit
597941b7
authored
9 years ago
by
Manuela Kuhn
Browse files
Options
Downloads
Patches
Plain Diff
Moved wrapper-script
parent
c3dcc1a3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ZeroMQTunnel/wrapper_script.py
+69
-0
69 additions, 0 deletions
ZeroMQTunnel/wrapper_script.py
with
69 additions
and
0 deletions
ZeroMQTunnel/wrapper_script.py
0 → 100644
+
69
−
0
View file @
597941b7
__author__
=
'
Manuela Kuhn <manuela.kuhn@desy.de>
'
import
argparse
import
subprocess
import
os
import
time
import
zmq
import
json
import
logging
import
helperScript
supportedFormats
=
[
"
tif
"
,
"
cbf
"
,
"
hdf5
"
]
watchFolder
=
"
/space/projects/Live_Viewer/source/
"
logfile
=
"
/space/projects/Live_Viewer/logs/wrapper_script.log
"
verbose
=
True
#enable logging
helperScript
.
initLogging
(
logfile
,
verbose
)
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
"
--mv_source
"
,
help
=
"
Move source
"
)
parser
.
add_argument
(
"
--mv_target
"
,
help
=
"
Move target
"
)
arguments
=
parser
.
parse_args
()
source
=
os
.
path
.
normpath
(
arguments
.
mv_source
)
target
=
os
.
path
.
normpath
(
arguments
.
mv_target
)
(
parentDir
,
filename
)
=
os
.
path
.
split
(
source
)
commonPrefix
=
os
.
path
.
commonprefix
(
[
watchFolder
,
source
]
)
relativebasepath
=
os
.
path
.
relpath
(
source
,
commonPrefix
)
(
relativeParent
,
blub
)
=
os
.
path
.
split
(
relativebasepath
)
(
name
,
postfix
)
=
filename
.
split
(
"
.
"
)
supported_file
=
postfix
in
supportedFormats
zmqIp
=
"
127.0.0.1
"
zmqPort
=
"
6080
"
if
supported_file
:
# set up ZeroMQ
zmqContext
=
zmq
.
Context
()
socket
=
zmqContext
.
socket
(
zmq
.
PUSH
)
zmqSocketStr
=
'
tcp://
'
+
zmqIp
+
'
:
'
+
zmqPort
socket
.
connect
(
zmqSocketStr
)
logging
.
debug
(
"
Connecting to ZMQ socket:
"
+
str
(
zmqSocketStr
))
#send reply back to server
workload
=
{
"
filepath
"
:
source
,
"
targetPath
"
:
target
}
workload_json
=
json
.
dumps
(
workload
)
try
:
socket
.
send
(
workload_json
)
except
:
logging
.
debug
(
"
Could not send message to ZMQ:
"
+
str
(
workload
))
logging
.
debug
(
"
Send message to ZMQ:
"
+
str
(
workload
))
# We never get here but clean up anyhow
try
:
socket
.
close
()
zmqContext
.
destroy
()
except
KeyboardInterrupt
:
socket
.
close
(
0
)
zmqContext
.
destroy
()
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