Permalink
Browse files

Can't use the with statement if we support py2.4

  • Loading branch information...
1 parent 332009f commit 59fde188cb80f286963bf4f529d6c4d5beb9df21 @labisso labisso committed Mar 8, 2010
Showing with 8 additions and 3 deletions.
  1. +8 −3 home/sbin/setup.py
View
11 home/sbin/setup.py
@@ -296,8 +296,11 @@ def perform_setup(self):
webconf.set('nimbusweb', 'ssl.key', relpath(hostkey, webdir))
webconf.set('nimbusweb', 'ca.dir', relpath(cadir, webdir))
- with open(webconfpath, 'wb') as webconffile:
+ try:
+ webconffile = open(webconfpath, 'wb')
webconf.write(webconffile)
+ finally:
+ webconffile.close()
# then setup GT container
gtcontainer.adjust_hostname(hostname, webdir, gtdir, log)
@@ -352,10 +355,12 @@ def main(argv=None):
if opts.configpath:
log.debug("saving settings to %s" % opts.configpath)
try:
- with open(opts.configpath, 'wb') as f:
- config.write(f)
+ f = open(opts.configpath, 'wb')
+ config.write(f)
except:
log.info("Failed to save settings to %s!" % opts.configpath)
+ finally:
+ f.close()
except InvalidInput, e:
msg = "\nProblem with input: %s" % e.msg

0 comments on commit 59fde18

Please sign in to comment.