[Pkg-debile-commits] [debile-slave] 87/100: Adapted to SQLAlchemy serialization format.
Sylvestre Ledru
sylvestre at alioth.debian.org
Mon Aug 19 14:53:15 UTC 2013
This is an automated email from the git hooks/post-receive script.
sylvestre pushed a commit to branch master
in repository debile-slave.
commit dadd98cde4acf84212705095033fdc21dc503d83
Author: Léo Cavaillé <leo at cavaille.net>
Date: Fri Jul 26 20:02:39 2013 +0200
Adapted to SQLAlchemy serialization format.
---
ethel/client.py | 24 ++++++++++++------------
ethel/config.py | 31 ++++++++++++++++++++-----------
ethel/daemon.py | 46 +++++++++++++++++-----------------------------
3 files changed, 49 insertions(+), 52 deletions(-)
diff --git a/ethel/client.py b/ethel/client.py
index 572e13a..30716df 100644
--- a/ethel/client.py
+++ b/ethel/client.py
@@ -1,5 +1,5 @@
from ethel.utils import tdir, cd, dget, upload, run_command
-from ethel.config import load
+from ethel.config import Config
from contextlib import contextmanager
import xmlrpclib
@@ -9,13 +9,13 @@ import os
def get_proxy():
- info = load()
+ info = Config()
proxy = xmlrpclib.ServerProxy(
"http://{user}:{password}@{host}:{port}/".format(
- user=info['user'],
- password=info['password'],
- host=info['host'],
- port=info['port']
+ user=info['host']['user'],
+ password=info['host']['password'],
+ host=info['host']['host'],
+ port=info['host']['port']
), allow_none=True)
return proxy
@@ -23,18 +23,18 @@ def get_proxy():
@contextmanager
def checkout(package):
proxy = get_proxy()
- _type = package['_type']
- if _type not in ['binaries', 'sources']:
- raise ValueError("_type sucks")
+ _type = package['type']
+ if _type not in ['binary', 'source']:
+ raise ValueError("type sucks")
def source():
- url = proxy.get_dsc(package['_id'])
+ url = proxy.get_dsc(package['source_id'])
dsc = os.path.basename(url)
dget(url)
yield dsc
def binary():
- info = proxy.get_deb_info(package['_id'])
+ info = proxy.get_deb_info(package['binary_id'])
url_base = info['root']
out, err, ret = run_command(['wget'] + [
os.path.join(url_base, x) for x in info['packages']])
@@ -44,5 +44,5 @@ def checkout(package):
with tdir() as where:
with cd(where):
- for x in {"sources": source, "binaries": binary}[_type]():
+ for x in {"source": source, "binary": binary}[_type]():
yield x
diff --git a/ethel/config.py b/ethel/config.py
index e89a09e..8a7f0f0 100644
--- a/ethel/config.py
+++ b/ethel/config.py
@@ -1,15 +1,24 @@
-try:
- import configparser
-except ImportError:
- import ConfigParser as configparser
+import ConfigParser
-CONFIG_BLOCK = "host"
+class Config(ConfigParser.ConfigParser):
+ def __init__(self, location="/etc/ethel.ini"):
+ ConfigParser.ConfigParser.__init__(self)
+ self.read(location)
+ def __getitem__(self, val):
+ return ConfigSection(val, self.items(val))
-def load(location="/etc/ethel.ini", block="host"):
- if block is None:
- block = CONFIG_BLOCK
+ def verify():
+ # TODO, check that after constructor the conf is fine
+ return True
- cfg = configparser.ConfigParser()
- cfg.read(location)
- return cfg[block]
+class ConfigSection(Config):
+ def __init__(self, name, vals):
+ self.section_name = name
+ self.vals = vals
+
+ def __getitem__(self, val):
+ for k,v in self.vals:
+ if k == val:
+ return v
+ raise Exception("No such key %s in the configuration", val)
diff --git a/ethel/daemon.py b/ethel/daemon.py
index 0ebe2fe..9a897c5 100644
--- a/ethel/daemon.py
+++ b/ethel/daemon.py
@@ -5,12 +5,12 @@ from ethel.commands import PLUGINS, load_module
from ethel.client import get_proxy, checkout
from contextlib import contextmanager
from ethel.utils import tdir, cd, run_command
-from ethel.config import load
+from ethel.config import Config
import logging
import time
-config = load()
+config = Config()
proxy = get_proxy()
@@ -29,20 +29,20 @@ def workon(suites, arches, capabilities):
if job is None:
yield
else:
- logging.info("Acquired job %s (%s) for %s/%s", job['_id'], job['type'], job['suite'], job['arch'])
+ logging.info("Acquired job id=%s (%s) for %s/%s", job['id'], job['type'], job['suite'], job['arch'])
try:
yield job
except:
logging.warn("Forfeiting the job because of internal exception")
- proxy.forfeit_job(job['_id'])
+ proxy.forfeit_job(job['id'])
raise
else:
logging.info("Successfully closing the job")
- proxy.close_job(job['_id'])
+ proxy.close_job(job['id'])
def generate_sut_from_source(package):
- name = package['source']
+ name = package['name']
local = None
version = package['version']
if "-" in version:
@@ -53,7 +53,7 @@ def generate_sut_from_source(package):
def generate_sut_from_binary(package):
source = proxy.get_source_package(package['source'])
arch = package['arch']
- name = source['source']
+ name = source['name']
local = None
version = source['version']
if "-" in version:
@@ -64,9 +64,9 @@ def generate_sut_from_binary(package):
def create_firehose(package, version_getter):
logging.info("Initializing empty firehose report")
sut = {
- "sources": generate_sut_from_source,
- "binaries": generate_sut_from_binary
- }[package['_type']](package)
+ "source": generate_sut_from_source,
+ "binary": generate_sut_from_binary
+ }[package['type']](package)
gname_, gversion = version_getter()
gname = "ethel/%s" % gname_
@@ -77,23 +77,14 @@ def create_firehose(package, version_getter):
def iterate():
- suites = listize(config['suites'])
- arches = listize(config['arches'])
+ suites = listize(config['host']['suites'])
+ arches = listize(config['host']['arches'])
with workon(suites, arches, list(PLUGINS.keys())) as job:
if job is None:
raise IDidNothingError("No more jobs")
- package_id = job['package']
- type_ = job['package_type']
+ package = job['package']
- logging.debug("Fetching the %s package, id=%s", type_, package_id)
- package = None
- if type_ == 'binary':
- package = proxy.get_binary_package(package_id)
- elif type_ == 'source':
- package = proxy.get_source_package(package_id)
- else:
- raise IDidNothingError("SHIT")
handler, version_getter = load_module(job['type'])
firehose = create_firehose(package, version_getter)
@@ -104,24 +95,21 @@ def iterate():
firehose, log, err = handler(target, package,
job, firehose)
- type_ = {"sources": "source",
- "binaries": "binary"}[package['_type']]
-
logging.info("Job worker returned, filing reports")
- report = proxy.submit_report(firehose.to_json(),
- job['_id'], err)
+# report = proxy.submit_report(firehose.to_json(),
+# job['_id'], err)
logging.info("Sending the XML firehose report to the pool")
open('firehose.xml', 'w').write(firehose.to_xml_bytes())
remote_firehose_path = proxy.get_firehose_write_location(report)
- cmd = config['copy'].format(src='firehose.xml',
+ cmd = config['host']['copy'].format(src='firehose.xml',
dest=remote_firehose_path)
out, err, ret = run_command(cmd)
logging.info("Sending the logs to the pool")
remote_path = proxy.get_log_write_location(report)
open('ethel-log', 'wb').write(log.encode('utf-8'))
- cmd = config['copy'].format(src='ethel-log',
+ cmd = config['host']['copy'].format(src='ethel-log',
dest=remote_path)
out, err, ret = run_command(cmd)
if ret != 0:
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-debile/debile-slave.git
More information about the Pkg-debile-commits
mailing list