I need some help to create a loop for my program. My problem is that I have to run the script twice, before the file/output registers any changes done to my configuration.
Programming is not my strongest skill - hope someone can be of assistance
UPDATED code:
try:
rescue = cu.rescue(action="get", format="text")
if rescue is None:
print ("No existing rescue configuration.")
print ("Saving rescue configuration.")
cu.rescue(action="save")
else:
print ("Rescue configuration exist:")
print ("Updating rescue configuration")
cu.rescue(action="save")
print (rescue)
except Exception as err:
print (err)
with open("Rescue Config.config", "w") as text_file:
text_file.write(rescue)
indentation matters in python, change the last few lines of your code to this
no need to close the file, this happens automatically when using the
with
statement