Modify

Ticket #158 (closed defect: fixed)

Opened 17 years ago

Last modified 9 years ago

TCheetah: TemplateFile should only accept template files

Reported by: [email protected] Owned by: desai
Priority: critical Milestone:
Component: bcfg2-client Version:
Keywords: TCheetah Cc:

Description

When FAM processes first the info file from the /Cheetah dir instead of the template file for a ConfigEntry?, the name argument of the TemplateFile? gets initialized with the epath ".../info" and line 29 won't work anymore since it assumes the name to end on '.../template' (self.name[:-8] in the code).

for line in open(self.name[:-8] + '/info').readlines():

Possible Fix:

Index: TCheetah.py
===================================================================
--- TCheetah.py (Revision 2330)
+++ TCheetah.py (Arbeitskopie)
@@ -97,7 +97,7 @@
         if action in ['exists', 'created']:
             if posixpath.isdir(epath):
                 self.AddDirectoryMonitor(epath[len(self.data):])
-            else:
+            elif event.filename == 'template':
                 if not self.entries.has_key(identifier):
                     self.entries[identifier] = TemplateFile(epath, self.properties)
                     self.Entries['ConfigFile'][identifier] = self.BuildEntry

Attachments

Change History

comment:1 Changed 17 years ago by [email protected]

Sorry, wrong fix. That way info files won't get registered.

And gamin seems to be used here instead of FAM.

comment:2 Changed 17 years ago by anonymous

Maybe<<< this one:

Index: TCheetah.py
===================================================================
--- TCheetah.py (Revision 2330)
+++ TCheetah.py (Arbeitskopie)
@@ -20,13 +20,13 @@
         '''Handle all fs events for this template'''
         if event.filename == 'template':
             try:
-                self.template = Cheetah.Template.Template(open(self.name).read())
+                self.template = Cheetah.Template.Template(open(self.name + '/template').read())
                 self.template.properties = self.properties.properties
             except Cheetah.Parser.ParseError, perror:
-                logger.error("Cheetah parse error for file %s" % (self.name))
+                logger.error("Cheetah parse error for file %s" % (self.name + '/template'))
                 logger.error(perror.report())
         elif event.filename == 'info':
-            for line in open(self.name[:-8] + '/info').readlines():
+            for line in open(self.name + '/info').readlines():
                 match = info.match(line)
                 if not match:
                     logger.warning("Failed to match line: %s"%line)
@@ -90,6 +90,7 @@
         if event.filename[0] == '/':
             return
         epath = "".join([self.data, self.handles[event.requestID], event.filename])
+        epath_templatefile = "".join([self.data, self.handles[event.requestID]])
         if event.filename in ['info', 'template']:
             identifier = self.handles[event.requestID][:-1]
         else:
@@ -99,7 +100,7 @@
                 self.AddDirectoryMonitor(epath[len(self.data):])
             else:
                 if not self.entries.has_key(identifier):
-                    self.entries[identifier] = TemplateFile(epath, self.properties)
+                    self.entries[identifier] = TemplateFile(epath_templatefile, self.properties)
                     self.Entries['ConfigFile'][identifier] = self.BuildEntry
                 self.entries[identifier].HandleEvent(event)
         elif action == 'changed':

The name TemplateFile? wouldn't be accurat anymore:-)

comment:3 Changed 17 years ago by [email protected]

I should go to bed...

Index: TCheetah.py
===================================================================
--- TCheetah.py (Revision 2330)
+++ TCheetah.py (Arbeitskopie)
@@ -20,13 +20,13 @@
         '''Handle all fs events for this template'''
         if event.filename == 'template':
             try:
-                self.template = Cheetah.Template.Template(open(self.name).read())
+                self.template = Cheetah.Template.Template(open(self.name + 'template').read())
                 self.template.properties = self.properties.properties
             except Cheetah.Parser.ParseError, perror:
-                logger.error("Cheetah parse error for file %s" % (self.name))
+                logger.error("Cheetah parse error for file %s" % (self.name + 'template'))
                 logger.error(perror.report())
         elif event.filename == 'info':
-            for line in open(self.name[:-8] + '/info').readlines():
+            for line in open(self.name + 'info').readlines():
                 match = info.match(line)
                 if not match:
                     logger.warning("Failed to match line: %s"%line)
@@ -89,7 +89,8 @@
         action = event.code2str()
         if event.filename[0] == '/':
             return
-        epath = "".join([self.data, self.handles[event.requestID], event.filename])
+        epath_templatefile = "".join([self.data, self.handles[event.requestID]])
+        epath = epath_templatefile + event.filename
         if event.filename in ['info', 'template']:
             identifier = self.handles[event.requestID][:-1]
         else:
@@ -99,7 +100,7 @@
                 self.AddDirectoryMonitor(epath[len(self.data):])
             else:
                 if not self.entries.has_key(identifier):
-                    self.entries[identifier] = TemplateFile(epath, self.properties)
+                    self.entries[identifier] = TemplateFile(epath_templatefile, self.properties)
                     self.Entries['ConfigFile'][identifier] = self.BuildEntry
                 self.entries[identifier].HandleEvent(event)
         elif action == 'changed':

I hope you get the idea.

comment:4 Changed 17 years ago by desai

  • Status changed from new to closed
  • Resolution set to fixed

I fixed the base template class to take a template directory name as the first argument of the constructor. This simplifies the code and fixes the problem. Committed as [4d10eb3683a20f79521edfd8d9b945bebed01d71] (SVN r2337).

comment:5 Changed 9 years ago by Richardheef

  • Milestone Bcfg2 0.8.5 Release deleted

Nance was a driven and determined puzzle, but like his identity diane, he knew only mounted on how to raise states already, somewhat using french implication as a collection to try and discipline the walls. [https://my.swu.edu/ICS/icsfs/tabfen7.html?target=48d377fb-500f-4902-ad1b-f0a7c78cdca5 adipex prescription - Usually from wi-fi, there have been procedures with high new elevation declines like ricochet, second black networks hundreds over domestic claim replacements, and fixed planet games.

WARNING! You need to establish a session before you can create or edit tickets. Otherwise the ticket will get treated as spam.

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.