# HG changeset patch # User k0s # Date 1259113489 18000 # Node ID 66bfcceea3b44fd692eaf96f46b90d103dcc7f2f # Parent c228832db7702788ccd9636cd5d526bb0a24ff54 improvements to blogme....it works except for a mysterious conncection reset by peer error" diff -r c228832db770 -r 66bfcceea3b4 bitsyblog/blogme.py --- a/bitsyblog/blogme.py Tue Nov 24 19:20:47 2009 -0500 +++ b/bitsyblog/blogme.py Tue Nov 24 20:44:49 2009 -0500 @@ -77,29 +77,31 @@ # get default host, if available if options.host: - if config.has_option('DEFAULTS', 'host'): - print "Make %s the default host? (Y/n): ", - answer = raw_input() - if not anwer.lower().startswith('n'): - _config['default'] = options.host + if not config.has_option('DEFAULTS', 'host'): + _config['default'] = options.host else: if config.has_option('DEFAULTS', 'host'): options.host = config.get('DEFAULTS', 'host') else: print "Enter URL of host: ", - host = raw_input() - _config['default'] = host + options.host = raw_input() + _config['default'] = options.host # determine user name and password fields = [ 'user', 'password' ] for field in fields: - if hasattr(options, field): - if (not config.has_option(options.host, field)) or (config.get(options.host, field) != getattr(options, field)): + has_option = config.has_option(options.host, field) + + if getattr(options, field): + if (not has_option) or (config.get(options.host, field) != getattr(options, field)): _config[field] = getattr(options, field) else: - print "%s: " % field, - setattr(options, field, raw_input()) - _config[field] = getattr(options, field) + if has_option: + setattr(options, field, config.get(options.host, field)) + else: + print "%s: " % field, + setattr(options, field, raw_input()) + _config[field] = getattr(options, field) # write the dotfile if it doesn't exist if _config: @@ -112,7 +114,7 @@ for field in fields: if not config.has_option(options.host, field): config.set(options.host, field, getattr(options, field)) - config.write() + config.write(file(options.config, 'w')) # get the blog if args: