[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [stem/master] Colorizing header banner



commit 1e56973e4cf251b7a29429435b1b97bcf353dbdc
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Sun May 11 16:09:23 2014 -0700

    Colorizing header banner
    
    Colorizing our prompt's initial output, with bolding to better emphasize the
    examples.
---
 stem/interpretor/__init__.py |   13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/stem/interpretor/__init__.py b/stem/interpretor/__init__.py
index 643767d..0e4492e 100644
--- a/stem/interpretor/__init__.py
+++ b/stem/interpretor/__init__.py
@@ -30,6 +30,8 @@ PROMPT = format('>>> ', Color.GREEN, Attr.BOLD) + RESET * 10
 
 STANDARD_OUTPUT = (Color.BLUE, )
 BOLD_OUTPUT = (Color.BLUE, Attr.BOLD)
+HEADER_OUTPUT = (Color.GREEN, )
+HEADER_BOLD_OUTPUT = (Color.GREEN, Attr.BOLD)
 ERROR_OUTPUT = (Attr.BOLD, Color.RED)
 
 settings_path = os.path.join(os.path.dirname(__file__), 'settings.cfg')
@@ -66,10 +68,10 @@ def main():
 
     if not is_tor_running:
       if not stem.util.system.is_available('tor'):
-        print msg('msg.tor_unavailable')
+        print format(msg('msg.tor_unavailable'), *ERROR_OUTPUT)
         sys.exit(1)
       else:
-        print msg('msg.starting_tor')
+        print format(msg('msg.starting_tor'), *HEADER_OUTPUT)
 
         stem.process.launch_tor_with_config(
           config = {
@@ -101,7 +103,12 @@ def main():
     readline.set_completer_delims('\n')
 
     interpretor = stem.interpretor.commands.ControlInterpretor(controller)
-    print msg('msg.startup_banner')
+
+    for line in msg('msg.startup_banner').splitlines():
+      line_format = HEADER_BOLD_OUTPUT if line.startswith('  ') else HEADER_OUTPUT
+      print format(line, *line_format)
+
+    print
 
     while True:
       try:



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits