~gmdduf/lava-dispatcher/gauss-support

« back to all changes in this revision

Viewing changes to lava_dispatcher/android_util.py

Update l-m-c cmdline options

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2011 Linaro Limited
 
2
#
 
3
# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
 
4
#
 
5
# This file is part of LAVA Dispatcher.
 
6
#
 
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.
 
11
#
 
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.
 
16
#
 
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>.
 
19
 
 
20
import os
 
21
from uuid import uuid1
 
22
from datetime import datetime
 
23
import json
 
24
import subprocess
 
25
import time
 
26
 
 
27
# TODO: Result saving could be replaced by linaro_dashboard_bundle probably.
 
28
def savebundlefile(testname, results, starttime, lava_result_dir):
 
29
    """
 
30
    Save results as .bundle file under /tmp/LAVA_RESULT_DIR/
 
31
    """
 
32
    TIMEFORMAT = '%Y-%m-%dT%H:%M:%SZ'
 
33
    testdata = {}
 
34
    test_runs = [{}]
 
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)
 
43
    bundle = testdata
 
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)
 
50