On 05/01/2009 05:18 PM, Michael DeHaan wrote:
> Michael DeHaan wrote:
>> Alex Davies wrote:
>>> Hi,
>>>
>>> I've just built a new cobbler machine this evening and have a problem
>>> with snippets that is probably very obvious but I can't work out.
>>>
>>> If I create a completly blank per_profile snippet, suddenly cheetah
>>> throws a wobbly. The relevant line in the .ks file is
>>>
>>> $SNIPPET('partition')
>>>
>>> With this line commented, all works well. With this line in the file
>>> however as soon as I create the correct file in the per_profile
>>> directory it all falls apart:
>>>
>>> [r...@cobbler ~]# cobbler system getks --name=test
>>> # Works fine
>>>
>>> [r...@cobbler partition]# pwd
>>> /var/lib/cobbler/snippets/per_profile/partition
>>> [r...@cobbler partition]# touch centos5-xen-x86_64
>>> [r...@cobbler ~]# cobbler system getks --name=test
>>>
>>> # *** ERROR ***
>>> #
>>> # There is a templating error preventing this file from rendering
>>> correctly.
>>> #
>>> # This is most likely not due to a bug in Cobbler and is something
>>> you can fix.
>>> #
>>> # Look at the message below to see what things are causing problems.
>>> #
>>> # (1) Does the template file reference a $variable that is not defined?
>>> # (2) is there a formatting error in a Cheetah directive?
>>> # (3) Should dollar signs ($) be escaped that are not being escaped?
>>> #
>>> # Try fixing the problem and then investigate to see if this message
>>> goes
>>> # away or changes.
>>> #
>>> #
>>> # module.__init__() argument 1 must be string, not unicode
>>> # File "/usr/lib/python2.4/site-packages/cobbler/templar.py", line
>>> 115, in render
>>> # data_out = str(t)
>>> #
>>> # File "/usr/lib64/python2.4/site-packages/Cheetah/Template.py",
>>> line 982, in __str__
>>> # def __str__(self): return getattr(self, mainMethName)()
>>> #
>>> # File
>>> "cheetah_DynamicallyCompiledCheetahTemplate_1241128756_44_46288.py",
>>> line 146, in respond
>>> #
>>> # File
>>> "cheetah_DynamicallyCompiledCheetahTemplate_1241128756_44_46288.py",
>>> line 92, in __errorCatcher4
>>> #
>>> # File "<string>", line 0, in ?
>>> #
>>> # File "/usr/lib/python2.4/site-packages/cobbler/template_api.py",
>>> line 156, in SNIPPET
>>> # result = BuiltinTemplate.SNIPPET(self, file)
>>> #
>>> # File "DynamicallyCompiledCheetahTemplate.py", line 89, in SNIPPET
>>> #
>>> # File "/usr/lib64/python2.4/site-packages/Cheetah/Template.py",
>>> line 1512, in _handleCheetahInclude
>>> # nestedTemplateClass = compiler.compile(source=source,file=file)
>>> #
>>> # File "/usr/lib/python2.4/site-packages/cobbler/template_api.py",
>>> line 124, in compile
>>> # return Cheetah.Template.Template.compile(*args, **kwargs)
>>> #
>>> # File "/usr/lib64/python2.4/site-packages/Cheetah/Template.py",
>>> line 754, in compile
>>> # mod = new.module(uniqueModuleName)
>>> #
>>>
>>> I'm running cobbler 1.6.3 on CentOS 5.3 (epel testing RPM).
>>>
>>> I know that the output tells me that this probably isnt a bug and
>>> almost certainly me being thick, I would love someone to point me in
>>> the right direction!
>>>
>>> Many thanks,
>>>
>>> Alex
>>> _______________________________________________
>>> cobbler mailing list
>>> [email protected]
>>> https://fedorahosted.org/mailman/listinfo/cobbler
>> Looks like it's this bug in python-cheetah:
>>
>> http://www.nabble.com/module.__init__()-argument-1-must-be-string,-not-unicode-tt15925945.html
>>
>>
>>
>> EPEL 5 has 2.0.1, which is a bit old. I'll ask the maintainer for an
>> update.
>>
>>
>>
>>
>> --Michael
>>
>
> Alex, in the meantime, can you tell me if this workaround fixes the
> problem for you:
>
> diff --git a/cobbler/templar.py b/cobbler/templar.py
> index b58a0b3..f422b20 100644
> --- a/cobbler/templar.py
> +++ b/cobbler/templar.py
> @@ -112,7 +112,7 @@ class Templar:
> # now do full templating scan, where we will also templatify the snippet
> insertions
> t = Template(source=raw_data, errorCatcher="Echo",
> searchList=[search_table])
> try:
> - data_out = str(t)
> + data_out = t.respond()
> except Exception, e:
> if out_path is None:
> return utils.cheetah_exc(e)
>
>
> I can't reproduce the problem on my end, so I'll need your help with
> testing.
>
> --Michael
Didn't fix it on my end:
# *** ERROR ***
#
# There is a templating error preventing this file from rendering correctly.
#
# This is most likely not due to a bug in Cobbler and is something you
can fix.
#
# Look at the message below to see what things are causing problems.
#
# (1) Does the template file reference a $variable that is not defined?
# (2) is there a formatting error in a Cheetah directive?
# (3) Should dollar signs ($) be escaped that are not being escaped?
#
# Try fixing the problem and then investigate to see if this message goes
# away or changes.
#
#
# module.__init__() argument 1 must be string, not unicode
# File "/usr/lib/python2.4/site-packages/cobbler/templar.py", line
115, in render
# data_out = t.respond()
#
# File
"cheetah_DynamicallyCompiledCheetahTemplate_1241191527_01_49557.py",
line 438, in respond
#
# File
"cheetah_DynamicallyCompiledCheetahTemplate_1241191527_01_49557.py",
line 183, in __errorCatcher17
#
# File "<string>", line 0, in ?
#
# File "/usr/lib/python2.4/site-packages/cobbler/template_api.py",
line 156, in SNIPPET
# result = BuiltinTemplate.SNIPPET(self, file)
#
# File "DynamicallyCompiledCheetahTemplate.py", line 89, in SNIPPET
#
# File "/usr/lib64/python2.4/site-packages/Cheetah/Template.py", line
1512, in _handleCheetahInclude
# nestedTemplateClass = compiler.compile(source=source,file=file)
#
# File "/usr/lib/python2.4/site-packages/cobbler/template_api.py",
line 124, in compile
# return Cheetah.Template.Template.compile(*args, **kwargs)
#
# File "/usr/lib64/python2.4/site-packages/Cheetah/Template.py", line
754, in compile
# mod = new.module(uniqueModuleName)
#
_______________________________________________
cobbler mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/cobbler