Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
datascience
balsamDEPRECATED
Commits
cf0518e7
Commit
cf0518e7
authored
Oct 14, 2017
by
Thomas Uram
Browse files
Migrate to Python 2+3
parent
3897a04f
Changes
3
Hide whitespace changes
Inline
Side-by-side
balsam/scheduler.py
View file @
cf0518e7
from
django.conf
import
settings
_temp
=
__import__
(
'schedulers.'
+
settings
.
BALSAM_SCHEDULER_CLASS
,
globals
(),
locals
(),
[
'submit'
,
'get_job_status'
,
'postprocess'
],
-
1
)
#_temp = __import__('schedulers.'+settings.BALSAM_SCHEDULER_CLASS, globals(), locals(),
#['submit','get_job_status','postprocess'], -1)
from
importlib
import
import_module
_temp
=
import_module
(
'balsam.schedulers.'
+
settings
.
BALSAM_SCHEDULER_CLASS
)
submit
=
_temp
.
submit
#status = _temp.status
#get_queue_state = _temp.get_queue_state
...
...
common/MessageInterface.py
View file @
cf0518e7
...
...
@@ -181,7 +181,7 @@ class MessageInterface:
body
=
message_body
,
properties
=
properties
,
)
except
Exception
,
e
:
except
Exception
as
e
:
logger
.
exception
(
'exception received while trying to send message'
)
raise
Exception
(
'exception received while trying to send message'
+
str
(
e
))
...
...
common/transfer.py
View file @
cf0518e7
...
...
@@ -2,7 +2,10 @@ from django.conf import settings
import
subprocess
import
logging
import
os
,
sys
,
traceback
import
urlparse
try
:
import
urlparse
except
ImportError
:
import
urllib.parse
as
urlparse
# temporary
import
shutil
...
...
@@ -24,13 +27,13 @@ class GridFTPHandler:
try
:
p
=
subprocess
.
Popen
(
command
.
split
(
' '
),
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
out
,
err
=
p
.
communicate
()
except
OSError
,
e
:
except
OSError
as
e
:
logger
.
error
(
'command failed with OSError, exception: '
+
str
(
e
))
raise
Exception
(
'Error in pre_stage_hook, OSError raised'
)
except
ValueError
,
e
:
except
ValueError
as
e
:
logger
.
error
(
'command failed with ValueError, exception: '
+
str
(
e
))
raise
Exception
(
'Error in pre_stage_hook, ValueError raised'
)
except
Exception
,
e
:
except
Exception
as
e
:
logger
.
error
(
'command failed, exception traceback:
\n
'
+
traceback
.
format_exc
()
)
raise
Exception
(
'Error in stage_in, unknown exception raised'
)
...
...
@@ -51,13 +54,13 @@ class GridFTPHandler:
try
:
p
=
subprocess
.
Popen
(
command
.
split
(
' '
),
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
out
,
err
=
p
.
communicate
()
except
OSError
,
e
:
except
OSError
as
e
:
logger
.
error
(
'command failed with OSError, exception: '
+
str
(
e
))
raise
Exception
(
'Error in stage_in, OSError raised'
)
except
ValueError
,
e
:
except
ValueError
as
e
:
logger
.
error
(
'command failed with ValueError, exception: '
+
str
(
e
))
raise
Exception
(
'Error in stage_in, ValueError raised'
)
except
Exception
,
e
:
except
Exception
as
e
:
logger
.
error
(
'command failed, exception traceback:
\n
'
+
traceback
.
format_exc
()
)
raise
Exception
(
'Error in stage_in, unknown exception raised'
)
if
p
.
returncode
:
...
...
@@ -75,13 +78,13 @@ class GridFTPHandler:
try
:
p
=
subprocess
.
Popen
(
command
.
split
(
' '
),
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
out
,
err
=
p
.
communicate
()
except
OSError
,
e
:
except
OSError
as
e
:
logger
.
error
(
'command failed with OSError, exception: '
+
str
(
e
))
raise
Exception
(
'Error in stage_out, OSError raised'
)
except
ValueError
,
e
:
except
ValueError
as
e
:
logger
.
error
(
'command failed with ValueError, exception: '
+
str
(
e
))
raise
Exception
(
'Error in stage_out, ValueError raised'
)
except
Exception
,
e
:
except
Exception
as
e
:
logger
.
error
(
'command failed, exception traceback:
\n
'
+
traceback
.
format_exc
()
)
raise
Exception
(
'Error in stage_out, unknown exception raised'
)
...
...
@@ -124,7 +127,7 @@ class SCPHandler:
def
stage_in
(
self
,
source_url
,
destination_directory
):
parts
=
urlparse
.
urlparse
(
source_url
)
command
=
'scp -p -r %s:%s %s'
%
(
source_url
,
destination_directory
)
print
'transfer.stage_in: command='
+
command
print
(
'transfer.stage_in: command='
+
command
)
ret
=
os
.
system
(
command
)
if
ret
:
raise
Exception
(
"Error in stage_in: %d"
%
ret
)
...
...
@@ -132,7 +135,7 @@ class SCPHandler:
def
stage_out
(
self
,
source_directory
,
destination_url
):
# ensure that source and destination each have a trailing '/'
command
=
'scp -p -r %s %s'
%
(
source_directory
,
destination_url
)
print
'transfer.stage_out: command='
+
command
print
(
'transfer.stage_out: command='
+
command
)
ret
=
os
.
system
(
command
)
if
ret
:
raise
Exception
(
"Error in stage_out: %d"
%
ret
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment