Removed /usr/local from CDPATH
[clearscm.git] / aws / display.py
1 #########################################################################
2 #
3 # File:         Display.py
4 # Description:  Display module
5 #
6 #########################################################################
7 import sys, os
8 from libxml2mod import xmlXPathNewValueTree
9
10 if os.getenv('DEBUG') != None:
11   DEBUG = True
12 else:
13   DEBUG = False
14
15 if os.getenv('VERBOSE') != None:
16   VERBOSE = True
17 else:
18   VERBOSE = False
19
20 def caller_name():
21     frame=inspect.currentframe()
22     frame=frame.f_back.f_back
23     code=frame.f_code
24     return code.co_filename
25
26 def display(msg = '', handle = sys.stdout, nolinefeed = False):
27   handle.write(msg)
28   
29   if nolinefeed == False:
30     handle.write("\n")
31
32 def display_err(msg, handle = sys.stderr, nolinefeed = False):
33
34   handle.write(msg)
35
36   if nolinefeed == False:
37     handle.write("\n") 
38
39 def debug(msg, handle = sys.stderr, nolinefeed = False, level = 0):
40   global DEBUG
41
42   if DEBUG == False:
43     return
44
45   display_err('DEBUG: ' + msg, handle, nolinefeed)
46
47 def error(msg, errno = 0, handle = sys.stderr, nolinefeed = False):
48   display_err('ERROR: {0}'.format(msg), handle, nolinefeed)
49
50   if errno != 0:
51     sys.exit(errno) 
52
53 def warning(msg, warnno = 0, handle = sys.stderr, nolinefeed = False):
54    display_err('WARNING:' + msg, handle, nolinefeed)
55
56 def verbose(msg, handle = sys.stdout):
57   global VERBOSE
58
59   if VERBOSE == False:
60     return
61
62   display(msg, handle)
63
64 def set_verbose(newValue):
65   global VERBOSE
66   
67   oldValue = VERBOSE
68
69   VERBOSE = newValue
70
71   return oldValue
72
73 def set_debug(newValue):
74   global DEBUG
75   
76   oldValue = DEBUG
77
78   DEBUG = newValue
79
80   return oldValue