Kaydet (Commit) 4088b928 authored tarafından Ali Rıza Keskin's avatar Ali Rıza Keskin

noecho ekledim [bitmedi]

üst 02d7d6ea
......@@ -38,6 +38,7 @@ def sig_handler(sig, frame):
def exit():
inary.util.noecho(False)
sys.exit(1)
def handle_exception(exception, value, tb):
......@@ -94,6 +95,7 @@ def blc_wsl():
if __name__ == "__main__":
blc_wsl()
inary.util.noecho(True)
sys.excepthook = handle_exception
signal.signal(signal.SIGTERM, sig_handler)
......@@ -102,3 +104,4 @@ if __name__ == "__main__":
if cli.command.name[1] in "rdb sf".split():
ctx.filesdb = inary.db.filesdb.FilesDB()
cli.run_command()
inary.util.noecho(False)
......@@ -18,7 +18,6 @@ import atexit
import importlib
import logging
import logging.handlers
import util
import os
import sys
......@@ -69,4 +68,3 @@ atexit.register(_cleanup)
ctx.config = inary.config.Config()
init_logging()
util.noecho()
......@@ -174,7 +174,9 @@ class CLI(inary.ui.UI):
prompt = msg + util.colorize(" "+_('(yes'), 'red') + '/' + util.colorize(_('no)'), 'green') + ": "
else:
prompt = msg + util.colorize(" "+_('(yes'), 'green') + '/' + util.colorize(_('no)'), 'red') + ": "
util.noecho(False)
s = input(prompt)
util.noecho(True)
if yes_expr.search(s):
return True
......
......@@ -199,6 +199,7 @@ class Command(object):
def die():
"""exit program"""
ctx.ui.error(_('Command terminated abnormally.'))
util.noecho(False)
sys.exit(-1)
......
......@@ -84,10 +84,29 @@ class UI(object):
"""ask the user to choose from a list of alternatives"""
pass
def confirm(self, msg):
"""ask a yes/no question"""
# default ui confirms everything
return True
def confirm(self, msg,invert=False):
msg = str(msg)
if ctx.config.options and ctx.config.options.yes_all:
return True
locale.setlocale(locale.LC_ALL, "")
yes_expr = re.compile(locale.nl_langinfo(locale.YESEXPR))
no_expr = re.compile(locale.nl_langinfo(locale.NOEXPR))
locale.setlocale(locale.LC_ALL, "C")
tty.tcflush(sys.stdin.fileno(), 0)
if invert:
prompt = msg + util.colorize(" "+_('(yes'), 'red') + '/' + util.colorize(_('no)'), 'green') + ": "
else:
prompt = msg + util.colorize(" "+_('(yes'), 'green') + '/' + util.colorize(_('no)'), 'red') + ": "
util.noecho(False)
s = input(prompt)
util.noecho(True)
if yes_expr.search(s):
return True
else:
return False
def display_progress(self, **ka):
"""display progress"""
......
......@@ -396,7 +396,7 @@ def noecho(enabled=True):
if(enabled):
printw("\x1b[?25l")
else:
printw("\x1b[?250")
printw("\x1b[?25h")
def attron(attribute):
"""Attribute enable"""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment