* examples/readtoc.py (added):

Add an example to read the TOC, not finished yet.
This commit is contained in:
Thomas Vander Stichele
2009-04-19 17:26:33 +00:00
parent 0fe1be06b7
commit a7e3779473
2 changed files with 46 additions and 0 deletions

View File

@@ -1,3 +1,8 @@
2009-04-19 Thomas Vander Stichele <thomas at apestaart dot org>
* examples/readtoc.py (added):
Add an example to read the TOC, not finished yet.
2009-04-19 Thomas Vander Stichele <thomas at apestaart dot org>
* morituri/extern (added):

41
examples/readtoc.py Normal file
View File

@@ -0,0 +1,41 @@
# -*- Mode: Python -*-
# vi:si:et:sw=4:sts=4:ts=4
import os
import subprocess
from morituri.common import task
from morituri.extern import asyncsub
class ReadTOCTask(task.Task):
"""
I am a task that reads the TOC of a CD, including pregaps.
"""
description = "Reading TOC..."
def start(self, runner):
task.Task.start(self, runner)
if os.path.exists('/tmp/toc'):
os.unlink('/tmp/toc')
bufsize = 1024
self._popen = asyncsub.Popen(["cdrdao", "read-toc", "/tmp/toc"],
bufsize=bufsize,
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, close_fds=True)
self.runner.schedule(1.0, self._read, runner)
def _read(self, runner):
print self._popen.recv_err()
self.runner.schedule(1.0, self._read, runner)
def main():
runner = task.SyncRunner()
t = ReadTOCTask()
runner.run(t)
main()