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) ...@@ -68,7 +68,8 @@ cherrypy.tools.CORS = cherrypy.Tool('before_finalize', CORS)
class JFlowServer (object): class JFlowServer (object):
MULTIPLE_TYPE_SPLITER = "._." MULTIPLE_TYPE_SPLITER = "._."
JFLOW_WDATA = "data"
def __init__(self): def __init__(self):
# Create a workflow manager to get access to our workflows # Create a workflow manager to get access to our workflows
self.wfmanager = WorkflowsManager() self.wfmanager = WorkflowsManager()
...@@ -87,7 +88,6 @@ class JFlowServer (object): ...@@ -87,7 +88,6 @@ class JFlowServer (object):
return wrapper return wrapper
def jsonify_workflow_status(self, workflow, init_to_zero=False): def jsonify_workflow_status(self, workflow, init_to_zero=False):
if workflow.start_time: start_time = time.asctime(time.localtime(workflow.start_time)) if workflow.start_time: start_time = time.asctime(time.localtime(workflow.start_time))
else: start_time = "-" else: start_time = "-"
if workflow.start_time and workflow.end_time: elapsed_time = str(workflow.end_time-workflow.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): ...@@ -135,7 +135,7 @@ class JFlowServer (object):
"components": components} "components": components}
return status return status
@cherrypy.expose @cherrypy.expose
@jsonify @jsonify
def get_available_workflows(self, **kwargs): def get_available_workflows(self, **kwargs):
...@@ -299,7 +299,7 @@ class JFlowServer (object): ...@@ -299,7 +299,7 @@ class JFlowServer (object):
@cherrypy.expose @cherrypy.expose
@jsonify @jsonify
def get_workflow_outputs(self, **kwargs): 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 @cherrypy.expose
@jsonify @jsonify
...@@ -338,7 +338,11 @@ if __name__ == '__main__': ...@@ -338,7 +338,11 @@ if __name__ == '__main__':
# quality client-server connections (cherrypy's defult is 10s) # quality client-server connections (cherrypy's defult is 10s)
cherrypy.server.socket_timeout = 60 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], cherrypy.config.update({'server.socket_host': socket_opts[0],
'server.socket_port': socket_opts[1]}) 'server.socket_port': socket_opts[1]})
# start the server # start the server
cherrypy.quickstart(JFlowServer()) cherrypy.quickstart(JFlowServer(), config=app_conf)
...@@ -53,17 +53,22 @@ class Component(object): ...@@ -53,17 +53,22 @@ class Component(object):
dynamic_outputs.append( attribute_value ) dynamic_outputs.append( attribute_value )
return dynamic_outputs return dynamic_outputs
def get_component_outputs(self): def get_component_outputs(self, web_path):
outputs = {} outputs = {}
for attribute_value in self.__dict__.values(): for attribute_value in self.__dict__.values():
if ( issubclass( attribute_value.__class__, DynamicOutput ) or if ( issubclass( attribute_value.__class__, DynamicOutput ) or
issubclass( attribute_value.__class__, OutputFileList) ): issubclass( attribute_value.__class__, OutputFileList) ):
for f in attribute_value: 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): 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 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): def _longestCommonSubstr(self, data, clean_end=True):
substr = '' substr = ''
if len(data) > 1 and len(data[0]) > 0: if len(data) > 1 and len(data[0]) > 0:
......
...@@ -114,11 +114,11 @@ class Workflow(threading.Thread): ...@@ -114,11 +114,11 @@ class Workflow(threading.Thread):
for arg in arg_lines: for arg in arg_lines:
yield arg yield arg
def get_outputs_per_components(self): def get_outputs_per_components(self, web_path):
outputs_files = {} outputs_files = {}
for current_components in self.components: for current_components in self.components:
#status = self.get_component_status(current_components.get_nameid()) #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"] #outputs_files["0"] = status["completed"]
return outputs_files return outputs_files
......
...@@ -90,9 +90,9 @@ class WorkflowsManager(object): ...@@ -90,9 +90,9 @@ class WorkflowsManager(object):
self._add_workflow(workflow) self._add_workflow(workflow)
return 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) 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): def get_output_directory(self):
return self.config_reader.get_work_directory() return self.config_reader.get_work_directory()
......
...@@ -62,7 +62,6 @@ ...@@ -62,7 +62,6 @@
success: function(data) { success: function(data) {
$this.$element.html(""); $this.$element.html("");
$.tmpl($this.options.template, {data: data}).appendTo($this.$element); $.tmpl($this.options.template, {data: data}).appendTo($this.$element);
console.log(data);
} }
}); });
} }
...@@ -92,8 +91,8 @@ ...@@ -92,8 +91,8 @@
template: ['<dl class="dl-horizontal">', template: ['<dl class="dl-horizontal">',
'{{each(component_name, files) data}}', '{{each(component_name, files) data}}',
'<dt>${component_name}</dt>', '<dt>${component_name}</dt>',
'{{each(index, file) files}}', '{{each(file_name, href) files}}',
'<dd><a href="${file}">${index}</a></dd>', '<dd><a href="${href}" download>${file_name}</a></dd>',
'{{/each}}', '{{/each}}',
'{{/each}}</dl>'].join('\n'), '{{/each}}</dl>'].join('\n'),
workflowID: null workflowID: null
......
Supports Markdown
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