Revision 5ce3ce4f snf-astakos-app/astakos/im/management/commands/service_add.py

b/snf-astakos-app/astakos/im/management/commands/service_add.py
35 35

  
36 36
from astakos.im.models import Service
37 37

  
38

  
38 39
class Command(BaseCommand):
39 40
    args = "<name> <url> [<icon>]"
40 41
    help = "Register a service"
41
    
42

  
42 43
    def handle(self, *args, **options):
43 44
        if len(args) < 2:
44 45
            raise CommandError("Invalid number of arguments")
45
        
46

  
46 47
        service = Service(name=args[0], url=args[1])
47 48
        if len(args) == 3:
48 49
            service.icon = args[2]
49 50
        try:
50 51
            service.save()
51
            self.stdout.write('Service created with token: %s\n' % service.auth_token)
52
            self.stdout.write(
53
                'Service created with token: %s\n' % service.auth_token)
52 54
        except Exception, e:
53
            raise CommandError(e)
55
            raise CommandError(e)

Also available in: Unified diff