OLD | NEW |
---|---|
(Empty) | |
1 # Copyright 2017 The Chromium Authors. All rights reserved. | |
2 # Use of this source code is governed by a BSD-style license that can be | |
3 # found in the LICENSE file. | |
4 | |
5 import time | |
6 import os | |
7 import shutil | |
8 import urllib | |
9 | |
10 from pylib.base import output_manager | |
11 | |
12 | |
13 class LocalOutputManager(output_manager.OutputManager): | |
14 """Saves and manages test output files locally in output directory. | |
15 | |
16 Location files will be saved in {output_dir}/TEST_RESULTS_{timestamp}. | |
17 """ | |
18 | |
19 def __init__(self, output_dir): | |
20 super(LocalOutputManager, self).__init__() | |
21 timestamp = time.strftime( | |
22 '%Y_%m_%dT%H_%M_%S', time.localtime()) | |
23 self._output_root = os.path.join( | |
jbudorick
2017/08/10 16:27:38
would it be helpful to include the suite name here
| |
24 output_dir, 'TEST_RESULTS_%s' % timestamp) | |
25 | |
26 #override | |
27 def _CreateArchiveJob(self, in_filepath, out_filename, out_subdir, datatype): | |
28 return LocalArchiveJob( | |
29 in_filepath, out_filename, out_subdir, datatype, self._output_root) | |
30 | |
31 | |
32 class LocalArchiveJob(output_manager.Job): | |
33 | |
34 def __init__(self, in_filepath, out_filename, out_subdir, datatype, out_root): | |
35 super(LocalArchiveJob, self).__init__( | |
36 in_filepath, out_filename, out_subdir, datatype) | |
37 self._output_path = os.path.join(out_root, out_subdir, out_filename) | |
38 | |
39 def Link(self): | |
40 return 'file://%s' % urllib.quote(self._output_path) | |
41 | |
42 def Archive(self): | |
43 if not os.path.exists(os.path.dirname(self._output_path)): | |
44 os.makedirs(os.path.dirname(self._output_path)) | |
45 shutil.copy(self._in_filepath, self._output_path) | |
OLD | NEW |