diff mbox

[Branch,~linaro-validation/lava-dispatcher/trunk] Rev 323: make lava-dispatch invoke lava dispatch, and make the latter's logging

Message ID 20120614060211.360.42044.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

Michael-Doyle Hudson June 14, 2012, 6:02 a.m. UTC
Merge authors:
  Michael Hudson-Doyle (mwhudson)
Related merge proposals:
  https://code.launchpad.net/~mwhudson/lava-dispatcher/lava-space-dispatch-compat/+merge/110222
  proposed by: Michael Hudson-Doyle (mwhudson)
  review: Approve - Andy Doan (doanac)
------------------------------------------------------------
revno: 323 [merge]
committer: Michael Hudson-Doyle <michael.hudson@linaro.org>
branch nick: trunk
timestamp: Thu 2012-06-14 18:00:48 +1200
message:
  make lava-dispatch invoke lava dispatch, and make the latter's logging
  setup match the formers
modified:
  lava-dispatch
  lava/dispatcher/commands.py


--
lp:lava-dispatcher
https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk

You are subscribed to branch lp:lava-dispatcher.
To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk/+edit-subscription
diff mbox

Patch

=== modified file 'lava-dispatch'
--- lava-dispatch	2012-03-08 22:30:45 +0000
+++ lava-dispatch	2012-06-14 03:46:53 +0000
@@ -1,90 +1,2 @@ 
-#!/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 json_schema_validator.errors import ValidationError
-
-from lava_dispatcher.job import LavaTestJob, validate_job_data
-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.")
-parser.add_option(
-    "--config-dir",
-    default=None if os.environ.get("VIRTUAL_ENV") is None else os.path.join(os.environ["VIRTUAL_ENV"], "etc", "lava-dispatcher"),
-    help="Configuration directory override (currently %default)")
-parser.add_option(
-    "--validate", action='store_true',
-    help="Just validate the job file, do not execute any steps.")
-parser.add_option(
-    "--job-id", action='store', default=None,
-    help="Set the scheduler job identifier. This alters process name for easier debugging")
-
-(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)
-
-# Set process id if job-id was passed to dispatcher
-if options.job_id:
-    try:
-        from setproctitle import getproctitle, setproctitle
-    except ImportError:
-        logging.warning("Unable to set import 'setproctitle', process name cannot be changed")
-    else:
-        setproctitle("%s [job: %s]" % (getproctitle(), options.job_id))
-
-
-config = get_config("lava-dispatcher", options.config_dir)
-logging_level = config.get("LOGGING_LEVEL")
-logging.root.setLevel(int(logging_level))
-
-job = LavaTestJob(jobdata, oob_file, config)
-
-#FIXME Return status
-if options.validate:
-    try:
-        validate_job_data(job.job_data)
-    except ValidationError as e:
-        print e
-else:
-    job.run()
+#!/bin/bash
+exec lava dispatch "$@"

=== modified file 'lava/dispatcher/commands.py'
--- lava/dispatcher/commands.py	2012-06-01 01:49:28 +0000
+++ lava/dispatcher/commands.py	2012-06-14 03:46:32 +0000
@@ -63,6 +63,10 @@ 
 
         # config the python logging
         # FIXME: move to lava-tool
+        # XXX: this is horrible, but: undo the logging setup lava-tool has
+        # done.
+        del logging.root.handlers[:]
+        del logging.root.filters[:]
         FORMAT = '<LAVA_DISPATCHER>%(asctime)s %(levelname)s: %(message)s'
         DATEFMT= '%Y-%m-%d %I:%M:%S %p'
         logging.basicConfig(format=FORMAT,datefmt=DATEFMT)