Commit 9d58a56b authored by owsla's avatar owsla

Fix user_group.py to run on native Windows, which lacks grp and pwd Python

modules. (Patch from Fred Gansevles)


git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup@903 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
parent 362177db
New in v1.1.17 (????/??/??)
---------------------------
Fix user_group.py to run on native Windows, which lacks grp and pwd Python
modules. (Patch from Fred Gansevles)
Optimize --check-destination and other functions by determining the increment
files server-side instead of client-side. (Patch from Josh Nisly)
......
......@@ -30,7 +30,11 @@ objects should only be used on the destination.
"""
import grp, pwd
try:
import grp, pwd
except ImportError:
pass
import log, Globals
############ "Private" section - don't use outside user_group ###########
......@@ -52,7 +56,7 @@ def uname2uid(uname):
try: return uname2uid_dict[uname]
except KeyError:
try: uid = pwd.getpwnam(uname)[2]
except KeyError: uid = None
except (KeyError, NameError): uid = None
uname2uid_dict[uname] = uid
return uid
......@@ -62,7 +66,7 @@ def gname2gid(gname):
try: return gname2gid_dict[gname]
except KeyError:
try: gid = grp.getgrnam(gname)[2]
except KeyError: gid = None
except (KeyError, NameError): gid = None
gname2gid_dict[gname] = gid
return gid
......@@ -163,7 +167,7 @@ def uid2uname(uid):
try: return uid2uname_dict[uid]
except KeyError:
try: uname = pwd.getpwuid(uid)[0]
except (KeyError, OverflowError), e: uname = None
except (KeyError, OverflowError, NameError), e: uname = None
uid2uname_dict[uid] = uname
return uname
......@@ -172,7 +176,7 @@ def gid2gname(gid):
try: return gid2gname_dict[gid]
except KeyError:
try: gname = grp.getgrgid(gid)[0]
except (KeyError, OverflowError), e: gname = None
except (KeyError, OverflowError, NameError), e: gname = None
gid2gname_dict[gid] = gname
return gname
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment