diff options
author | Bala.FA <bala@gluster.com> | 2011-09-22 14:46:48 +0530 |
---|---|---|
committer | Tim <timothyasir@gluster.com> | 2011-09-23 13:58:03 +0530 |
commit | 562882f58ff56472eba9e8663def40a6b6e2a19a (patch) | |
tree | 5fffe96627d405e5f5d177db03f35a7b89673152 | |
parent | adae8ca0e2d2a7a628c070ad420d6054f6dab77c (diff) |
Cleanup in add_user_cifs_all.py
Signed-off-by: Bala.FA <bala@gluster.com>
-rwxr-xr-x | src/com.gluster.storage.management.gateway.scripts/src/gateway/add_user_cifs_all.py | 27 |
1 files changed, 5 insertions, 22 deletions
diff --git a/src/com.gluster.storage.management.gateway.scripts/src/gateway/add_user_cifs_all.py b/src/com.gluster.storage.management.gateway.scripts/src/gateway/add_user_cifs_all.py index 33adea0b..9c6329c7 100755 --- a/src/com.gluster.storage.management.gateway.scripts/src/gateway/add_user_cifs_all.py +++ b/src/com.gluster.storage.management.gateway.scripts/src/gateway/add_user_cifs_all.py @@ -16,36 +16,19 @@ import Utils def getUid(userName): - try: - fp = open(Globals.CIFS_USER_FILE) - content = fp.read() - fp.close() - except IOError, e: - Utils.log("failed to read file %s: %s" % (Globals.CIFS_USER_FILE, str(e))) - return False - - for line in content.strip().split(): - tokens = line.split(":") + lines = Utils.readFile(Globals.CIFS_USER_FILE, lines=True) + for line in lines: + tokens = line.strip().split(":") if tokens[1] == userName: return int(tokens[0]) return None def getLastUid(): - if not os.path.exists(Globals.CIFS_USER_FILE): - return Globals.DEFAULT_UID - try: - fp = open(Globals.CIFS_USER_FILE) - content = fp.read() - fp.close() - except IOError, e: - Utils.log("failed to read file %s: %s" % (Globals.CIFS_USER_FILE, str(e))) - return False - - lines = content.strip().split() + lines = Utils.readFile(Globals.CIFS_USER_FILE, lines=True) if not lines: return Globals.DEFAULT_UID - return int(lines[-1].split(":")[0]) + return int([line.strip().split(':')[0] for line in lines if line.strip()][-1]) def setUid(uid, userName): |