1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
#!/usr/bin/env python
# Copyright (C) 2011 Linaro Limited
#
# Author: Paul Larson <paul.larson@linaro.org>
#
# This file is part of LAVA Dispatcher.
#
# LAVA Dispatcher is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# LAVA Dispatcher is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, see <http://www.gnu.org/licenses>.
import optparse
import os
import sys
import logging.config
from lava_dispatcher import LavaTestJob
from lava_dispatcher.config import get_config
parser = optparse.OptionParser('%prog: lava-dispatch <json job file>')
parser.add_option(
"--oob-fd", default=None, type=int, help="Write OOB data to this fd.")
(options, args) = parser.parse_args()
if len(args) != 1:
parser.print_help()
sys.exit(1)
if options.oob_fd:
oob_file = os.fdopen(options.oob_fd, 'w')
else:
oob_file = sys.stderr
with open(args[0]) as fd:
jobdata = fd.read()
# config the python logging
FORMAT = '<LAVA_DISPATCHER>%(asctime)s %(levelname)s: %(message)s'
DATEFMT= '%Y-%m-%d %I:%M:%S %p'
logging.basicConfig(format=FORMAT,datefmt=DATEFMT)
config = get_config("lava-dispatcher")
logging_level = config.get("LOGGING_LEVEL")
logging.root.setLevel(int(logging_level))
job = LavaTestJob(jobdata, oob_file)
#FIXME Return status
job.run()
|