Commit 16ec645a authored by Philippe Bardou's avatar Philippe Bardou
Browse files

Web path for outputs

parent 9f693559
......@@ -68,7 +68,8 @@ cherrypy.tools.CORS = cherrypy.Tool('before_finalize', CORS)
class JFlowServer (object):
MULTIPLE_TYPE_SPLITER = "._."
JFLOW_WDATA = "data"
def __init__(self):
# Create a workflow manager to get access to our workflows
self.wfmanager = WorkflowsManager()
......@@ -87,7 +88,6 @@ class JFlowServer (object):
return wrapper
def jsonify_workflow_status(self, workflow, init_to_zero=False):
if workflow.start_time: start_time = time.asctime(time.localtime(workflow.start_time))
else: start_time = "-"
if workflow.start_time and workflow.end_time: elapsed_time = str(workflow.end_time-workflow.start_time)
......@@ -135,7 +135,7 @@ class JFlowServer (object):
"components": components}
return status
@cherrypy.expose
@jsonify
def get_available_workflows(self, **kwargs):
......@@ -299,7 +299,7 @@ class JFlowServer (object):
@cherrypy.expose
@jsonify
def get_workflow_outputs(self, **kwargs):
return self.wfmanager.get_workflow_ouputs(kwargs["workflow_id"])
return self.wfmanager.get_workflow_ouputs(JFlowServer.JFLOW_WDATA, kwargs["workflow_id"])
@cherrypy.expose
@jsonify
......@@ -338,7 +338,11 @@ if __name__ == '__main__':
# quality client-server connections (cherrypy's defult is 10s)
cherrypy.server.socket_timeout = 60
app_conf = {'/': {'tools.staticdir.root': jflowconf.get_work_directory()},
os.path.join('/', JFlowServer.JFLOW_WDATA): {'tools.staticdir.on' : True,
'tools.staticdir.dir' : jflowconf.get_work_directory()}}
cherrypy.config.update({'server.socket_host': socket_opts[0],
'server.socket_port': socket_opts[1]})
# start the server
cherrypy.quickstart(JFlowServer())
cherrypy.quickstart(JFlowServer(), config=app_conf)
......@@ -53,17 +53,22 @@ class Component(object):
dynamic_outputs.append( attribute_value )
return dynamic_outputs
def get_component_outputs(self):
def get_component_outputs(self, web_path):
outputs = {}
for attribute_value in self.__dict__.values():
if ( issubclass( attribute_value.__class__, DynamicOutput ) or
issubclass( attribute_value.__class__, OutputFileList) ):
for f in attribute_value:
outputs[os.path.basename(f)] = f
outputs[os.path.basename(f)] = self._webify_workflow_outputs(web_path, f)
elif issubclass( attribute_value.__class__, OutputFile):
outputs[os.path.basename(str(attribute_value))] = attribute_value
outputs[os.path.basename(attribute_value)] = self._webify_workflow_outputs(web_path, attribute_value)
return outputs
def _webify_workflow_outputs(self, web_path, path):
work_dir = self.config_reader.get_work_directory()
socket_opt = self.config_reader.get_socket_options()
return "http://" + socket_opt[0] + ":" + str(socket_opt[1]) + "/" + path.replace(work_dir, web_path)
def _longestCommonSubstr(self, data, clean_end=True):
substr = ''
if len(data) > 1 and len(data[0]) > 0:
......
......@@ -114,11 +114,11 @@ class Workflow(threading.Thread):
for arg in arg_lines:
yield arg
def get_outputs_per_components(self):
def get_outputs_per_components(self, web_path):
outputs_files = {}
for current_components in self.components:
#status = self.get_component_status(current_components.get_nameid())
outputs_files[current_components.get_nameid()] = current_components.get_component_outputs()
outputs_files[current_components.get_nameid()] = current_components.get_component_outputs(web_path)
#outputs_files["0"] = status["completed"]
return outputs_files
......
......@@ -90,9 +90,9 @@ class WorkflowsManager(object):
self._add_workflow(workflow)
return workflow
def get_workflow_ouputs(self, workflow_id):
def get_workflow_ouputs(self, web_path, workflow_id):
workflow = self.get_workflow(workflow_id)
return workflow.get_outputs_per_components()
return workflow.get_outputs_per_components(web_path)
def get_output_directory(self):
return self.config_reader.get_work_directory()
......
......@@ -62,7 +62,6 @@
success: function(data) {
$this.$element.html("");
$.tmpl($this.options.template, {data: data}).appendTo($this.$element);
console.log(data);
}
});
}
......@@ -92,8 +91,8 @@
template: ['<dl class="dl-horizontal">',
'{{each(component_name, files) data}}',
'<dt>${component_name}</dt>',
'{{each(index, file) files}}',
'<dd><a href="${file}">${index}</a></dd>',
'{{each(file_name, href) files}}',
'<dd><a href="${href}" download>${file_name}</a></dd>',
'{{/each}}',
'{{/each}}</dl>'].join('\n'),
workflowID: null
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment