I am trying to take Redhat kickstart files and modify them in python before using them in a server setup. My app uses python to curl the original kickstart file from my Redhat Satellite server then I'm doing a string replace on certain values in the kickstart file. When I curl the file in python it comes back as a multi-line string, which is what I need in order for redhat kickstart to interpret the file correctly. But when I return the string variable through one of these frameworks (web2py, bottle, flask) something is happening and it is not returning it as a multi-line string, I need it to preserve the exact format of the original file besides the areas I change. I don't want to put my kickstart files in templates because I manage them through satellite, if I curl the file from satellite then it picks up any modifications without needing to go into the template ever time. Then in a template or something I either return the string without a template or in a template file I only pass 1 variable to the template as the entire kickstart file.
@route('/kickstart/<name>')
def kickstart(name):
ks = vula.kickstarter.kickstart.Kickstarter()
ks_file = ks.getKickstartFile()
return pystache.render('{{kickstart}}', {'kickstart': ks_file})
Here is the method in my vula package. It returns the file exactly the way I need it. But again something is happening between this and returning this value through the framework.
def getKickstartFile(self):
response = urllib2.urlopen('https://my-satellite-server/core-kickstarter')
ks_file = response.read()
return ks_file
I started off using Bottle as a framework but I found a statement that says they are not capable of returning multi-line strings, so scratch that. I moved over to Flask but currently Flask is doing the same thing. I am still learning python and possibly I'm doing something wrong, but I need any help possible to get this working correctly. I would like to output a multi-line string. I understand that you use either
""" or '''
for multi-line strings, but even after you do that and send it through a framework it will still print to the screen as one continuous line. What am I doing wrong? As a vary last resort I will be forced to put the kickstart files into templates if I cannot output multi-line strings.
<br>and not\n, but in your case of course you don't need <br>, you just don't see new lines but as for console it should be fine...