def UI_Important(text): debug_logger.debug(text) if UI_mode == 'text': sys.stdout.write('\n' + text + '\n') else: SendDataToYast({'type': 'dialog-error', 'message': text}) path, yarg = GetDataFromYast()
def UI_BusyStart(message): debug_logger.debug('UI_BusyStart: %s' % UI_mode) if UI_mode == 'text': UI_Info(message) else: SendDataToYast({'type': 'dialog-busy-start', 'message': message}) ypath, yarg = GetDataFromYast()
def UI_LongMessage(title, message): SendDataToYast({ 'type': 'long-dialog-message', 'headline': title, 'message': message }) ypath, yarg = GetDataFromYast()
def UI_GetFile(file): debug_logger.debug('UI_GetFile: %s' % UI_mode) filename = None if UI_mode == 'text': sys.stdout.write(file['description'] + '\n') filename = sys.stdin.read() else: file['type'] = 'dialog-getfile' SendDataToYast(file) ypath, yarg = GetDataFromYast() if yarg['answer'] == 'okay': filename = yarg['filename'] return filename
def UI_YesNoCancel(text, default): debug_logger.debug('UI_YesNoCancel: %s: %s %s' % (UI_mode, text, default)) default = default.lower() ans = None if UI_mode == 'text': yes = _('(Y)es') no = _('(N)o') cancel = _('(C)ancel') yeskey = get_translated_hotkey(yes).lower() nokey = get_translated_hotkey(no).lower() cancelkey = get_translated_hotkey(cancel).lower() ans = 'XXXINVALIDXXX' while ans not in ['c', 'n', 'y']: sys.stdout.write('\n' + text + '\n') if default == 'y': sys.stdout.write('\n[%s] / %s / %s\n' % (yes, no, cancel)) elif default == 'n': sys.stdout.write('\n%s / [%s] / %s\n' % (yes, no, cancel)) else: sys.stdout.write('\n%s / %s / [%s]\n' % (yes, no, cancel)) ans = getkey() if ans: # Get back to english from localised answer ans = ans.lower() if ans == yeskey: ans = 'y' elif ans == nokey: ans = 'n' elif ans == cancelkey: ans = 'c' elif ans == 'left': if default == 'n': default = 'y' elif default == 'c': default = 'n' elif ans == 'right': if default == 'y': default = 'n' elif default == 'n': default = 'c' else: ans = default else: SendDataToYast({'type': 'dialog-yesnocancel', 'question': text}) ypath, yarg = GetDataFromYast() ans = yarg['answer'] if not ans: ans = default return ans
def promptUser(self, params=''): cmd = None arg = None if UI_mode == 'text': cmd, arg = self.Text_PromptUser() else: self.type = 'wizard' SendDataToYast(self) ypath, yarg = GetDataFromYast() if not cmd: cmd = 'CMD_ABORT' arg = yarg['selected'] if cmd == 'CMD_ABORT': confirm_and_abort() cmd = 'XXXINVALIDXXX' return (cmd, arg)
def UI_GetString(text, default): debug_logger.debug('UI_GetString: %s: %s %s' % (UI_mode, text, default)) string = default if UI_mode == 'text': readline.set_startup_hook(lambda: readline.insert_text(default)) try: string = raw_input('\n' + text) except EOFError: string = '' finally: readline.set_startup_hook() else: SendDataToYast({ 'type': 'dialog-getstring', 'label': text, 'default': default }) ypath, yarg = GetDataFromYast() string = yarg['string'] return string.strip()
def UI_BusyStop(): debug_logger.debug('UI_BusyStop: %s' % UI_mode) if UI_mode != 'text': SendDataToYast({'type': 'dialog-busy-stop'}) ypath, yarg = GetDataFromYast()