Commit cb29af27 authored by Jerome Mariette's avatar Jerome Mariette
Browse files

update trace code

parent d605f15b
......@@ -38,7 +38,7 @@ from weaver.function import PythonFunction
class Component(object):
TRACE="trace.cmd"
TRACE_FILE_NAME = "trace.txt"
def __init__(self):
self.prefix = "default"
......@@ -46,6 +46,8 @@ class Component(object):
self.output_directory = None
self.config_reader = JFlowConfigReader()
self.version = self.get_version()
if isinstance(self.version, bytes):
self.version = self.version.decode()
self.batch_options = self.config_reader.get_component_batch_options(self.__class__.__name__)
def is_dynamic(self):
......@@ -543,7 +545,7 @@ class Component(object):
else:
py_function(inputs=new_inputs, outputs=new_outputs, arguments=arguments, includes=includes+includes_in)
self.write_trace(function.__name__, inputs, outputs, arguments, cmd_format, map, "PythonFunction")
self.__write_trace(function.__name__, inputs, outputs, arguments, cmd_format, map, "PythonFunction")
def add_shell_execution(self, source, inputs=[], outputs=[], arguments=[], includes=[],
cmd_format=None, map=False, shell=None, collect=False, local=False):
......@@ -564,22 +566,22 @@ class Component(object):
else :
shell_function( inputs=inputs, outputs=outputs, arguments=arguments, includes=includes )
self.write_trace(source, inputs, outputs, arguments, cmd_format, map, "Shell")
self.__write_trace(source, inputs, outputs, arguments, cmd_format, map, "Shell")
def write_trace(self, name, inputs, outputs, arguments, cmd_format, map, type):
trace_fh=open(os.path.join(self.output_directory,Component.TRACE),"a")
def __write_trace(self, name, inputs, outputs, arguments, cmd_format, map, type):
trace_fh=open(os.path.join(self.output_directory, Component.TRACE_FILE_NAME), "a")
trace_fh.write("###\n###Execution trace of "+type+": "+name+"\n")
if map :
trace_fh.write("MODE MAP\n")
if cmd_format != "" and type == "Shell":
trace_fh.write("COMMAND: " + str(cmd_format) + "\n")
self.write_element(trace_fh,"ARGCUMENTS",arguments)
self.write_element(trace_fh,"INPUTS",inputs)
self.write_element(trace_fh,"OUTPUTS",outputs)
self.__write_element(trace_fh,"ARGCUMENTS",arguments)
self.__write_element(trace_fh,"INPUTS",inputs)
self.__write_element(trace_fh,"OUTPUTS",outputs)
trace_fh.close()
def write_element(self,fh, title, element):
def __write_element(self,fh, title, element):
to_write=''
if isinstance(element, list):
if len (element)> 0 :
......@@ -593,4 +595,5 @@ class Component(object):
to_write+= element+"\n"
if to_write != "" :
fh.write(title+" :\n")
fh.write(to_write)
\ No newline at end of file
fh.write(to_write)
\ No newline at end of file
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