From b4f4d14e453aaec849e95268e6327fa07e5ff03e Mon Sep 17 00:00:00 2001 From: "Chris St. Pierre" Date: Wed, 22 Aug 2012 17:09:01 -0400 Subject: fixed handling of regex filename patterns in GroupSpool/EntrySet --- src/lib/Bcfg2/Server/Plugin.py | 5 +++-- src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py | 2 +- src/lib/Bcfg2/Server/Plugins/Decisions.py | 5 +++-- src/lib/Bcfg2/Server/Plugins/Probes.py | 3 ++- src/lib/Bcfg2/Server/Plugins/TGenshi.py | 7 ++++++- src/lib/Bcfg2/Server/Plugins/TemplateHelper.py | 4 ++-- 6 files changed, 17 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/lib/Bcfg2/Server/Plugin.py b/src/lib/Bcfg2/Server/Plugin.py index f858c7b44..f841cef22 100644 --- a/src/lib/Bcfg2/Server/Plugin.py +++ b/src/lib/Bcfg2/Server/Plugin.py @@ -1063,8 +1063,9 @@ class SpecificData(object): class EntrySet(Debuggable): """Entry sets deal with the host- and group-specific entries.""" ignore = re.compile("^(\.#.*|.*~|\\..*\\.(sw[px])|.*\\.genshi_include)$") + basename_is_regex=False - def __init__(self, basename, path, entry_type, encoding, is_regex=False): + def __init__(self, basename, path, entry_type, encoding): Debuggable.__init__(self, name=basename) self.path = path self.entry_type = entry_type @@ -1073,7 +1074,7 @@ class EntrySet(Debuggable): self.infoxml = None self.encoding = encoding - if is_regex: + if self.basename_is_regex: base_pat = basename else: base_pat = re.escape(basename) diff --git a/src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py b/src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py index 4b9403320..fe993ab54 100644 --- a/src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py +++ b/src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py @@ -160,7 +160,7 @@ class CfgEntrySet(Bcfg2.Server.Plugin.EntrySet): import glob submodules = [] for path in __path__: - for submodule in glob.glob("%s/*.py" % path): + for submodule in glob.glob(os.path.join(path, "*.py")): mod = '.'.join(submodule.split("/")[-1].split('.')[:-1]) if mod != '__init__': submodules.append((None, mod, True)) diff --git a/src/lib/Bcfg2/Server/Plugins/Decisions.py b/src/lib/Bcfg2/Server/Plugins/Decisions.py index 78b549c2c..90d9ecbe3 100644 --- a/src/lib/Bcfg2/Server/Plugins/Decisions.py +++ b/src/lib/Bcfg2/Server/Plugins/Decisions.py @@ -14,6 +14,8 @@ class DecisionFile(Bcfg2.Server.Plugin.SpecificData): return [(x.get('type'), x.get('name')) for x in self.contents.xpath('.//Decision')] class DecisionSet(Bcfg2.Server.Plugin.EntrySet): + basename_is_regex = True + def __init__(self, path, fam, encoding): """Container for decision specification files. @@ -24,8 +26,7 @@ class DecisionSet(Bcfg2.Server.Plugin.EntrySet): """ Bcfg2.Server.Plugin.EntrySet.__init__(self, '(white|black)list', path, - DecisionFile, encoding, - is_regex=True) + DecisionFile, encoding) try: fam.AddMonitor(path, self) except OSError: diff --git a/src/lib/Bcfg2/Server/Plugins/Probes.py b/src/lib/Bcfg2/Server/Plugins/Probes.py index cae06b659..7f300ebe0 100644 --- a/src/lib/Bcfg2/Server/Plugins/Probes.py +++ b/src/lib/Bcfg2/Server/Plugins/Probes.py @@ -114,12 +114,13 @@ class ProbeSet(Bcfg2.Server.Plugin.EntrySet): ignore = re.compile("^(\.#.*|.*~|\\..*\\.(tmp|sw[px])|probed\\.xml)$") probename = re.compile("(.*/)?(?P\S+?)(\.(?P(?:G\d\d)|H)_\S+)?$") bangline = re.compile('^#!\s*(?P.*)$') + basename_is_regex = True def __init__(self, path, fam, encoding, plugin_name): self.plugin_name = plugin_name Bcfg2.Server.Plugin.EntrySet.__init__(self, '[0-9A-Za-z_\-]+', path, Bcfg2.Server.Plugin.SpecificData, - encoding, is_regex=True) + encoding) fam.AddMonitor(path, self) def HandleEvent(self, event): diff --git a/src/lib/Bcfg2/Server/Plugins/TGenshi.py b/src/lib/Bcfg2/Server/Plugins/TGenshi.py index c84e0a506..c7335a0c0 100644 --- a/src/lib/Bcfg2/Server/Plugins/TGenshi.py +++ b/src/lib/Bcfg2/Server/Plugins/TGenshi.py @@ -31,7 +31,7 @@ def removecomment(stream): yield kind, data, pos -class TemplateFile: +class TemplateFile(object): """Template file creates Genshi template structures for the loaded file.""" def __init__(self, name, specific, encoding): @@ -121,6 +121,10 @@ class TemplateFile: raise Bcfg2.Server.Plugin.PluginExecutionError('Genshi template loading error: %s' % err) +class TemplateEntrySet(Bcfg2.Server.Plugin.EntrySet): + basename_is_regex = True + + class TGenshi(Bcfg2.Server.Plugin.GroupSpool): """ The TGenshi generator implements a templating @@ -130,5 +134,6 @@ class TGenshi(Bcfg2.Server.Plugin.GroupSpool): name = 'TGenshi' __author__ = 'jeff@ocjtech.us' filename_pattern = 'template\.(txt|newtxt|xml)' + es_cls = TemplateEntrySet es_child_cls = TemplateFile deprecated = True diff --git a/src/lib/Bcfg2/Server/Plugins/TemplateHelper.py b/src/lib/Bcfg2/Server/Plugins/TemplateHelper.py index 79da8da75..224637e3d 100644 --- a/src/lib/Bcfg2/Server/Plugins/TemplateHelper.py +++ b/src/lib/Bcfg2/Server/Plugins/TemplateHelper.py @@ -51,12 +51,12 @@ class HelperModule(Bcfg2.Server.Plugin.SpecificData): class HelperSet(Bcfg2.Server.Plugin.EntrySet): ignore = re.compile("^(\.#.*|.*~|\\..*\\.(sw[px])|.*\.py[co])$") fpattern = '[0-9A-Za-z_\-]+\.py' + basename_is_regex = True def __init__(self, path, fam, encoding, plugin_name): self.plugin_name = plugin_name Bcfg2.Server.Plugin.EntrySet.__init__(self, self.fpattern, path, - HelperModule, encoding, - is_regex=True) + HelperModule, encoding) fam.AddMonitor(path, self) def HandleEvent(self, event): -- cgit v1.2.3-1-g7c22