I am trying to take Redhat kickstart files and modify them in python before using them in server setup. My application uses python to curl the kickstart source file from my Redhat Satellite server, then I do the replacement of the string with specific values ββin the kickstart file. When I twist the file in python, it returns as a multi-line string, which is what I need for redhat kickstart to correctly interpret the file. But when I return a string variable through one of these frameworks (web2py, bottle, flask), something happens and it does not return it as a multi-line string, I need to save the exact format of the source file, except for the areas I change. I donβt want to put kickstart files into the templates, because I manage them through the satellite, if I twist the file from the satellite, then it picks up any changes without thinking about entering the template for all the time. Then in the template or something, I either return the line without the template, or to the template file, I transfer only 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 my vula method. It returns the file exactly as I need it. But again, something happens between this and returns 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 using Bottle as a framework, but I found an expression that says they are not able to return multi-line strings, so scratch this. I moved to Flux, but now Flux is doing the same. I'm still learning python and maybe I am doing something wrong, but I need help to get this to work correctly. I would like to output a multi-line string. I understand that you are using either
""" or '''
for multi-line lines, but even after you do this and send it through the framework, it will print on the screen as one continuous line. What am I doing wrong? As a last resort, I will be forced to put kickstart files into templates if I cannot output multi-line strings.