Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNate Theis <natetheis@gmail.com>2010-11-30 05:19:55 (GMT)
committer Nate Theis <natetheis@gmail.com>2010-11-30 05:19:55 (GMT)
commite91d3f94d2422a2028b454e1bf2c1d8934c48e9d (patch)
tree280641d743381643edf83b48f6af35f1e49dc355
parentc26fef480236e9836754454daf4e524f03240094 (diff)
Parser essentially done. Yay
-rw-r--r--wodim_tools.py72
1 files changed, 60 insertions, 12 deletions
diff --git a/wodim_tools.py b/wodim_tools.py
index 8d8d7d5..9acd3bd 100644
--- a/wodim_tools.py
+++ b/wodim_tools.py
@@ -27,12 +27,17 @@ trackdonematcher = re.compile(r"Track\s(?P<tracknum>\d+):\sTotal\sbytes"
+ r"\sread/written:\s(?P<bytesread>\d+)/"
+ r"(?P<byteswritten>\d+)\s\((?P<sectors>\d+)\s"
+ r"sectors\)\.")
+
+fixatestartmatcher = re.compile(r"Fixating...")
+
+fixatedonematcher = re.compile(r"Fixating\stime:\s+(?P<time>\d+\.\d+)s")
carriagereturn = chr(13)
class WodimWrapper():
+ '''WodimWrapper is a class to burn CDs with Wodim'''
def _get_track_data(self):
trackinfo = {}
totalline = ""
@@ -53,7 +58,7 @@ class WodimWrapper():
def _wait_until_write_start(self):
match = self.wodim_process.expect(writestartmatcher)
- def _do_track(self):
+ def _do_burn(self):
self.wodim_process.expect(trackstartmatcher)
match = self.wodim_process.match.groupdict()
@@ -72,28 +77,71 @@ class WodimWrapper():
elif linetype == 1:
self.trackdone_cb(match)
break
-
+
+ ##FIXME: Only supports 1-track CD burning
+ ##I need example output for a multi-track burn
+
+ ##fixate CD
+
+ self.wodim_process.expect(fixatestartmatcher)
+ self.fixatestart_cb()
+
+ self.wodim_process.expect(fixatedonematcher)
+ self.fixatedone_cb(self.wodim_process.match.groupdict())
+
+ ##now just wait for Wodim to finish!
+
+ if self.wodim_process.exitstatus is None:
+ self.wodim_process.wait()
+
+ self.wodim_process.close()
+
def __init__(self, args, trackstart_cb, trackprogress_cb,
- trackdone_cb, command_path="wodim"):
- '''WodimWrapper is a class to burn CDs with Wodim'''
+ trackdone_cb, fixatestart_cb, fixatedone_cb,
+ burncomplete_cb, trackdataready_cb,
+ command_path="wodim"):
+ '''Initialize stuff, mainly set variables'''
+ #Yeah, that's a lot of callbacks
+
self.trackstart_cb = trackstart_cb
self.trackprogress_cb = trackprogress_cb
self.trackdone_cb = trackdone_cb
+ self.fixatestart_cb = fixatestart_cb
+ self.fixatedone_cb = fixatedone_cb
+ self.burncomplete_cb = burncomplete_cb
+ self.trackdataready_cb = trackdataready_cb
+
+ self.wodim_command = command_path + " -v "
+ #Some info is only shown with -v
- wodim_command = command_path + " -v " #Some info is only shown with -v
- wodim_command += " ".join(args)
+ self.wodim_command += " ".join(args)
- self.wodim_process = pexpect.spawn(wodim_command)
+ def run(self):
+ '''Do the burn!'''
+ self.wodim_process = pexpect.spawn(self.wodim_command)
- trackdata = self._get_track_data()
+ trackdata = self._get_track_data()
+ self.trackdataready_cb(trackdata)
self._wait_until_write_start()
- #self._do_track()
+ self._do_burn()
- print trackdata
+ self.burncomplete_cb()
+
+ return self.wodim_process.exitstatus
+
+
if __name__ == "__main__":
- def printer(x): print x
- ww = WodimWrapper([], printer, printer, printer, command_path="./wodim")
+ #run a few tests for development purposes
+ #i should write unit tests later
+
+ def printer(*args):
+ for arg in args: print arg
+
+ ww = WodimWrapper([], printer, printer, printer,
+ printer, printer, printer, printer,
+ command_path="./wodim")
+ ww.run()