From 20f55f6d739451629c4d918319362962bee5a141 Mon Sep 17 00:00:00 2001 From: Devendra Date: Wed, 7 May 2014 18:21:27 +0530 Subject: adding presence channel option to grant and revoke --- python/examples/console.py | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) (limited to 'python') diff --git a/python/examples/console.py b/python/examples/console.py index 3d7ba38..7798340 100644 --- a/python/examples/console.py +++ b/python/examples/console.py @@ -328,9 +328,8 @@ class DevConsole(Cmd): self.prompt = self.get_prompt() return line - def emptyline(self): - self.prompt = get_date() + " [" + color.colorize( - pubnub.get_origin(), "blue") + "] > " + #def emptyline(self): + # self.prompt = self.get_prompt() def cmdloop_with_keyboard_interrupt(self): try: @@ -490,7 +489,10 @@ class DevConsole(Cmd): action='store_true', default=False, help="Write ?"), make_option('-t', '--ttl', action="store", - default=5, help="TTL") + default=5, help="TTL"), + make_option('-p', '--presence', action="store_true", + dest="presence", + default=False, help="Grant on presence channel ?") ]) def do_grant(self, command, opts): opts.channel = self.default_channel \ @@ -506,12 +508,20 @@ class DevConsole(Cmd): opts.read, opts.write, opts.ttl, async=self.async) + if opts.presence is True: + _grant_command_handler(opts.channel + '-pnpres', opts.auth_key, + opts.read, opts.write, + opts.ttl, async=self.async) + @options([make_option('-c', '--channel', action="store", help="Channel on which to revoke"), make_option('-a', '--auth-key', dest="auth_key", action="store", help="Auth Key"), make_option('-t', '--ttl', action="store", - default=5, help="TTL") + default=5, help="TTL"), + make_option('-p', '--presence', action="store_true", + dest="presence", + default=False, help="Revoke on presence channel ?") ]) def do_revoke(self, command, opts): opts.channel = self.default_channel \ @@ -526,6 +536,11 @@ class DevConsole(Cmd): _revoke_command_handler( opts.channel, opts.auth_key, opts.ttl, async=self.async) + if opts.presence is True: + _revoke_command_handler( + opts.channel + '-pnpres', opts.auth_key, + opts.ttl, async=self.async) + @options([make_option('-c', '--channel', action="store", help="Channel on which to revoke"), make_option('-a', '--auth-key', dest="auth_key", action="store", @@ -589,12 +604,12 @@ class DevConsole(Cmd): kill_all_threads() return -1 - def do_EOF(self, args): - kill_all_threads() - return self.do_exit(args) + #def do_EOF(self, args): + # kill_all_threads() + # return self.do_exit(args) - def handler(self, signum, frame): - kill_all_threads() + #def handler(self, signum, frame): + # kill_all_threads() def main(): -- cgit v1.2.3