From 550323273d6d64a3eb9fc66b5027c995f497f1df Mon Sep 17 00:00:00 2001 From: "Bala.FA" Date: Thu, 22 Sep 2011 14:48:55 +0530 Subject: Cleanup in create_volume_cifs_all.py Signed-off-by: Bala.FA --- .../src/gateway/create_volume_cifs_all.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/com.gluster.storage.management.gateway.scripts/src/gateway/create_volume_cifs_all.py b/src/com.gluster.storage.management.gateway.scripts/src/gateway/create_volume_cifs_all.py index 59e74bed..7186283c 100755 --- a/src/com.gluster.storage.management.gateway.scripts/src/gateway/create_volume_cifs_all.py +++ b/src/com.gluster.storage.management.gateway.scripts/src/gateway/create_volume_cifs_all.py @@ -16,18 +16,13 @@ import Utils def addVolumeCifsConf(volumeName, userList): - try: - fp = open(Globals.CIFS_VOLUME_FILE) - content = fp.read() - fp.close() - except IOError, e: - Utils.log("failed to read file %s: %s" % (Globals.CIFS_VOLUME_FILE, str(e))) - content = "" - + lines = Utils.readFile(Globals.CIFS_VOLUME_FILE, lines=True) try: fp = open(Globals.CIFS_VOLUME_FILE, "w") - for line in content.split(): - if line.split(":")[0] != volumeName: + for line in lines: + if not line.strip(): + continue + if line.strip().split(":")[0] != volumeName: fp.write("%s\n" % line) fp.write("%s:%s\n" % (volumeName, ":".join(userList))) fp.close() -- cgit