diff options
Diffstat (limited to 'import-layers/yocto-poky/scripts/lib/wic/msger.py')
-rw-r--r-- | import-layers/yocto-poky/scripts/lib/wic/msger.py | 78 |
1 files changed, 2 insertions, 76 deletions
diff --git a/import-layers/yocto-poky/scripts/lib/wic/msger.py b/import-layers/yocto-poky/scripts/lib/wic/msger.py index b73755422..fb8336d94 100644 --- a/import-layers/yocto-poky/scripts/lib/wic/msger.py +++ b/import-layers/yocto-poky/scripts/lib/wic/msger.py @@ -21,18 +21,14 @@ import sys import re import time -__ALL__ = ['set_mode', - 'get_loglevel', +__ALL__ = ['get_loglevel', 'set_loglevel', 'set_logfile', - 'raw', 'debug', 'verbose', 'info', 'warning', 'error', - 'ask', - 'pause', ] # COLORs in ANSI @@ -70,10 +66,6 @@ def _general_print(head, color, msg=None, stream=None, level='normal'): # skip return - # encode raw 'unicode' str to utf8 encoded str - if msg and isinstance(msg, unicode): - msg = msg.encode('utf-8', 'ignore') - errormsg = '' if CATCHERR_BUFFILE_FD > 0: size = os.lseek(CATCHERR_BUFFILE_FD, 0, os.SEEK_END) @@ -122,9 +114,6 @@ def _color_print(head, color, msg, stream, level): newline = True if msg is not None: - if isinstance(msg, unicode): - msg = msg.encode('utf8', 'ignore') - stream.write('%s%s' % (head, msg)) if newline: stream.write('\n') @@ -159,7 +148,7 @@ def _split_msg(head, msg): return head, msg def get_loglevel(): - return (k for k, v in LOG_LEVELS.items() if v == LOG_LEVEL).next() + return next((k for k, v in LOG_LEVELS.items() if v == LOG_LEVEL)) def set_loglevel(level): global LOG_LEVEL @@ -182,9 +171,6 @@ def log(msg=''): if msg: LOG_CONTENT += msg -def raw(msg=''): - _general_print('', NO_COLOR, msg) - def info(msg): head, msg = _split_msg('Info', msg) _general_print(head, INFO_COLOR, msg) @@ -206,66 +192,6 @@ def error(msg): _color_perror(head, ERR_COLOR, msg) sys.exit(1) -def ask(msg, default=True): - _general_print('\rQ', ASK_COLOR, '') - try: - if default: - msg += '(Y/n) ' - else: - msg += '(y/N) ' - if INTERACTIVE: - while True: - repl = raw_input(msg) - if repl.lower() == 'y': - return True - elif repl.lower() == 'n': - return False - elif not repl.strip(): - # <Enter> - return default - - # else loop - else: - if default: - msg += ' Y' - else: - msg += ' N' - _general_print('', NO_COLOR, msg) - - return default - except KeyboardInterrupt: - sys.stdout.write('\n') - sys.exit(2) - -def choice(msg, choices, default=0): - if default >= len(choices): - return None - _general_print('\rQ', ASK_COLOR, '') - try: - msg += " [%s] " % '/'.join(choices) - if INTERACTIVE: - while True: - repl = raw_input(msg) - if repl in choices: - return repl - elif not repl.strip(): - return choices[default] - else: - msg += choices[default] - _general_print('', NO_COLOR, msg) - - return choices[default] - except KeyboardInterrupt: - sys.stdout.write('\n') - sys.exit(2) - -def pause(msg=None): - if INTERACTIVE: - _general_print('\rQ', ASK_COLOR, '') - if msg is None: - msg = 'press <ENTER> to continue ...' - raw_input(msg) - def set_logfile(fpath): global LOG_FILE_FP |