1
# Copyright (C) 2011 Linaro Limited
3
# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
5
# This file is part of LAVA Dispatcher.
7
# LAVA Dispatcher is free software; you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 2 of the License, or
10
# (at your option) any later version.
12
# LAVA Dispatcher is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
17
# You should have received a copy of the GNU General Public License
18
# along with this program; if not, see <http://www.gnu.org/licenses>.
21
from uuid import uuid1
22
from datetime import datetime
27
# TODO: Result saving could be replaced by linaro_dashboard_bundle probably.
28
def savebundlefile(testname, results, starttime, lava_result_dir):
30
Save results as .bundle file under /tmp/LAVA_RESULT_DIR/
32
TIMEFORMAT = '%Y-%m-%dT%H:%M:%SZ'
35
testdata['format'] = "Dashboard Bundle Format 1.2"
36
test_runs[0]['test_id'] = testname
37
test_runs[0]['analyzer_assigned_uuid'] = str(uuid1())
38
test_runs[0]['time_check_performed'] = False
39
test_runs[0]['analyzer_assigned_date'] = starttime
40
# TODO: hw_context sw_context for android
41
testdata['test_runs'] = test_runs
42
testdata['test_runs'][0].update(results)
44
subprocess.call(["mkdir", "-p", "/tmp/%s" % lava_result_dir])
45
# The file name should be unique to be distinguishable from others
46
filename = "/tmp/%s/" % lava_result_dir + testname + \
47
str(time.mktime(datetime.utcnow().timetuple())) + ".bundle"
48
with open(filename, "wt") as stream:
49
json.dump(bundle, stream)