X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=src%2Fnepi%2Fresources%2Fomf%2Fomf6_parser.py;h=b542e8ccdf004d3f13200b1e4c7cc24eba9a2f77;hb=cb5d027b813a27d7de263653e1a8e0cef5490f0a;hp=c3b37a82839f3d6336004abdf33655c4eef58fb8;hpb=a55b5cf0818ced6ab8dc3e88fad7f6616675e826;p=nepi.git diff --git a/src/nepi/resources/omf/omf6_parser.py b/src/nepi/resources/omf/omf6_parser.py index c3b37a82..b542e8cc 100644 --- a/src/nepi/resources/omf/omf6_parser.py +++ b/src/nepi/resources/omf/omf6_parser.py @@ -3,9 +3,8 @@ # Copyright (C) 2013 INRIA # # This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation; # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -20,6 +19,7 @@ from nepi.util.logger import Logger +import os import traceback import xml.etree.ElementTree as ET @@ -174,22 +174,6 @@ class OMF6Parser(Logger): uid = self._check_for_tag(root, namespaces, "uid") event = self._check_for_tag(root, namespaces, "event") - if event == "STDOUT": - if not uid+'out' in self.traces: - f = open('/tmp/'+ uid + '.out','w') - self.traces[uid+'out'] = f - self.trace = self.traces[uid+'out'] - elif event == "STDERR" : - if not uid+'err' in self.traces: - g = open('/tmp/'+ uid + '.err','w') - self.traces[uid+'err'] = g - self.trace = self.traces[uid+'err'] - elif event == "EXIT" : - if uid+'out' in self.traces: - self.traces[uid+'out'].close() - if uid+'err' in self.traces: - self.traces[uid+'err'].close() - log = "STATUS -- " for elt in props.keys(): ns, tag = elt.split('}') @@ -199,8 +183,18 @@ class OMF6Parser(Logger): self.mailbox['started'].append(uid) log = log + "event : " + props[elt]+" -- " elif tag == "msg": - if event == "STDOUT" or event == "STDERR" : - self.trace.write(props[elt]+'\n') + if event == "STDOUT" : + filename = os.path.join("/tmp", "%s.out" % uid) + with open(filename,'a+') as f: + # XXX: Adding fake \n for visual formatting + msg = props[elt] # + "\n" + f.write(msg) + elif event == "STDERR" : + filename = os.path.join("/tmp", "%s.err" % uid) + with open(filename,'a+') as f: + # XXX: Adding fake \n for visual formatting + msg = props[elt] # + "\n" + f.write(msg) log = log + tag +" : " + props[elt]+" -- " else: log = log + tag +" : " + props[elt]+" -- "