summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2011-06-29 16:19:50 +0100
committerLars Wirzenius <liw@liw.fi>2011-06-29 16:19:50 +0100
commite14a0df100e896b3a36b1839a8a0863185857b35 (patch)
treed0fafb7a96fc11c64c3e68ff5c3782566493a700
parent39a5154dfb8173800751e5ca6e938e63a3808b1e (diff)
downloadvmdebootstrap-e14a0df100e896b3a36b1839a8a0863185857b35.tar.gz
Use with to deal with an open file.
-rwxr-xr-xvmdebootstrap5
1 files changed, 2 insertions, 3 deletions
diff --git a/vmdebootstrap b/vmdebootstrap
index 67e5a40..f859587 100755
--- a/vmdebootstrap
+++ b/vmdebootstrap
@@ -172,9 +172,8 @@ class VmDebootstrap(cliapp.Application):
def set_hostname(self, rootdir):
hostname = self.settings['hostname']
- f = open(os.path.join(rootdir, 'etc', 'hostname'), 'w')
- f.write(hostname)
- f.close()
+ with open(os.path.join(rootdir, 'etc', 'hostname'), 'w') as f:
+ f.write(hostname)
def set_root_password(self, rootdir):
if self.settings['root-password']: