diff options
| author | Devendra | 2014-04-23 02:10:55 +0530 | 
|---|---|---|
| committer | Devendra | 2014-04-23 02:10:55 +0530 | 
| commit | b2f1e0ed2337b61073a595eaf36afd718a21a3fe (patch) | |
| tree | 71e4a6802b488b5b2e31d50b14be983a0595c9df | |
| parent | f1ce4ae3179d51e88aca266d107531209d2d98a2 (diff) | |
| download | pubnub-python-b2f1e0ed2337b61073a595eaf36afd718a21a3fe.tar.bz2 | |
fixing issues reported by Dara in dev console
| -rw-r--r-- | common/PubnubCoreAsync.py | 1 | ||||
| -rw-r--r-- | python-tornado/Pubnub.py | 1 | ||||
| -rw-r--r-- | python-twisted/Pubnub.py | 1 | ||||
| -rw-r--r-- | python/Pubnub.py | 1 | ||||
| -rwxr-xr-x | python/examples/dev-console.py | 55 | 
5 files changed, 33 insertions, 26 deletions
| diff --git a/common/PubnubCoreAsync.py b/common/PubnubCoreAsync.py index 30d337c..db10575 100644 --- a/common/PubnubCoreAsync.py +++ b/common/PubnubCoreAsync.py @@ -69,6 +69,7 @@ class PubnubCoreAsync(PubnubBase):          self._connect                   = None          self._tt_lock                   = _tt_lock          self._channel_list_lock         = _channel_list_lock +        self._connect                   = lambda: None      def get_channel_list(self, channels):          channel = '' diff --git a/python-tornado/Pubnub.py b/python-tornado/Pubnub.py index 73cb62d..5607df0 100644 --- a/python-tornado/Pubnub.py +++ b/python-tornado/Pubnub.py @@ -666,6 +666,7 @@ class PubnubCoreAsync(PubnubBase):          self._connect                   = None          self._tt_lock                   = _tt_lock          self._channel_list_lock         = _channel_list_lock +        self._connect                   = lambda: None      def get_channel_list(self, channels):          channel = '' diff --git a/python-twisted/Pubnub.py b/python-twisted/Pubnub.py index 22d647b..f5259ac 100644 --- a/python-twisted/Pubnub.py +++ b/python-twisted/Pubnub.py @@ -666,6 +666,7 @@ class PubnubCoreAsync(PubnubBase):          self._connect                   = None          self._tt_lock                   = _tt_lock          self._channel_list_lock         = _channel_list_lock +        self._connect                   = lambda: None      def get_channel_list(self, channels):          channel = '' diff --git a/python/Pubnub.py b/python/Pubnub.py index bca3ee5..d41f626 100644 --- a/python/Pubnub.py +++ b/python/Pubnub.py @@ -666,6 +666,7 @@ class PubnubCoreAsync(PubnubBase):          self._connect                   = None          self._tt_lock                   = _tt_lock          self._channel_list_lock         = _channel_list_lock +        self._connect                   = lambda: None      def get_channel_list(self, channels):          channel = '' diff --git a/python/examples/dev-console.py b/python/examples/dev-console.py index 52ed910..c4c6bc8 100755 --- a/python/examples/dev-console.py +++ b/python/examples/dev-console.py @@ -70,21 +70,37 @@ class color:     UNDERLINE = '\033[4m'     END = '\033[0m' +from datetime import datetime  def print_ok(msg, channel=None): -    chstr = " [Channel : " + channel + "] " if channel is not None else ""  +    chstr = color.PURPLE + "[" + datetime.now().strftime('%Y-%m-%d %H:%M:%S') + "] " + color.END +    chstr += color.CYAN + "[Channel : " + channel + "] " if channel is not None else "" + color.END      try: -        print(color.GREEN + chstr + str(msg) + color.END) -    except: +        print(chstr + color.GREEN +  str(msg) + color.END) +    except Exception as e:          print(msg)  def print_error(msg, channel=None): -    chstr = " [Channel : " + channel + "] " if channel is not None else ""  +    chstr = color.PURPLE + "[" + datetime.now().strftime('%Y-%m-%d %H:%M:%S') + "] " + color.END +    chstr += color.CYAN + "[Channel : " + channel + "] " if channel is not None else "" + color.END      try: -        print(color.RED + color.BOLD +  chstr + str(msg) + color.END) +        print( chstr + color.RED + color.BOLD +str(msg) + color.END)      except:          print(msg) +import threading + +def kill_all_threads(): +    for thread in threading.enumerate(): +        if thread.isAlive(): +            try: +                thread._Thread__stop() +            except Exception as e: +                pass +                #print(e) +                #thread.exit() +                #print(str(thread.getName()) + ' could not be terminated') +  def get_input(message, t=None):      while True:          try: @@ -92,6 +108,8 @@ def get_input(message, t=None):                  command = raw_input(message)              except NameError:                  command = input(message) +            except KeyboardInterrupt: +                return None              if t is not None and t == bool:                  if command in ["True", "true", "1", 1, "y", "Y", "yes", "Yes", "YES"]:                      return True @@ -111,9 +129,11 @@ def get_input(message, t=None):  def _publish_command_handler():      channel = get_input("[PUBLISH] Enter Channel Name ", str) +    if channel is None: +        return      while True: -        message = get_input("[PUBLISH] Enter Message ( QUIT for exit from publish mode ) ") -        if message == 'QUIT' or message == 'quit': +        message = get_input("[PUBLISH] Enter Message ( QUIT or CTRL-C for exit from publish mode ) ") +        if message == 'QUIT' or message == 'quit' or message == None:              return            def _callback(r):              print_ok(r) @@ -214,19 +234,6 @@ def _here_now_command_handler(): -import threading - -def kill_all_threads(): -    for thread in threading.enumerate(): -        if thread.isAlive(): -            try: -                thread._Thread__stop() -            except Exception as e: -                pass -                #print(e) -                #thread.exit() -                #print(str(thread.getName()) + ' could not be terminated') -  commands = []  commands.append({"command" : "publish", "handler" : _publish_command_handler}) @@ -252,12 +259,8 @@ def get_help():  while True: -    try: -        command = get_input(color.BLUE + get_help(), int) -    except KeyboardInterrupt: -        kill_all_threads() -        break -    if command == len(commands) - 1: +    command = get_input(color.BLUE + get_help(), int) +    if command == len(commands) - 1 or command is None:          kill_all_threads()          break      if command >= len(commands): | 
