Skip to content

Commit

Permalink
[bug] rename mail get-token commands
Browse files Browse the repository at this point in the history
otherwise the command cannot be dispatched.
return dicts instead of strings too.
  • Loading branch information
kalikaneko committed Aug 15, 2016
1 parent c8520be commit 7deebbc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/leap/bitmask/cli/mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ class Mail(command.Command):
enable Start service
disable Stop service
status Display status about service
get-token Returns token for the mail service
get-smtp-certificate Downloads a new smtp certificate
get_token Returns token for the mail service
get_smtp_certificate Downloads a new smtp certificate
'''.format(name=command.appname)

commands = ['enable', 'disable', 'status', 'get-token',
'get-smtp-certificate']
commands = ['enable', 'disable', 'status', 'get_token',
'get_smtp_certificate']
3 changes: 2 additions & 1 deletion src/leap/bitmask/core/dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def dispatch(self, service, *parts, **kw):
_method = getattr(self, 'do_' + subcmd.upper(), None)
if not _method:
raise RuntimeError('No such subcommand')
return _method(service, *parts, **kw)
return defer.maybeDeferred(_method, service, *parts, **kw)


class UserCmd(SubCommand):
Expand Down Expand Up @@ -105,6 +105,7 @@ class MailCmd(SubCommand):

@register_method('dict')
def do_ENABLE(self, service, *parts, **kw):
# FIXME -- service doesn't have this method
d = service.do_enable_service(self.label)
return d

Expand Down
8 changes: 4 additions & 4 deletions src/leap/bitmask/core/mail_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,15 +459,15 @@ def hook_on_new_keymanager_instance(self, **kw):
# commands

def do_status(self):
return 'mail: %s' % 'running' if self.running else 'disabled'
status = 'running' if self.running else 'disabled'
return {'mail': status}

def get_token(self):
active_user = self._active_user
if not active_user:
return defer.succeed('NO ACTIVE USER')
return defer.succeed({'user': None})
token = self._service_tokens.get(active_user)
# TODO return just the tuple, no format.
return defer.succeed("MAIL TOKEN (%s): %s" % (active_user, token))
return defer.succeed({'user': active_user, 'token': token})

def do_get_smtp_cert_path(self, userid):
username, provider = userid.split('@')
Expand Down

0 comments on commit 7deebbc

Please sign in to comment.