Part of the problem appears to be the path to the cfg file.
I found that if I give it a full path name -- /var/lib/cobbler/snippits/mysettings.cfg --
then the script goes through !
So the next question is : Is there an environment setting available to me that would give
me the path to the snippets directory ? Or do I need to code it in myself in some fashion
?
“Sometimes I think the surest sign that intelligent life exists elsewhere in the universe
is that none of it has tried to contact us.”
Bill Waterson (Calvin & Hobbes)
----- Dan White <ygor(a)comcast.net> wrote:
I have some python code that does what I want to do in a snippet, but
I cannot translate it into something that will get past the cheetah compile/conversion.
Just a few lines - here they are:
<python code>
import sys, ConfigParser
cf=ConfigParser.ConfigParser()
sys.stdout.write("cf=")
print cf
list=cf.read ( 'mysettings.cfg' )
sys.stdout.write("cfg file=")
print list
sys.stdout.write("sections=")
print cf.sections()
print cf.get ( 'MySection', 'field1' )
print cf.get ( 'MySection', 'field2' )
</python code>
The file (mysettings.cfg) contains:
[MySection]
field1 = this
field2 = that
When I execute this python script, I get this output:
cf=<ConfigParser.ConfigParser instance at (address)>
cfg file=['mysettings.cfg']
sections=[MySection]
this
that
Now to the cobbler/cheetah snippet:
<snippet>
#import ConfigParser
#set $cf=$ConfigParser.ConfigParser()
#echo 'cf=>'
#echo $cf
#echo '\n'
#set $list=$cf.read ( 'mysettings.cfg' )
#echo 'cfg file=>'
#echo $list
#echo '\n'
#set $sec = $cf.sections()
#echo 'sections=>'
#echo $sec
#echo '\n'
#set $one = $cf.get ( 'MySection', 'field1' )
#echo $one
#set $two = $cf.get ( 'MySection', 'field2' )
#echo $two
</snippet>
But the cheetah fails in an odd (to me) way.
First of all, the line:
#set $list=$cf.read ( 'mysettings.cfg' )
fails unless I change it to :
#set $list= cf.read ( 'mysettings.cfg' )
and then I get the following output:
cf=<ConfigParser.ConfigParser instance at (address)>
cfg file=[]
sections=[]
and then the script will fail on the "get" method calls
Any suggestions / clues out there ?
“Sometimes I think the surest sign that intelligent life exists elsewhere in the universe
is that none of it has tried to contact us.”
Bill Waterson (Calvin & Hobbes)
_______________________________________________
cobbler mailing list
cobbler(a)lists.fedorahosted.org
https://fedorahosted.org/mailman/listinfo/cobbler