Mercurial > gub
changeset 3395:47d96728825e
Let repository commands go through oslog, uniformise load_module
and kludge debian.linux-headers-py include (where's my darcsum :-(.
author | Jan Nieuwenhuizen <janneke@gnu.org> |
---|---|
date | Wed, 02 May 2007 20:55:40 +0200 |
parents | eb2fe94b5b57 |
children | 144d9e4c5e2f |
files | gub/cross.py gub/gubb.py gub/misc.py gub/repository.py gub/specs/debian/__init__.py gub/specs/linux-headers.py |
diffstat | 5 files changed, 30 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/gub/cross.py Wed May 02 17:40:00 2007 +0200 +++ b/gub/cross.py Wed May 02 20:55:40 2007 +0200 @@ -141,17 +141,14 @@ return cross_module_cache[platform] import re - desc = ('.py', 'U', 1) - base = re.sub ('[-0-9].*', '', platform) for name in platform, base: file_name = 'gub/%(name)s.py' % locals () if os.path.exists (file_name): break - file = open (file_name) settings.os_interface.info ('module-name: ' + file_name + '\n') - import imp - module = imp.load_module (base, file, file_name, desc) + import misc + module = misc.load_module (file_name, base) import md5 cross_module_checksums[platform] = md5.md5 (open (file_name).read ()).hexdigest ()
--- a/gub/gubb.py Wed May 02 17:40:00 2007 +0200 +++ b/gub/gubb.py Wed May 02 20:55:40 2007 +0200 @@ -620,6 +620,8 @@ # TODO: junk this, always set repo in __init__ def with_vc (self, repo): self.vc_repository = repo + self.vc_repository.system = self.os_interface.system + self.vc_repository.read_pipe = self.os_interface.read_pipe return self def with_tarball (self, mirror='', version='', format='gz', strip_components=1, name=''): @@ -776,12 +778,10 @@ pass def get_class_from_spec_file (settings, file_name, name): - import imp - + import misc settings.os_interface.info ('reading spec: ' + file_name + '\n') - file = open (file_name) - desc = ('.py', 'U', 1) - module = imp.load_module (name, file, file_name, desc) + module = misc.load_module (file_name, name) + # cross/gcc.py:Gcc will be called: cross/Gcc.py, # to distinguish from specs/gcc.py:Gcc.py base = os.path.basename (name)
--- a/gub/misc.py Wed May 02 17:40:00 2007 +0200 +++ b/gub/misc.py Wed May 02 20:55:40 2007 +0200 @@ -8,15 +8,28 @@ def join_lines (str): return str.replace ('\n', ' ') +def load_module (file_name, name=None): + if not name: + import os + name = os.path.split (os.path.basename (file_name))[0] + file = open (file_name) + desc = ('.py', 'U', 1) + import imp + return imp.load_module (name, file, file_name, desc) -def bind(function, arg1): - def bound(*args, **kwargs): - return function(arg1, *args, **kwargs) +def load_spec (spec_file_name): + import os + # FIXME: should use settings.specdir + specdir = os.getcwd () + '/gub/specs' + return load_module ('%(specdir)s/%(spec_file_name)s.py' % locals ()) +def bind (function, arg1): + def bound (*args, **kwargs): + return function (arg1, *args, **kwargs) return bound def read_pipe (cmd, ignore_errors=False): - print 'executing pipe %s' % cmd + print 'Executing pipe %s' % cmd pipe = os.popen (cmd) val = pipe.read ()
--- a/gub/repository.py Wed May 02 17:40:00 2007 +0200 +++ b/gub/repository.py Wed May 02 20:55:40 2007 +0200 @@ -33,7 +33,7 @@ class Repository: def __init__ (self): - #URG, go through oslog + # Fallback, this will go through oslog self.system = misc.system self.read_pipe = misc.read_pipe
--- a/gub/specs/linux-headers.py Wed May 02 17:40:00 2007 +0200 +++ b/gub/specs/linux-headers.py Wed May 02 20:55:40 2007 +0200 @@ -24,7 +24,11 @@ usr/include/net/route.h ''') -from gub import debian +#urg, shoot /me in foot +#from gub import debian +from gub import misc +debian = misc.load_spec ('debian/linux-kernel-headers') + class Linux_headers__debian (debian.Linux_kernel_headers): def __init__ (self, settings): debian.Linux_kernel_headers.__init__ (self, settings)