Improve spinner by method pause/resume.

Add -P param from get password without interactive.
develop
parent d5a01b186e
commit 4f8d73db1d

@ -65,6 +65,8 @@ class StoppableThread(threading.Thread):
def __init__(self):
super(StoppableThread, self).__init__()
self._stop = threading.Event()
self._pause = threading.Event()
self._paused = threading.Event()
def run(self):
l = ['|','/','-','\\','|','/','-','\\']
@ -74,10 +76,23 @@ class StoppableThread(threading.Thread):
sys.stdout.write("\r\r" + i)
sys.stdout.flush()
time.sleep(.1)
while self.paused() and not self.stopped():
self._paused.set()
if self.stopped():
sys.stdout.write("\b")
sys.stdout.flush()
return 0
def pause(self):
self._pause.set()
while not self._paused.is_set():
self._paused.clear()
sys.stdout.write("\r")
sys.stdout.flush()
def resume(self):
self._pause.clear()
def stop(self):
self._stop.set()
@ -85,6 +100,9 @@ class StoppableThread(threading.Thread):
def stopped(self):
return self._stop.isSet()
def paused(self):
return self._pause.isSet()
def connect_with_cert(cert, path_to_cert, url, args, wait_thread, clVarsCore,
crypto_Error, Connect_Error):
flag_thread_start = False

@ -90,6 +90,10 @@ def parse():
parser.add_argument(
'-f', '--force', action='store_true', default=False,
dest = 'no_questions', help=_('silent during the process'))
parser.add_argument(
'-P', action='store_true', default=False,
dest = 'stdin_passwd',
help=_('use passwords for the users accounts from standard input'))
return parser
def get_view(client, method, sid, view_params):
@ -103,6 +107,7 @@ def get_view(client, method, sid, view_params):
def call_method(client, args, wait_thread):
method = args.method
no_questions = args.no_questions
stdin_passwd = args.stdin_passwd
view_params = get_view_params(client, method + '_view', step = None, \
expert = True)
@ -122,7 +127,7 @@ def call_method(client, args, wait_thread):
_print (_('Unknown parameter'), i)
raise Exception(1)
param_object, steps = collect_object(client, param_object, view, args,
wait_thread)
wait_thread,stdin_passwd=stdin_passwd)
if steps.label and hasattr (param_object, 'CheckOnly'):
param_object['CheckOnly'] = True
check_res = {}

Loading…
Cancel
Save