Ich hab ein kleines Problem mit QProcess und zwar schreib ich gerade ne kleine Ui für AVG Antivirus und starte avgscan per QProcess.
Nach dem der avgscan gestartet ist lese ich Prozentstatus und Verzeichnis aus und genau hier ist mein Problem!
Starte ich "avgscan /home/foobar/Bilder" in der Konsole sehe ich 0 - 100% und alle 547 Verzeichnisnamen.
Starte ich avgscan über QProcess und Lese % und Verzeichnis aus, zählt der Counter gerade mal 10 Ausgaben und der ProgressBar bleibt bei 90% stecken.
Code ineffizient oder QProcess zu lahm?
Code: Alles auswählen
def onScan(self):
cmd = []
cmd.append(self.checkScanMode())
cmd = cmd + self.checkSelectedFolder()
# Start process and setup signal/slot
self.process = QtCore.QProcess()
#self.process.setProcessChannelMode(2)
self.process.readyRead.connect(self.output)
self.process.finished.connect(self.onFinish)
self.process.start('avgscan', QtCore.QStringList(cmd))
Code: Alles auswählen
def output(self):
output = self.process.readAllStandardOutput().replace('[2K','')
try:
self.count +=1
a = re.findall('\[(.*)\..%\] (/.*)', output)
p = int(a[0][0].replace('~', ''))
d = a[0][1]
print d
self.progressBar.setValue(p)
self.currentDirectory.setText(str(self.count))
except IndexError:
pass
Ausgabe von self.output()
Code: Alles auswählen
/home/foobar/Bilder/CBR/IMG_20120821_130923.jpg
/home/foobar/Bilder/Transformers/tf_1_optimus_large.jpg
/home/foobar/Bilder/Foobar/Hamsterbacken.jpg
/home/foobar/Bilder/DCIM/Calibra/
/home/foobar/Bilder/DCIM/Camera/IMG_20120615_181118.jpg
12
The End
Selbst wenn ich den Code verkürze in z.B. (Siehe unten), kommt die QProcess bzw die Ui nicht nach -.-'
Code: Alles auswählen
def output(self):
#output = self.process.readAllStandardOutput()#.replace('[2K','')
try:
self.count +=1
#a = re.findall('\[(.*)\..%\] (/.*)', output)
p = int(re.findall('\[~(.*)\..%\]', self.process.readAllStandardOutput())[0])
#p = int(a[0][0].replace('~', ''))
#d = a[0][1]
#print d
self.progressBar.setValue(p)
self.currentDirectory.setText(str(self.count))
except IndexError:
pass