=== added file 'lava-scheduler'
@@ -0,0 +1,11 @@
+#!/usr/bin/python
+
+import os
+
+# The following line is mangled to point at the debian settings file
+# at package build time.
+os.environ['DJANGO_SETTINGS_MODULE'] = 'lava_server.settings.development'
+
+from lava_scheduler_daemon.main import main
+
+main()
=== modified file 'lava_scheduler_daemon/board.py'
@@ -190,7 +190,7 @@
self._check_call = self.reactor.callLater(
10, self._checkForJob)
return
- self.logger.debug("starting job %r", job_data)
+ self.logger.info("starting job %r", job_data)
self.running_job = self.job_cls(
job_data, self.dispatcher, self.reactor)
d = self.running_job.run()
=== added file 'lava_scheduler_daemon/config.py'
@@ -0,0 +1,35 @@
+from ConfigParser import ConfigParser
+import os
+from StringIO import StringIO
+
+#from xdg.BaseDirectory import load_config_paths
+
+defaults = {
+ 'logging': StringIO(
+'''
+[logging]
+level = INFO
+destination = -
+'''),
+ }
+
+# python xdg isn't installable via pip, so...
+def load_config_paths(name):
+ for directory in os.path.expanduser("~/.config"), '/etc/xdg':
+ path = os.path.join(directory, name)
+ if os.path.isdir(path):
+ yield path
+
+
+def get_config(name):
+ config_files = []
+ for directory in load_config_paths('lava-scheduler'):
+ path = os.path.join(directory, '%s.conf' % name)
+ if os.path.exists(path):
+ config_files.append(path)
+ config_files.reverse()
+ fp = ConfigParser()
+ if name in defaults:
+ fp.readfp(defaults[name])
+ fp.read(config_files)
+ return fp
=== renamed file 'lava-scheduler' => 'lava_scheduler_daemon/main.py' (properties changed: +x to -x)
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
import logging
import os
import sys
@@ -6,28 +5,36 @@
from twisted.internet import reactor
from lava_scheduler_daemon.service import BoardSet
+from lava_scheduler_daemon.config import get_config
-os.environ['DJANGO_SETTINGS_MODULE'] = 'lava_server.settings.development'
from lava_scheduler_daemon.dbjobsource import DatabaseJobSource
-source = DatabaseJobSource()
-
-if sys.argv[1:] == ['--use-fake']:
- dispatcher = os.path.join(
- os.path.dirname(os.path.abspath(__file__)), 'fake-dispatcher')
-elif sys.argv[1:]:
- print >>sys.stderr, "invalid options %r" % sys.argv[1:]
- sys.exit(1)
-else:
- dispatcher = 'lava-dispatch'
-
-service = BoardSet(source, dispatcher, reactor)
-reactor.callWhenRunning(service.startService)
-
-logger = logging.getLogger('')
-handler = logging.StreamHandler(sys.stdout)
-handler.setFormatter(logging.Formatter("[%(name)s] %(message)s"))
-logger.addHandler(handler)
-logger.setLevel(logging.DEBUG)
-
-reactor.run()
+def main():
+ source = DatabaseJobSource()
+
+ if sys.argv[1:] == ['--use-fake']:
+ dispatcher = os.path.join(
+ os.path.dirname(os.path.abspath(__file__)), 'fake-dispatcher')
+ elif sys.argv[1:]:
+ print >>sys.stderr, "invalid options %r" % sys.argv[1:]
+ sys.exit(1)
+ else:
+ dispatcher = 'lava-dispatch'
+
+ service = BoardSet(source, dispatcher, reactor)
+ reactor.callWhenRunning(service.startService)
+
+ logger = logging.getLogger('')
+ config = get_config('logging')
+ level = config.get("logging", "level")
+ destination = config.get("logging", 'destination', None)
+ if destination == '-':
+ handler = logging.StreamHandler(sys.stdout)
+ else:
+ handler = logging.FileHandler(destination)
+ handler.setFormatter(
+ logging.Formatter("[%(levelname)s] [%(name)s] %(message)s"))
+ logger.addHandler(handler)
+ logger.setLevel(getattr(logging, level))
+
+ reactor.run()
=== modified file 'lava_scheduler_daemon/service.py'
@@ -20,10 +20,12 @@
self._update_boards_call.clock = reactor
def _updateBoards(self):
- self.logger.info("Refreshing board list")
+ self.logger.debug("Refreshing board list")
return self.source.getBoardList().addCallback(self._cbUpdateBoards)
def _cbUpdateBoards(self, board_names):
+ if set(board_names) == set(self.boards):
+ return
self.logger.info("New board list %s", board_names)
new_boards = {}
for board_name in board_names: