
Ich bastel an einem UI für Restic und setze dafür oft subprocess.run ein. Ein Beispiel
Code: Alles auswählen
process = subprocess.run(['ls',
'-lha',
mount_path],
check=False,
stdout=subprocess.PIPE,
universal_newlines=True)
output = process.stdout
mainWin.widget.setPlainText(output)
self.statusBar().showMessage(mount_path)
Code: Alles auswählen
process.check.returncode()
Auch hier wieder mein Beispielcode
Code: Alles auswählen
# Create cmd
cmd = ['restic',
'-r',
backup_data[row].repository,
'mount',
mount_path]
pwd = backup_data[row].password.encode()
# We create the object, here with stdin and open the asynchronous subprocess
p1 = subprocess.Popen(cmd,stdin=subprocess.PIPE,stderr=subprocess.PIPE)
p1.stdin.write(pwd)
p1.stdin.close()
Aber, wenn man nun das Passwort falsch eingibt, möchte ich das bitte abfangen. Auf der Konsole taucht das hier auf
Code: Alles auswählen
Fatal: wrong password or no key found
Ich vermute, da es sich um einen asynchronen(?) Prozess handelt, kann man so nicht auf die Daten zugreifen (reine Spekulation)
Ich würde mich freuen, wenn mir jemand einen Tipp geben könnte wie man das "richtig" löst.