summaryrefslogtreecommitdiff
path: root/lib/spack/spack/tty.py
blob: 4cad0914e6dfd821fe084af89bbde94a81aef716 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import sys
import spack
from spack.color import *

indent = "  "

def msg(message, *args):
    cprint("@*b{==>} @*w{%s}" % cescape(message))
    for arg in args:
        print indent + str(arg)


def info(message, *args, **kwargs):
    format = kwargs.get('format', '*b')
    cprint("@%s{==>} %s" % (format, cescape(message)))
    for arg in args:
        print indent + str(arg)


def verbose(message, *args):
    if spack.verbose:
        info(message, *args, format='*g')


def debug(*args):
    if spack.debug:
        info("Debug: " + message, *args, format='*c')


def error(message, *args):
    info("Error: " + message, *args, format='*r')


def warn(message, *args):
    info("Warning: " + message, *args, format='*Y')


def die(message, *args):
    error(message, *args)
    sys.exit(1)


def pkg(message):
    """Outputs a message with a package icon."""
    import platform
    from version import Version

    mac_ver = platform.mac_ver()[0]
    if mac_ver and Version(mac_ver) >= Version('10.7'):
        print u"\U0001F4E6" + indent,
    else:
        cprint('@*g{[+]} ')
    print message