Article View: pl.comp.lang.python
Article #27863Skrypt psuje wyjscie konsoli
From: Michal
Date: Fri, 31 Dec 2010 06:57
Date: Fri, 31 Dec 2010 06:57
46 lines
2028 bytes
2028 bytes
Witam, mam sobie skrypcik, ktory odpala w tle mplayera i po pewnym czasie go wylacza. Niestety po wyjsciu ze skryptu wyjscie konsoli nie dziala tak jak powinno. Gdy pisze znaki na klawiaturze nie pokazuje sie one. Jednak gdy jakis program wyswietla znaki to sa one wypisywane. np.: pisze ls i naciskam enter to napis 'ls' sie nie pokazuje ale zawartosc katalogu juz tak. Program wygdlada tak: #!/usr/bin/python2 import subprocess import datetime import time soma = 'http://www.radiohoryzont.pl/listen.m3u' recordTime = 1 #3600 * 2.0 probeDelta = 1.0 #15 def dumpStream(): startTime = datetime.datetime.now() fileName = 'horyzont-%02dM-%02dD-%02dH.mp3' % (startTime.month, startTime.day, startTime.hour) command = ['mplayer', '-dumpstream', '-dumpfile', fileName, soma] process = None print(fileName) try: process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) playTime = (datetime.datetime.now() - startTime).seconds while process.poll() == None and playTime < recordTime: time.sleep(probeDelta) playTime = (datetime.datetime.now() - startTime).seconds process.kill() finally: if process != None: process.kill() dumpStream() -- Michal
Technical Details
Message-ID:
<20101231075722.a7829af6.natural-born-killer@donotmail.me>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!not-for-mailShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!not-for-mail From: Michal <natural-born-killer@donotmail.me> Newsgroups: pl.comp.lang.python Subject: Skrypt psuje wyjscie konsoli Date: Fri, 31 Dec 2010 07:57:22 +0100 Organization: "Portal Gazeta.pl -> http://www.gazeta.pl" Lines: 46 Message-ID: <20101231075722.a7829af6.natural-born-killer@donotmail.me> NNTP-Posting-Host: 91.218.156.245 Mime-Version: 1.0 X-Trace: inews.gazeta.pl 1293778590 29071 91.218.156.245 (31 Dec 2010 06:56:30 GMT) X-Complaints-To: usenet@agora.pl NNTP-Posting-Date: Fri, 31 Dec 2010 06:56:30 +0000 (UTC) X-Newsreader: Sylpheed 3.0.3 (GTK+ 2.22.1; x86_64-unknown-linux-gnu) X-User: natural-born-killer Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit