def testCreatingFileHandle(self):
        fh1 = file_handle.FromTempFile(self.temp_file_txt)
        self.assertEquals(fh1.extension, '.txt')

        fh2 = file_handle.FromFilePath(self.abs_path_html)
        self.assertEquals(fh2.extension, '.html')
        self.assertNotEquals(fh1.id, fh2.id)
Exemple #2
0
 def _GetTempFileHandle(self):
     tf = tempfile.NamedTemporaryFile(delete=False, suffix='.html')
     if self.page:
         title = self.page.display_name
     else:
         title = ''
     trace2html.WriteHTMLForTraceDataToFile([self._trace_data.EventData()],
                                            title, tf)
     tf.close()
     return file_handle.FromTempFile(tf)
Exemple #3
0
 def _GetTempFileHandle(self, trace_data):
     tf = tempfile.NamedTemporaryFile(delete=False, suffix='.html')
     if self.page:
         title = self.page.display_name
     else:
         title = ''
     trace2html.WriteHTMLForTraceDataToFile(
         [trace_data.GetEventsFor(trace_data_module.CHROME_TRACE_PART)],
         title, tf)
     tf.close()
     return file_handle.FromTempFile(tf)
Exemple #4
0
 def _GetTempFileHandle(self, trace_data):
   if self.page:
     title = self.page.display_name
   else:
     title = ''
   content = StringIO.StringIO()
   trace2html.WriteHTMLForTraceDataToFile(
       [trace_data.GetEventsFor(trace_data_module.CHROME_TRACE_PART)],
       title,
       content)
   tf = tempfile.NamedTemporaryFile(delete=False, suffix='.html')
   tf.write(content.getvalue().encode('utf-8'))
   tf.close()
   return file_handle.FromTempFile(tf)