Package lib :: Package cuckoo :: Package common :: Module colors
[hide private]
[frames] | no frames]

Source Code for Module lib.cuckoo.common.colors

 1  # Copyright (C) 2010-2014 Cuckoo Foundation. 
 2  # This file is part of Cuckoo Sandbox - http://www.cuckoosandbox.org 
 3  # See the file 'docs/LICENSE' for copying permission. 
 4   
 5  import os 
 6  import sys 
 7   
8 -def color(text, color_code):
9 """Colorize text. 10 @param text: text. 11 @param color_code: color. 12 @return: colorized text. 13 """ 14 # $TERM under Windows: 15 # cmd.exe -> "" (what would you expect..?) 16 # cygwin -> "cygwin" (should support colors, but doesn't work somehow) 17 # mintty -> "xterm" (supports colors) 18 if sys.platform == "win32" and os.getenv("TERM") != "xterm": 19 return text 20 return "\x1b[%dm%s\x1b[0m" % (color_code, text)
21
22 -def black(text):
23 return color(text, 30)
24
25 -def red(text):
26 return color(text, 31)
27
28 -def green(text):
29 return color(text, 32)
30
31 -def yellow(text):
32 return color(text, 33)
33
34 -def blue(text):
35 return color(text, 34)
36
37 -def magenta(text):
38 return color(text, 35)
39
40 -def cyan(text):
41 return color(text, 36)
42
43 -def white(text):
44 return color(text, 37)
45
46 -def bold(text):
47 return color(text, 1)
48