|
|
|
@ -48,28 +48,32 @@ class printNoColor:
|
|
|
|
|
sys.stdout.write(string)
|
|
|
|
|
|
|
|
|
|
class NoneProgressBar:
|
|
|
|
|
"""Abstract class of progress bar. It do nothing."""
|
|
|
|
|
def __init__(self,title,dialog=None):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
def openDialog(self,title,max=None):
|
|
|
|
|
"""Create dialog with progress bar, prepare date"""
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
def shutdownDialog(self):
|
|
|
|
|
"""Destroy dialog"""
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
def setValue(self,value):
|
|
|
|
|
"""Set value of progress bar relative of maximum"""
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
def setMaximum(self,max):
|
|
|
|
|
"""Set maximum value of progress bar"""
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
def setTitle(self,title):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
def close(self):
|
|
|
|
|
"""Set title of progress dialog"""
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
class GProgressBar(NoneProgressBar):
|
|
|
|
|
"""GProgressBar uses Xdialog program for display progressbar."""
|
|
|
|
|
def __init__(self,title,xdialog=None):
|
|
|
|
|
self.title = title
|
|
|
|
|
self.bgPID = 0
|
|
|
|
@ -82,6 +86,7 @@ class GProgressBar(NoneProgressBar):
|
|
|
|
|
if max != None:
|
|
|
|
|
self.setMaximum(max)
|
|
|
|
|
|
|
|
|
|
title = re.sub("<[^>]+>", title)
|
|
|
|
|
self.title = title
|
|
|
|
|
if os.system('which Xdialog &>/dev/null') == 0:
|
|
|
|
|
pipe = subprocess.Popen('/usr/bin/Xdialog --progress "%s" 5 80'\
|
|
|
|
@ -126,11 +131,9 @@ class GProgressBar(NoneProgressBar):
|
|
|
|
|
'''Установить описания прогресса'''
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
def close(self):
|
|
|
|
|
'''Закрыть прогресс'''
|
|
|
|
|
self.shutdownDialog()
|
|
|
|
|
|
|
|
|
|
class KProgressBar(NoneProgressBar):
|
|
|
|
|
"""KProgressBar uses kdialog program and dbus for display progressbar."""
|
|
|
|
|
|
|
|
|
|
suffixSet = 'org.freedesktop.DBus.Properties.Set \
|
|
|
|
|
org.kde.kdialog.ProgressDialog'
|
|
|
|
|
execenv = {"HOME":"/root"}
|
|
|
|
@ -160,16 +163,20 @@ org.kde.kdialog.ProgressDialog'
|
|
|
|
|
close_fds=True,
|
|
|
|
|
env=env, shell=True)
|
|
|
|
|
pipe.stdin.close()
|
|
|
|
|
# wait for terminate kdialog, which say dbus dialog id
|
|
|
|
|
if pipe.poll() is None:
|
|
|
|
|
# ожидание в 5 сек
|
|
|
|
|
for t in range(500):
|
|
|
|
|
time.sleep(0.01)
|
|
|
|
|
if pipe.poll() != None:
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
# waiting is ok
|
|
|
|
|
if pipe.poll() == 0:
|
|
|
|
|
self.kdialog = pipe.stdout.readline().strip()
|
|
|
|
|
while not "org.kde.kdialog" in self.kdialog:
|
|
|
|
|
s = pipe.stdout.readline()
|
|
|
|
|
# if bad result of kdialog then shutdown dialog
|
|
|
|
|
if s == "":
|
|
|
|
|
pipe.stdout.close()
|
|
|
|
|
pipe.stderr.close()
|
|
|
|
@ -179,6 +186,7 @@ org.kde.kdialog.ProgressDialog'
|
|
|
|
|
self.setTitle(self.title)
|
|
|
|
|
pipe.stdout.close()
|
|
|
|
|
pipe.stderr.close()
|
|
|
|
|
# waiting is failed
|
|
|
|
|
else:
|
|
|
|
|
pipe.stdout.close()
|
|
|
|
|
pipe.stderr.close()
|
|
|
|
@ -239,11 +247,8 @@ org.kde.kdialog.ProgressDialog'
|
|
|
|
|
os.system(env + '/usr/bin/qdbus %s setLabelText "%s" >/dev/null'\
|
|
|
|
|
%(self.kdialog,self.title))
|
|
|
|
|
|
|
|
|
|
def close(self):
|
|
|
|
|
'''Закрыть прогресс'''
|
|
|
|
|
self.shutdownDialog()
|
|
|
|
|
|
|
|
|
|
def ProgressBar(*args,**kwarg):
|
|
|
|
|
"""Return instance of object for progress bar"""
|
|
|
|
|
if os.system('which kdialog &>/dev/null') == 0:
|
|
|
|
|
return KProgressBar(*args,**kwarg)
|
|
|
|
|
elif os.system('which Xdialog &>/dev/null') == 0:
|
|
|
|
@ -263,6 +268,9 @@ class ProgressProfile(cl_profile.profile):
|
|
|
|
|
self.progress.setValue(number)
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def close(self):
|
|
|
|
|
self.progressbar.shutdownDialog()
|
|
|
|
|
|
|
|
|
|
class RsyncProgressBar:
|
|
|
|
|
'''Объект запуска rsync для получения количества созданных файлов и
|
|
|
|
|
при необходимости вывода progressbar
|
|
|
|
@ -337,7 +345,7 @@ class RsyncProgressBar:
|
|
|
|
|
self.progress.setValue(value)
|
|
|
|
|
|
|
|
|
|
def close(self):
|
|
|
|
|
self.progress.close()
|
|
|
|
|
self.progress.shutdownDialog()
|
|
|
|
|
|
|
|
|
|
# Импортированные классы в cl_ldap
|
|
|
|
|
# Запись ошибок
|
|
|
|
@ -837,7 +845,7 @@ conjunction with the 'login' or 'logout'")
|
|
|
|
|
# Объединяем профили
|
|
|
|
|
dirsFiles = clProf.applyProfiles()
|
|
|
|
|
if progress:
|
|
|
|
|
clProf.progress.close()
|
|
|
|
|
clProf.close()
|
|
|
|
|
if clProf.getError():
|
|
|
|
|
self.printERROR(clProf.getError())
|
|
|
|
|
return False
|
|
|
|
|