diff options
| author | Devendra | 2014-06-20 09:20:42 +0530 | 
|---|---|---|
| committer | Devendra | 2014-06-20 09:20:42 +0530 | 
| commit | 73046c29970d257332867fa9d07d0860e03de089 (patch) | |
| tree | e77c36ba4aa25b47a801ff7c1492fad1433f0749 /python/examples | |
| parent | 123e7cdd041177314781131d3f0ce50c1d165f3b (diff) | |
| download | pubnub-python-73046c29970d257332867fa9d07d0860e03de089.tar.bz2 | |
fixed color bugs on prompts
Diffstat (limited to 'python/examples')
| -rw-r--r-- | python/examples/console.py | 24 | 
1 files changed, 10 insertions, 14 deletions
| diff --git a/python/examples/console.py b/python/examples/console.py index 229db93..d9087c0 100644 --- a/python/examples/console.py +++ b/python/examples/console.py @@ -93,9 +93,8 @@ def get_date():  def print_ok_normal(msg, channel=None):      if msg is None:          return -    chstr = color.colorize("[" + get_date() + "] ", "magenta") -    chstr += color.colorize("[Channel : " + channel + -                            "] " if channel is not None else "", "cyan") +    chstr = "[" + color.colorize(get_date(), "magenta") + "] " +    chstr += "[" + color.colorize("Channel : " + channel if channel is not None else "", "cyan") + "] "       try:          print_console(of, (chstr + color.colorize(str(msg), "green")))      except UnicodeEncodeError as e: @@ -107,9 +106,8 @@ def print_ok_normal(msg, channel=None):  def print_error_normal(msg, channel=None):      if msg is None:          return -    chstr = color.colorize("[" + get_date() + "] ", "magenta") -    chstr += color.colorize("[Channel : " + channel + -                            "] " if channel is not None else "", "cyan") +    chstr = "[" + color.colorize(get_date(), "magenta") + "] " +    chstr += "[" + color.colorize("Channel : " + channel if channel is not None else "", "cyan") + "] "       try:          print_console(of, (chstr + color.colorize(color.colorize(              str(msg), "red"), "bold"))) @@ -120,9 +118,8 @@ def print_error_normal(msg, channel=None):  def print_ok_pretty(msg, channel=None):      if msg is None:          return -    chstr = color.colorize("[" + get_date() + "] ", "magenta") -    chstr += color.colorize("[Channel : " + channel + -                            "] " if channel is not None else "", "cyan") +    chstr = "[" + color.colorize(get_date(), "magenta") + "] " +    chstr += "[" + color.colorize("Channel : " + channel if channel is not None else "", "cyan") + "] "       try:          print_console(of, (chstr + highlight(json.dumps(msg, indent=2))))      except UnicodeEncodeError as e: @@ -134,9 +131,8 @@ def print_ok_pretty(msg, channel=None):  def print_error_pretty(msg, channel=None):      if msg is None:          return -    chstr = color.colorize("[" + get_date() + "] ", "magenta") -    chstr += color.colorize("[Channel : " + channel + -                            "] " if channel is not None else "", "cyan") +    chstr = "[" + color.colorize(get_date(), "magenta") + "] " +    chstr += "[" + color.colorize("Channel : " + channel if channel is not None else "", "cyan") + "] "       try:          print_console(of, (chstr + color.colorize(color.colorize(              "ERROR: ", "red"), "bold") + @@ -350,7 +346,7 @@ class DevConsole(Cmd):          self.disable_pretty = False      def get_channel_origin(self): -        cho = " [" +        cho = ""          channels = get_channel_array()          channels_str = ",".join(channels)          sl = self.channel_truncation @@ -366,7 +362,7 @@ class DevConsole(Cmd):          origin = pubnub.get_origin().split("://")[1]          origin += color.colorize(" (SSL)", "green") if pubnub.get_origin(          ).split("://")[0] == "https" else "" -        return cho + color.colorize(origin, "blue") + "] > " +        return " [" + cho + color.colorize(origin, "blue") + "] > "      def get_prompt(self):          prompt = "[" + get_date() + "]" | 
