diff --git a/pym/cl_client.py b/pym/cl_client.py index 8216234..9a06438 100644 --- a/pym/cl_client.py +++ b/pym/cl_client.py @@ -30,7 +30,7 @@ import _cl_keys import time import stat -import popen2 +import subprocess import time Version = "calculate-client 2.1.2" @@ -47,7 +47,7 @@ class printNoColor: class ProgressBar: suffixSet = 'org.freedesktop.DBus.Properties.Set \ org.kde.kdialog.ProgressDialog' - execenv = 'HOME="/root" ' + execenv = {"HOME":"/root"} max = 100 kdialog = None label = None @@ -61,16 +61,17 @@ org.kde.kdialog.ProgressDialog' self.max = max self.title = title if os.system('which kdialog >/dev/null') == 0: - self.label ="LOGINKDIALOG=%d" % os.getpid() - pipe = popen2.Popen4(self.execenv + " %s " % self.label +\ - '/usr/bin/kdialog --progressbar "%s" %d' % (\ - " "*(len(title)+20),self.max)) + self.execenv["LOGINKDIALOG"] = str(os.getpid()) + pipe = subprocess.Popen('/usr/bin/kdialog --progressbar "%s" %d'\ + %(" "*(len(title)+20), self.max), + stdout=subprocess.PIPE,close_fds=True, + env=self.execenv, shell=True) if pipe.poll() != 0: time.sleep(0.5) if pipe.poll() == 0: - self.kdialog = pipe.fromchild.readline().strip() + self.kdialog = pipe.stdout.readline().strip() while not "org.kde.kdialog" in self.kdialog: - s = fout.fromchild.readline() + s = pipe.stdout.readline() if s == "": self.shutdownDialog() self.kdialog = s.strip() @@ -81,8 +82,10 @@ org.kde.kdialog.ProgressDialog' def shutdownDialog(self): '''Принудительно уничтожить процесс kdialog''' self.kdialog = None + pipe = subprocess.Popen("/bin/ps axeo pid,cmd", stdout=subprocess.PIPE, + close_fds=True, shell=True) if self.label != None: - for s in os.popen('/bin/ps axeo pid,cmd'): + for s in pipe.stdout: if self.label in s: try: os.kill( int(s.split()[0]), 9 ) @@ -161,9 +164,10 @@ class RsyncProgressBar(ProgressBar): def runsilent(self): '''Запустить rsync без progressbar''' - self.pipe = popen2.Popen4(self.rsyncstr) + self.pipe = subprocess.Popen(self.rsyncstr, stdout=subprocess.PIPE, + close_fds=True, shell=True) while True: - s = self.pipe.fromchild.readline() + s = self.pipe.stdout.readline() if len(s) == 0: break q = self.receiverre.search(s) @@ -173,10 +177,11 @@ class RsyncProgressBar(ProgressBar): def run(self): '''Запустить rsync с progressbar''' self.openDialog(self.title,0) - self.pipe = popen2.Popen4(self.rsyncstr) + self.pipe = subprocess.Popen(self.rsyncstr, stdout=subprocess.PIPE, + close_fds=True, shell=True) oldpercent = 0 while True: - s = self.pipe.fromchild.readline() + s = self.pipe.stdout.readline() if len(s) == 0: break q = self.senderre.search(s)