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:41:22 (GMT)
committer Nate Theis <natetheis@gmail.com>2010-11-30 05:41:22 (GMT)
commit556004435147f043cb286a29974daafd7ecb4748 (patch)
tree331b6ba99a1e25b1076cbb39485771678e51e9bf
parente91d3f94d2422a2028b454e1bf2c1d8934c48e9d (diff)
Revert "Parser essentially done. Yay"
This reverts commit e91d3f94d2422a2028b454e1bf2c1d8934c48e9d.
-rw-r--r--wodim_tools.py72
1 files changed, 12 insertions, 60 deletions
diff --git a/wodim_tools.py b/wodim_tools.py
index 9acd3bd..8d8d7d5 100644
--- a/wodim_tools.py
+++ b/wodim_tools.py
@@ -27,17 +27,12 @@ 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 = ""
@@ -58,7 +53,7 @@ class WodimWrapper():
def _wait_until_write_start(self):
match = self.wodim_process.expect(writestartmatcher)
- def _do_burn(self):
+ def _do_track(self):
self.wodim_process.expect(trackstartmatcher)
match = self.wodim_process.match.groupdict()
@@ -77,71 +72,28 @@ 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, fixatestart_cb, fixatedone_cb,
- burncomplete_cb, trackdataready_cb,
- command_path="wodim"):
- '''Initialize stuff, mainly set variables'''
- #Yeah, that's a lot of callbacks
-
+ trackdone_cb, command_path="wodim"):
+ '''WodimWrapper is a class to burn CDs with Wodim'''
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
- self.wodim_command += " ".join(args)
+ wodim_command = command_path + " -v " #Some info is only shown with -v
+ wodim_command += " ".join(args)
- def run(self):
- '''Do the burn!'''
- self.wodim_process = pexpect.spawn(self.wodim_command)
+ self.wodim_process = pexpect.spawn(wodim_command)
- trackdata = self._get_track_data()
- self.trackdataready_cb(trackdata)
+ trackdata = self._get_track_data()
self._wait_until_write_start()
- self._do_burn()
+ #self._do_track()
- self.burncomplete_cb()
-
- return self.wodim_process.exitstatus
-
-
+ print trackdata
if __name__ == "__main__":
- #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()
+ def printer(x): print x
+ ww = WodimWrapper([], printer, printer, printer, command_path="./wodim")