mirror of
https://github.com/GAM-team/GAM.git
synced 2026-07-03 20:31:35 +00:00
Fix error handling for nonexistent users in data transfers (#367)
This commit is contained in:
@@ -2041,7 +2041,7 @@ def convertToUserID(user):
|
|||||||
if user.find(u'@') == -1:
|
if user.find(u'@') == -1:
|
||||||
user = u'%s@%s' % (user, GC_Values[GC_DOMAIN])
|
user = u'%s@%s' % (user, GC_Values[GC_DOMAIN])
|
||||||
try:
|
try:
|
||||||
return callGAPI(cd.users(), u'get', throw_reasons=[u'notFound'], userKey=user, fields=u'id')[u'id']
|
return callGAPI(cd.users(), u'get', throw_reasons=[u'userNotFound', u'badRequest', u'forbidden'], userKey=user, fields=u'id')[u'id']
|
||||||
except googleapiclient.errors.HttpError:
|
except googleapiclient.errors.HttpError:
|
||||||
print u'ERROR: no such user %s' % user
|
print u'ERROR: no such user %s' % user
|
||||||
sys.exit(3)
|
sys.exit(3)
|
||||||
@@ -2049,7 +2049,7 @@ def convertToUserID(user):
|
|||||||
def convertUserIDtoEmail(uid):
|
def convertUserIDtoEmail(uid):
|
||||||
cd = buildGAPIObject(u'directory')
|
cd = buildGAPIObject(u'directory')
|
||||||
try:
|
try:
|
||||||
return callGAPI(cd.users(), u'get', throw_reasons=[u'notFound'], userKey=uid, fields=u'primaryEmail')[u'primaryEmail']
|
return callGAPI(cd.users(), u'get', throw_reasons=[u'userNotFound', u'badRequest', u'forbidden'], userKey=uid, fields=u'primaryEmail')[u'primaryEmail']
|
||||||
except googleapiclient.errors.HttpError:
|
except googleapiclient.errors.HttpError:
|
||||||
return u'uid:{0}'.format(uid)
|
return u'uid:{0}'.format(uid)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user