[Pkg-debile-commits] [debile-master] 02/02: Implemented configuration verification
Léo Cavaillé
leo.cavaille-guest at alioth.debian.org
Thu Aug 22 21:42:31 UTC 2013
This is an automated email from the git hooks/post-receive script.
leo.cavaille-guest pushed a commit to branch master
in repository debile-master.
commit fceae20924b0e898a9bd756e010dc0e214d94392
Author: Léo Cavaillé <leo at cavaille.net>
Date: Thu Aug 22 16:58:58 2013 +0200
Implemented configuration verification
---
debile/master/archive.py | 10 +++++-----
debile/master/cli/init.py | 6 +++---
debile/master/config.py | 33 +++++++++++++++++++++++++++++----
debile/master/incoming.py | 4 ++--
debile/master/server.py | 2 +-
skel/debile-master.ini | 6 +++---
6 files changed, 43 insertions(+), 18 deletions(-)
diff --git a/debile/master/archive.py b/debile/master/archive.py
index 601ebbc..058c352 100644
--- a/debile/master/archive.py
+++ b/debile/master/archive.py
@@ -75,9 +75,9 @@ class UserRepository:
def __init__(self, user):
self.user = user
self.config = Config()
- incoming_path = self.config.get('paths', 'incoming')
+ incoming_path = self.config.get('paths', 'incoming_path')
self.incoming_path = os.path.join(incoming_path, self.user.login)
- pool_path = self.config.get('paths', 'pool')
+ pool_path = self.config.get('paths', 'pool_path')
self.pool_path = os.path.join(pool_path, self.user.login)
def get_apt_entry(self):
@@ -230,7 +230,7 @@ class UserRepository:
def move_to_pool_source(package, changes, root=None):
config = Config()
- pool = config.get('paths', 'pool')
+ pool = config.get('paths', 'pool_path')
path = os.path.join(pool, str(package.package_id))
if root:
path = os.path.join(path, root)
@@ -246,8 +246,8 @@ def move_to_pool_source(package, changes, root=None):
def move_to_pool_binary(package, bfilename, root=None):
config = Config()
- pool = config.get('paths', 'pool')
- incoming = config.get('paths', 'incoming')
+ pool = config.get('paths', 'pool_path')
+ incoming = config.get('paths', 'incoming_path')
path = os.path.join(pool, str(package.source.package_id))
if root:
path = os.path.join(path, root)
diff --git a/debile/master/cli/init.py b/debile/master/cli/init.py
index 8cede95..f48e98f 100644
--- a/debile/master/cli/init.py
+++ b/debile/master/cli/init.py
@@ -17,9 +17,9 @@ def main():
Session = sessionmaker(bind=engine)
session = Session()
- pool = config.get('paths', 'pool')
- incoming = config.get('paths', 'incoming')
- jobs = config.get('paths', 'job')
+ pool = config.get('paths', 'pool_path')
+ incoming = config.get('paths', 'incoming_path')
+ jobs = config.get('paths', 'jobs_path')
if args.flags.contains('--drop'):
diff --git a/debile/master/config.py b/debile/master/config.py
index 62ffa19..319e3eb 100644
--- a/debile/master/config.py
+++ b/debile/master/config.py
@@ -1,7 +1,14 @@
import ConfigParser
-class Config(ConfigParser.ConfigParser):
+class IncompleteConfig(Exception):
+ def __init__(self, section, option):
+ self.section = section
+ self.option = option
+ def __str__(self):
+ print " >> Missing option %s in section [%s] in config file" % (self.option, self.section)
+
+class Config(ConfigParser.ConfigParser):
_instance = None
def __new__(cls, *args, **kwargs):
if not cls._instance:
@@ -11,7 +18,25 @@ class Config(ConfigParser.ConfigParser):
def __init__(self, location="/etc/debile-master.ini"):
ConfigParser.ConfigParser.__init__(self)
self.read(location)
+ self.verify()
+
+ def verify(self):
+ # db section
+ self._verify_item("db", "engine")
+ # job section
+ self._verify_item("jobs", "arches")
+ self._verify_item("jobs", "binary")
+ self._verify_item("jobs", "build-enabled")
+ self._verify_item("jobs", "build-flavors")
+ self._verify_item("jobs", "source")
+ # paths section
+ self._verify_item("paths", "debile_fqdn")
+ self._verify_item("paths", "debile_url")
+ self._verify_item("paths", "incoming_path")
+ self._verify_item("paths", "jobs_path")
+ self._verify_item("paths", "pool_path")
+ self._verify_item("paths", "pool_url")
- def verify():
- # TODO, check that after constructor the conf is fine
- return True
+ def _verify_item(self, section, option):
+ if not self.has_option(section, option):
+ raise IncompleteConfig(section, option)
diff --git a/debile/master/incoming.py b/debile/master/incoming.py
index 46dc055..16467c5 100644
--- a/debile/master/incoming.py
+++ b/debile/master/incoming.py
@@ -25,14 +25,14 @@ def process():
# Loop on all users
# See UserRepository documentation for path composition
for u in users:
- source_incoming = os.path.join(config.get('paths', 'incoming'), u.login, 'source')
+ source_incoming = os.path.join(config.get('paths', 'incoming_path'), u.login, 'source')
pcf = lambda x: parse_changes_file(x, source_incoming)
# Process source incoming
with cd(source_incoming):
for changes in fglob("*changes", pcf):
accept_source(changes, u)
- binary_incoming_root = os.path.join(config.get('paths', 'incoming'), u.login)
+ binary_incoming_root = os.path.join(config.get('paths', 'incoming_path'), u.login)
build_flavors = listize(config.get('jobs', 'build-flavors'))
for compiler in build_flavors:
binary_incoming = os.path.join(binary_incoming_root, compiler)
diff --git a/debile/master/server.py b/debile/master/server.py
index 1faa756..f8b0afa 100644
--- a/debile/master/server.py
+++ b/debile/master/server.py
@@ -238,7 +238,7 @@ class DebileMasterInterface(object):
"""
Return the path where we put output files for this job UUID.
"""
- path = os.path.join(config.get('paths', 'job'), str(job_uuid))
+ path = os.path.join(config.get('paths', 'jobs_path'), str(job_uuid))
if not os.path.exists(path):
os.makedirs(path)
return path
diff --git a/skel/debile-master.ini b/skel/debile-master.ini
index ebb0f43..96e73d5 100644
--- a/skel/debile-master.ini
+++ b/skel/debile-master.ini
@@ -41,12 +41,12 @@ debile_fqdn=debile.debian.net
; This has to be the dput target of ricky
; Here will be received the incoming packages to process, this folder will be
; watched by debile-processd
-incoming=/srv/local-mirror/incoming
+incoming_path=/srv/local-mirror/incoming
; The pool meaning that packages are moved here like in an archive to be downloaded
; elsewhere (dget by ethel for instance)
-pool=/srv/local-mirror/pool
+pool_path=/srv/local-mirror/pool
; A public URL to access the system path "pool" defined above, you must install
; some http server (apache, nginx...)
pool_url=http://debile.debian.net/pool
; The place we put the reports in, you can download them through debuild.me links
-job=/srv/local-mirror/jobs
+jobs_path=/srv/local-mirror/jobs
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-debile/debile-master.git
More information about the Pkg-debile-commits
mailing list