summaryrefslogtreecommitdiffstats
path: root/scripts/lib/wic/msger.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/lib/wic/msger.py')
-rw-r--r--scripts/lib/wic/msger.py23
1 files changed, 12 insertions, 11 deletions
diff --git a/scripts/lib/wic/msger.py b/scripts/lib/wic/msger.py
index 35b705b867..1b60980296 100644
--- a/scripts/lib/wic/msger.py
+++ b/scripts/lib/wic/msger.py
@@ -16,7 +16,8 @@
16# with this program; if not, write to the Free Software Foundation, Inc., 59 16# with this program; if not, write to the Free Software Foundation, Inc., 59
17# Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17# Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19import os,sys 19import os
20import sys
20import re 21import re
21import time 22import time
22 23
@@ -37,8 +38,8 @@ __ALL__ = ['set_mode',
37# COLORs in ANSI 38# COLORs in ANSI
38INFO_COLOR = 32 # green 39INFO_COLOR = 32 # green
39WARN_COLOR = 33 # yellow 40WARN_COLOR = 33 # yellow
40ERR_COLOR = 31 # red 41ERR_COLOR = 31 # red
41ASK_COLOR = 34 # blue 42ASK_COLOR = 34 # blue
42NO_COLOR = 0 43NO_COLOR = 0
43 44
44PREFIX_RE = re.compile('^<(.*?)>\s*(.*)', re.S) 45PREFIX_RE = re.compile('^<(.*?)>\s*(.*)', re.S)
@@ -47,12 +48,12 @@ INTERACTIVE = True
47 48
48LOG_LEVEL = 1 49LOG_LEVEL = 1
49LOG_LEVELS = { 50LOG_LEVELS = {
50 'quiet': 0, 51 'quiet': 0,
51 'normal': 1, 52 'normal': 1,
52 'verbose': 2, 53 'verbose': 2,
53 'debug': 3, 54 'debug': 3,
54 'never': 4, 55 'never': 4,
55 } 56}
56 57
57LOG_FILE_FP = None 58LOG_FILE_FP = None
58LOG_CONTENT = '' 59LOG_CONTENT = ''
@@ -75,7 +76,7 @@ def _general_print(head, color, msg=None, stream=None, level='normal'):
75 76
76 errormsg = '' 77 errormsg = ''
77 if CATCHERR_BUFFILE_FD > 0: 78 if CATCHERR_BUFFILE_FD > 0:
78 size = os.lseek(CATCHERR_BUFFILE_FD , 0, os.SEEK_END) 79 size = os.lseek(CATCHERR_BUFFILE_FD, 0, os.SEEK_END)
79 os.lseek(CATCHERR_BUFFILE_FD, 0, os.SEEK_SET) 80 os.lseek(CATCHERR_BUFFILE_FD, 0, os.SEEK_SET)
80 errormsg = os.read(CATCHERR_BUFFILE_FD, size) 81 errormsg = os.read(CATCHERR_BUFFILE_FD, size)
81 os.ftruncate(CATCHERR_BUFFILE_FD, 0) 82 os.ftruncate(CATCHERR_BUFFILE_FD, 0)
@@ -158,7 +159,7 @@ def _split_msg(head, msg):
158 return head, msg 159 return head, msg
159 160
160def get_loglevel(): 161def get_loglevel():
161 return (k for k,v in LOG_LEVELS.items() if v==LOG_LEVEL).next() 162 return (k for k, v in LOG_LEVELS.items() if v == LOG_LEVEL).next()
162 163
163def set_loglevel(level): 164def set_loglevel(level):
164 global LOG_LEVEL 165 global LOG_LEVEL