From bd534cb779c1dc41793e1870c911d923f71d79e7 Mon Sep 17 00:00:00 2001 From: Tony Mack Date: Wed, 6 May 2009 17:20:07 +0000 Subject: [PATCH 1/1] updated, but not complete untill save() is finished --- geni-config-tty | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/geni-config-tty b/geni-config-tty index 7ada0945..003495a6 100755 --- a/geni-config-tty +++ b/geni-config-tty @@ -60,12 +60,29 @@ command_usage += """ variable_usage= """Edit Commands : .\tStops prompting, return to mainloop =\tShows default value -?\tThis help +?\tThis help """ def save(changes, config_file): - - print "save" + cfile = open(config_file, 'r') + newlines = [] + for line in cfile: + newlines.append(line) + for variable in changes: + if line.startswith(variable): + print variable + try: + value = int(changes[variable]) + newlines.append('%s=%s' % (variable, value)) + except: + value = changes[variable] + newlines.append('%s="%s"' % (variable, value)) + from pprint import pprint + pprint(newlines) + cfile.close() + cfile = open(config_file, 'w') + cfile.writelines(newlines) + cfile.close() def get_defaults(): geni_config = Config() @@ -109,7 +126,7 @@ def prompt_variable(variable, default_config): raise Excception ('BailOut') if (answer == "") or (answer == default_value): - return answer + return default_value elif (answer == "."): raise Exception ('BailOut') elif (answer == "?"): -- 2.43.0