def _build_results_xml(self): """Generate XML holding results of submission.""" #work out the results filename, including path, then get results xml results_filename = self._get_file_path() result = getFileAsString(results_filename) return result
def _build_state_xml(self): """Generate xml holding current state of results for input data id. This function checks to see whether the submission indicated has finished processing, not finished processing, or errored out. It creates and returns an xml string indicating the current state. """ #initalize state to be empty--meaning processing not done yet state = "" stylesheet = "" curr_time = strftime("%I:%M:%S %p, %b %d %Y ") data_id = self._data_id #generate a stylesheet directive if we have a stylesheet path if self.WaitStylePath: stylesheet = '<?xml-stylesheet href="' + self.WaitStylePath + \ '" type="text/xsl"?>' #end if there's a defined stylesheet #check if the results file or error file exists results_filename = self._get_file_path() error_filename = self._get_file_path(True) #if a results file exists, just say we're done; otherwise, if an #error file exists, insert the error into the state xml if isfile(results_filename): state = "<done />" elif isfile(error_filename): #escape error msg (for safe xml)and put in an <error> tag state = getFileAsString(error_filename) state = "<error>" + escape(state) + "</error>" #end if either results or errors exist for this id result = \ """<?xml version="1.0" ?> %(stylesheet)s <process> <id>%(data_id)s</id><time>%(curr_time)s</time>%(state)s </process>""" % locals() return result