Permalink
Browse files

WIP: Highlights errors on the console.

git-svn-id: svn://cherokee-project.com/wizards2@6806 5dc97367-97f1-0310-9951-d761b3857238
  • Loading branch information...
alobbs committed Aug 15, 2011
1 parent 22c0a2f commit e56a859ee0949753afcadbe851427c4ca9f1294c
Showing with 23 additions and 3 deletions.
  1. +23 −3 cherokee-wizard
View
@@ -38,14 +38,34 @@ USAGE = \
"Report bugs to http://bugs.cherokee-project.com\n"
+# ANSI Colors
+#
+ESC = chr(27) + '['
+RESET = '%s0m' %(ESC)
+
+def green (s): return ESC + '0;32m' + s + RESET
+def red (s): return ESC + '0;31m' + s + RESET
+def yellow (s): return ESC + '1;33m' + s + RESET
+def blue (s): return ESC + '0;34m' + s + RESET
+
+
+# Util
+#
+def print_error (msg, severity="ERROR"):
+ sys.stdout.write ("%s: %s\n" %(red(severity), msg))
+ sys.stdout.flush ()
+
+
+# Installer
+#
def install (wizard_path, params):
# Log
Install_Log.only_print = True
# Load the module
mod = Wizard2.Load_Module (wizard_path)
if not mod:
- print "ERROR: Could not load '%s'" %(wizard_path)
+ print_error ("Could not load '%s'" %(wizard_path))
return 1
# Launch the wizard
@@ -63,10 +83,10 @@ def install (wizard_path, params):
errors = phase()
if errors:
for err in set(errors):
- print err
+ print_error (err)
return 1
- print "ok"
+ print yellow("ok")
# Save the config
CTK.cfg.save()

0 comments on commit e56a859

Please sign in to comment.