Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
genotoul-bioinfo
jflow
Commits
84c03457
Commit
84c03457
authored
Jul 22, 2014
by
Jerome Mariette
Browse files
upload ok
parent
60c67280
Changes
4
Hide whitespace changes
Inline
Side-by-side
bin/jflow_server.py
View file @
84c03457
...
...
@@ -72,6 +72,7 @@ class JFlowServer (object):
def
__init__
(
self
):
# Create a workflow manager to get access to our workflows
self
.
wfmanager
=
WorkflowsManager
()
self
.
jflow_config_reader
=
JFlowConfigReader
()
def
jsonify
(
func
):
'''JSON and JSONP decorator for CherryPy'''
...
...
@@ -210,22 +211,20 @@ class JFlowServer (object):
@
cherrypy
.
expose
def
upload
(
self
,
**
kwargs
):
print
kwargs
file_param
=
kwargs
.
keys
()[
0
]
# the file transfer can take a long time; by default cherrypy
# limits responses to 300s; we increase it to 1h
cherrypy
.
response
.
timeout
=
3600
# upload file by chunks
FH_sever_file
=
open
(
"/tmp/"
+
kwargs
[
file_param
].
filename
,
"w"
)
##################tmp folder a recup
size
=
0
FH_sever_file
=
open
(
os
.
path
.
join
(
self
.
jflow_config_reader
.
get_tmp_directory
(),
kwargs
[
file_param
].
filename
.
encode
(
'ascii'
,
'ignore'
)),
"w"
)
while
True
:
data
=
kwargs
[
file_param
].
file
.
read
(
8192
)
if
not
data
:
break
size
+=
len
(
data
)
FH_sever_file
.
write
(
data
)
FH_sever_file
.
close
()
return
"ok"
@
cherrypy
.
expose
@
cherrypy
.
tools
.
noBodyProcess
()
...
...
src/jflow/config_reader.py
View file @
84c03457
...
...
@@ -37,6 +37,8 @@ class JFlowConfigReader(object):
self
.
reader
.
read
(
os
.
path
.
join
(
os
.
path
.
dirname
(
inspect
.
getfile
(
self
.
__class__
)),
self
.
CONFIG_FILE_PATH
))
def
get_tmp_directory
(
self
):
if
not
os
.
path
.
isdir
(
self
.
reader
.
get
(
"storage"
,
"tmp_directory"
)):
os
.
makedirs
(
self
.
reader
.
get
(
"storage"
,
"tmp_directory"
),
0751
)
return
self
.
reader
.
get
(
"storage"
,
"tmp_directory"
)
def
get_work_directory
(
self
):
...
...
src/jflow/workflow.py
View file @
84c03457
...
...
@@ -101,7 +101,7 @@ class Workflow(threading.Thread):
self
.
id
=
id
self
.
args
=
self
.
_extend_and_format_args
(
self
.
parameters
,
args
)
self
.
args
=
self
.
_prepare_input_files
(
self
.
args
)
self
.
args
=
self
.
_prepare_input_files
(
self
.
parameters
,
self
.
args
)
self
.
metadata
=
self
.
args
[
"metadata"
]
if
self
.
id
is
not
None
:
self
.
directory
=
self
.
manager
.
get_workflow_directory
(
self
.
name
,
self
.
id
)
...
...
@@ -227,9 +227,6 @@ class Workflow(threading.Thread):
pass
def
get_temporary_file
(
self
,
suffix
=
".txt"
):
# first check if tmp directory exists
if
not
os
.
path
.
isdir
(
self
.
jflow_config_reader
.
get_tmp_directory
()):
os
.
makedirs
(
self
.
jflow_config_reader
.
get_tmp_directory
(),
0751
)
tempfile_name
=
os
.
path
.
basename
(
tempfile
.
NamedTemporaryFile
(
suffix
=
suffix
).
name
)
return
os
.
path
.
join
(
self
.
jflow_config_reader
.
get_tmp_directory
(),
tempfile_name
)
...
...
@@ -315,18 +312,37 @@ class Workflow(threading.Thread):
local_file
.
write
(
buffer
)
local_file
.
close
()
logging
.
getLogger
(
"types.urlfile"
).
debug
(
"URL file '{0}' successfully downloaded as: {1}"
.
format
(
input
,
file_path
))
return
file_path
return
[
file_path
,
True
]
except
:
return
input
return
[
input
,
False
]
def
_prepare_input_files
(
self
,
args
):
def
_prepare_input_files
(
self
,
parameters
,
args
):
kparams
=
{}
for
param
in
parameters
:
kparams
[
param
.
name
]
=
param
new_args
=
args
for
param
in
args
.
keys
():
if
args
[
param
].
__class__
.
__name__
==
"list"
:
for
i
,
val
in
enumerate
(
args
[
param
]):
new_args
[
param
][
i
]
=
self
.
_download_urlfile
(
args
[
param
][
i
])
else
:
new_args
[
param
]
=
self
.
_download_urlfile
(
args
[
param
])
is_uri
,
is_local
=
False
,
False
# handle url inputs
if
kparams
[
param
].
type
.
__name__
==
"inputfile"
or
kparams
[
param
].
type
.
__name__
==
"urlfile"
:
if
args
[
param
].
__class__
.
__name__
==
"list"
:
for
i
,
val
in
enumerate
(
args
[
param
]):
new_args
[
param
][
i
],
is_uri
=
self
.
_download_urlfile
(
args
[
param
][
i
])
else
:
new_args
[
param
],
is_uri
=
self
.
_download_urlfile
(
args
[
param
])
# handle upload inputs
try
:
is_local
=
os
.
path
.
isfile
(
args
[
param
])
except
:
is_local
=
False
if
not
is_uri
and
not
is_local
and
kparams
[
param
].
type
.
__name__
==
"inputfile"
:
if
args
[
param
].
__class__
.
__name__
==
"list"
:
for
i
,
val
in
enumerate
(
args
[
param
]):
if
args
[
param
][
i
]:
new_args
[
param
][
i
]
=
os
.
path
.
join
(
self
.
jflow_config_reader
.
get_tmp_directory
(),
(
args
[
param
][
i
]))
else
:
if
args
[
param
]:
new_args
[
param
]
=
os
.
path
.
join
(
self
.
jflow_config_reader
.
get_tmp_directory
(),
(
args
[
param
]))
return
new_args
def
_extend_and_format_args
(
self
,
parameters
,
args
):
...
...
src/js/jflow-wfform.js
View file @
84c03457
...
...
@@ -194,20 +194,40 @@ jQuery.validator.addMethod("exclude_required", function(value, element, options)
// then send data
var
params
=
""
,
$this
=
this
;
// before serializing, all inputs have to be abled, otherwise they are not transmitted
$
(
"
a[class^=inputfile_]
"
).
each
(
function
(){
var
parts
=
$
(
this
).
attr
(
"
class
"
).
split
(
"
_
"
),
tid
=
parts
.
slice
(
1
,
parts
.
lenght
).
join
(
"
_
"
);
$
(
"
#
"
+
tid
).
removeAttr
(
'
disabled
'
);
});
$
.
each
(
$
(
'
#workflow_form
'
).
serializeArray
(),
function
(
_
,
kv
)
{
params
+=
kv
.
name
+
"
=
"
+
escape
(
kv
.
value
)
+
"
&
"
;
});
$
(
"
#workflow_form :checkbox
"
).
each
(
function
(){
if
(
!
$
(
this
).
prop
(
'
checked
'
))
{
params
+=
$
(
this
).
attr
(
"
name
"
)
+
"
=false&
"
;
}
});
$this
.
$element
.
on
(
"
uploaded
"
,
function
()
{
$
.
ajax
({
url
:
$this
.
options
.
serverURL
+
'
/run_workflow?
'
+
params
+
'
callback=?
'
,
dataType
:
"
json
"
,
success
:
function
(
running_wf
)
{
$this
.
$element
.
trigger
(
'
run
'
,
running_wf
);
}
});
});
$this
.
$element
.
trigger
(
'
upload
.files
'
);
$this
.
$element
.
trigger
(
'
upload
ing
'
);
// execute _uploadProgress to init the display
_uploadProgress
(
$this
.
options
.
progressTemplate
)
// then loop to follow the file upload
timer
=
setInterval
(
function
()
{
_uploadProgress
(
$this
.
options
.
progressTemplate
)
},
TIMER
);
$this
.
$element
.
trigger
(
'
uploaded
'
);
}
}
...
...
@@ -282,7 +302,7 @@ jQuery.validator.addMethod("exclude_required", function(value, element, options)
url
:
$this
.
options
.
serverURL
+
"
/upload
"
,
forceIframeTransport
:
true
,
add
:
function
(
e
,
data
)
{
$this
.
$element
.
on
(
"
upload
.files
"
,
function
()
{
$this
.
$element
.
on
(
"
upload
ing
"
,
function
()
{
data
.
submit
();
});
}
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment