Czyli co, to po prostu jakiś bug?
Oblatałem rano chyba z 100 tematów na staku. Próbowałem w blok 'try' dodawać itp, ale nie jest łapany wyjątek. (albo jeszcze nie ogarniam na tyle pythona)
def executeCommand(cmd):
process = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
while True:
if process.poll() is not None:
break;
try:
nextline = process.stdout.readline()
except IOError:
sys.stdout.write("Exc on close: " + str(sys.exc_info()[0]) + "\n")
if nextline != '':
nextline = nextline.decode("utf-8", errors="ignore")
if "upload date is not in range" in nextline:
break
try:
sys.stdout.write(nextline)
sys.stdout.flush()
except IOError:
sys.stdout.write("Exc on close: " + str(sys.exc_info()[0]) + "\n")
try:
process.stdout.close()
except IOError:
sys.stdout.write("Exc on close: " + str(sys.exc_info()[0]) + "\n")
process.terminate()
output:
Rivit@DESKTOP-QEC4TCS D:\
$ update.py
[youtube:channel] UC-LTY8udwDeOUzMY8PIhD6w: Downloading channel page
[youtube:playlist] UU-LTY8udwDeOUzMY8PIhD6w: Downloading webpage
[download] Downloading playlist: Uploads from Poeta Kodu
[youtube:playlist] playlist Uploads from Poeta Kodu: Downloading 12 videos
[download] Downloading video 1 of 12
[youtube] os5xHYIeid4: Downloading webpage
[youtube] os5xHYIeid4: Downloading video info webpage
[youtube] os5xHYIeid4: Downloading MPD manifest
ERROR: [Errno 22] Invalid argument
ERROR: [Errno 22] Invalid argument
Exception ignored in: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='cp1250'>
OSError: [Errno 22] Invalid argument
Albo czy znasz może jakąś inną metodę przechwytywania stdout z running procesu?