From 593fe6d4fceaa3c86db77e00a1df3d9639587134 Mon Sep 17 00:00:00 2001 From: Anthony Towns Date: Mon, 14 Jan 2008 03:45:03 +0000 Subject: [PATCH] initial support for local python extensions --- config/debian/dak.conf | 1 + config/debian/extensions.py | 2 ++ dak/dak.py | 34 +++++++++++++++++++++++++++++++++- 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 config/debian/extensions.py diff --git a/config/debian/dak.conf b/config/debian/dak.conf index 4b8412c2..daf7a50e 100644 --- a/config/debian/dak.conf +++ b/config/debian/dak.conf @@ -26,6 +26,7 @@ Dinstall OverrideDisparityCheck "true"; StableDislocationSupport "false"; DefaultSuite "unstable"; + UserExtensions "/srv/ftp.debian.org/dak/config/debian/extensions.py"; QueueBuildSuites { unstable; diff --git a/config/debian/extensions.py b/config/debian/extensions.py new file mode 100644 index 00000000..44bd5c72 --- /dev/null +++ b/config/debian/extensions.py @@ -0,0 +1,2 @@ +import sys + diff --git a/dak/dak.py b/dak/dak.py index f82d74cc..10da0411 100755 --- a/dak/dak.py +++ b/dak/dak.py @@ -28,11 +28,31 @@ ################################################################################ -import sys +import sys, imp import daklib.utils ################################################################################ +class UserExtension: + def __init__(self, user_extension = None): + if user_extension: + m = imp.load_source("dak_userext", user_extension) + d = m.__dict__ + else: + m, d = None, {} + self.__dict__["_module"] = m + self.__dict__["_d"] = d + + def __getattr__(self, a): + if a in self.__dict__: return self.__dict__[a] + if a[0] == "_": raise AttributeError, a + return self._d.get(a, None) + + def __setattr__(self, a, v): + self._d[a] = v + +################################################################################ + def init(): """Setup the list of modules and brief explanation of what they do.""" @@ -143,6 +163,13 @@ Availble commands:""" def main(): """Launch dak functionality.""" + Cnf = daklib.utils.get_conf() + + if Cnf.has_key("Dinstall::UserExtensions"): + userext = UserExtension(Cnf["Dinstall::UserExtensions"]) + else: + userext = UserExtension() + functionality = init() modules = [ command for (command, _) in functionality ] @@ -179,6 +206,11 @@ def main(): # Invoke the module module = __import__(cmdname.replace("-","_")) + + module.dak_userext = userext + userext.dak_module = module + if userext.init is not None: userext.init(cmdname) + module.main() ################################################################################ -- 2.39.2