~devcamcar/django-nova/fix_get_user

« back to all changes in this revision

Viewing changes to src/django_nova/adminclient.py

  • Committer: Devin Carlen
  • Date: 2011-01-28 20:35:31 UTC
  • Revision ID: devin.carlen@gmail.com-20110128203531-ojqtxsjx0zbhwgqc
Made adminclient get_user return None instead of throwing EC2Exception if requested user not available

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
import base64
23
23
import boto
 
24
import boto.exception
24
25
import httplib
25
26
import re
26
27
import string
332
333
 
333
334
    def get_user(self, name):
334
335
        """ grab a single user by name """
335
 
        user = self.apiconn.get_object('DescribeUser', {'Name': name}, UserInfo)
336
 
 
337
 
        if user.username != None:
338
 
            return user
 
336
        try:
 
337
            return self.apiconn.get_object('DescribeUser', {'Name': name}, UserInfo)
 
338
        except boto.exception.BotoServerError, e:
 
339
            if e.status == 400 and e.error_code == 'NotFound':
 
340
                return None
 
341
            raise
339
342
 
340
343
    def has_user(self, username):
341
344
        """ determine if user exists """