Hi folks,

We have to do some bulk changes on the labels for a customer, so we 
developed a python script to get the labels for all the users of the 
customer.

It works for the majority of the users, but it is always giving an error for 
4 users, listed below:
- fernanda.lacerda
- marcelo.bandeira
- recepcao
- renata.muricy

The error is 401: Internal exception

As the script works for the 20 remaining users in the domain, I don't think 
it is an API problem, but something at the backend.

Can you help me to see what might be happening?

Best regards,

Eduardo Bortoluzzi Junior

-- 
You received this message because you are subscribed to the Google Groups 
"Google Apps Domain Information and Management APIs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-apps-mgmt-apis?hl=en.

Start...
Processing these users: ['andre.wakimoto', 'carlos.iglesias', 'ezequiel.grin', 
'fabio.cepeda', 'fabricio.avino', 'fernanda.lacerda', 'graziele.pereira', 
'isabella.pacco', 'joao.lima', 'luis.canedo', 'luis.teixeira', 
'marcelo.bandeira', 'marina.valadao', 'mauricio.costa', 'otavio.sasso', 
'patricia.dias', 'phernanda.lima', 'rafael.pontes', 'recepcao', 
'reginaldo.freitas', 'renata.muricy', 'roberto.greco', 'sergio.russo', 
'silvia.vitorelli']

----------------------------------------
User 'andre.wakimoto' OK
----------------------------------------
User 'carlos.iglesias' OK
----------------------------------------
User 'ezequiel.grin' OK
----------------------------------------
User 'fabio.cepeda' OK
----------------------------------------
User 'fabricio.avino' OK
----------------------------------------
User 'fernanda.lacerda' ERR
{'status': 401, 'body': '<HTML>\n<HEAD>\n<TITLE>Internal 
exception</TITLE>\n</HEAD>\n<BODY BGCOLOR="#FFFFFF" 
TEXT="#000000">\n<H1>Internal exception</H1>\n<H2>Error 
401</H2>\n</BODY>\n</HTML>\n', 'reason': 'Internal exception'}
----------------------------------------
User 'graziele.pereira' OK
----------------------------------------
User 'isabella.pacco' OK
----------------------------------------
User 'joao.lima' OK
----------------------------------------
User 'luis.canedo' OK
----------------------------------------
User 'luis.teixeira' OK
----------------------------------------
User 'marcelo.bandeira' ERR
{'status': 401, 'body': '<HTML>\n<HEAD>\n<TITLE>Internal 
exception</TITLE>\n</HEAD>\n<BODY BGCOLOR="#FFFFFF" 
TEXT="#000000">\n<H1>Internal exception</H1>\n<H2>Error 
401</H2>\n</BODY>\n</HTML>\n', 'reason': 'Internal exception'}
----------------------------------------
User 'marina.valadao' OK
----------------------------------------
User 'mauricio.costa' OK
----------------------------------------
User 'otavio.sasso' OK
----------------------------------------
User 'patricia.dias' OK
----------------------------------------
User 'phernanda.lima' OK
----------------------------------------
User 'rafael.pontes' OK
----------------------------------------
User 'recepcao' ERR
{'status': 401, 'body': '<HTML>\n<HEAD>\n<TITLE>Internal 
exception</TITLE>\n</HEAD>\n<BODY BGCOLOR="#FFFFFF" 
TEXT="#000000">\n<H1>Internal exception</H1>\n<H2>Error 
401</H2>\n</BODY>\n</HTML>\n', 'reason': 'Internal exception'}
----------------------------------------
User 'reginaldo.freitas' OK
----------------------------------------
User 'renata.muricy' ERR
{'status': 401, 'body': '<HTML>\n<HEAD>\n<TITLE>Internal 
exception</TITLE>\n</HEAD>\n<BODY BGCOLOR="#FFFFFF" 
TEXT="#000000">\n<H1>Internal exception</H1>\n<H2>Error 
401</H2>\n</BODY>\n</HTML>\n', 'reason': 'Internal exception'}
----------------------------------------
User 'roberto.greco' OK
----------------------------------------
User 'sergio.russo' OK
----------------------------------------
User 'silvia.vitorelli' OK
----------------------------------------
End
#!/usr/bin/python
# -*- coding: utf-8 -*-

'''
Code to test de emailsettings, label retrieving.

Arguments: consumer_key consumer_secret domain user_1 user_2 ... user_n

If no user is done, will list the labels for all users.
'''

import sys
import gdata.apps.service
import gdata.apps.emailsettings.service

SIG_METHOD = gdata.auth.OAuthSignatureMethod.HMAC_SHA1


print "Start..."

# Getting parameters
consumer_key = sys.argv[1]
consumer_secret = sys.argv[2]
domain = sys.argv[3]

if len(sys.argv) > 4:
  users = sys.argv[4:]
else:
  # Getting all users, if needed
  appsServiceClient = gdata.apps.service.AppsService(domain=domain)
  appsServiceClient.SetOAuthInputParameters(SIG_METHOD, consumer_key, consumer_secret=consumer_secret, two_legged_oauth=True)

  for entry in appsServiceClient.GetGeneratorForAllUsers():
        users = [user.login.user_name for user in entry.entry]

print "Processing these users: %s" % users
print

# Get all the labels
for user in users:
  print "-"*40
  emailSettingsService = gdata.apps.emailsettings.service.EmailSettingsService(domain=domain)
  emailSettingsService.SetOAuthInputParameters(SIG_METHOD, consumer_key, consumer_secret=consumer_secret, two_legged_oauth=True, requestor_id="%s@%s" % (user, domain))

  uri = emailSettingsService._serviceUrl("label", user)
  try:
    labelsFeed = emailSettingsService._GetPropertyFeed(uri)
  except Exception, e:
    print "User '%s' ERR" % user
    print e
    continue
  else:
    print "User '%s' OK" % user

##  labels = []  
##  for labelEntry in labelsFeed.entry:
##    for prop in labelEntry.property:
##      if prop.name == "label":
##        labels.append(prop.value)
##  
##  print "Labels for '%s': %s" % (user, labels)
  
print "-"*40
print "End"
eduardo@linux-dudinha:/media/PENDRIVE$ python emailsettings.py <consumer_key> 
<consumer_secret> ciadvogados.com.br fernanda.lacerda
Start...
Processing these users: ['fernanda.lacerda']

----------------------------------------
User 'fernanda.lacerda' ERR
{'status': 401, 'body': '<HTML>\n<HEAD>\n<TITLE>Internal 
exception</TITLE>\n</HEAD>\n<BODY BGCOLOR="#FFFFFF" 
TEXT="#000000">\n<H1>Internal exception</H1>\n<H2>Error 
401</H2>\n</BODY>\n</HTML>\n', 'reason': 'Internal exception'}
----------------------------------------
End
eduardo@linux-dudinha:/media/PENDRIVE$

Reply via email to