How to get sector values for progress bar?

Holger Koch <[email protected]> Thu, 28 Oct 2010 00:29:42 +0200
Newsgroups gmane.comp.audio.cd-paranoia.general
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--===============0114433137==
Content-Type: multipart/alternative;
 boundary="------------080504090705060607000904"

This is a multi-part message in MIME format.
--------------080504090705060607000904
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Hello everybody!

I am currently working on a CD ripper front end for cdparanoia. My 
problem is to find a way to get the current sector of the CD that is 
being ripped to update the respective progress bar of the application's 
gui. At the moment I use a python method like this:

     def button1_clicked(self, widget):
         task = self.actRip(11)
         gobject.idle_add(task.next)

     def actRip(self, n):
         cmd = ("cdparanoia", "-e", "-Z", "-B", "-v", "-d", "/dev/scd0", 
str(n), "/home/atarax/Desktop/Rip/ripper03/wav")
         ripping = subprocess.Popen(cmd, stderr=subprocess.PIPE)
         log = open("/home/atarax/Desktop/Rip/ripper03/log", "w")
         for line in ripping.stderr:
             if "[read]" in line:
                 low = 187762512.0  # offset value found in log file
                 high = 197609160.0  # finish value found in log file
                 position = float(line[(line.rfind(" ") + 1):-1])
                 self.entry1.set_text(str(position))
                 fraction = (position - low) / (high - low)
                 self.progressbar1.set_fraction(fraction)
                 percent = int(fraction * 100)
                 self.progressbar1.set_text("Track " + str(n) + ": " + 
str(percent) + " %")
                 log.write(line)
             yield True
         yield False

This is just a reduced snippet as an example of the procedure. The 
output of ripping.stderr returns lines that contain completely different 
values as the track info created by cdparanoia -Q, like this:
##: 0 [read] @ 187984776
I cannot find an obvious relationship between those values of 
ripping.stderr and the sector values. Even the values of [read] and 
[wrote] are not congruent. When ripping the CD via command line I get 
the rich bargraph (http://www.xiph.org/paranoia/faq.html#progbar) that 
seems to be pretty useful, but how can I redirect this output to my 
script, while ripping.stderr offers much poorer information?

Thank you for your assistance.
Holger Koch

--------------080504090705060607000904
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

<meta http-equiv=3D"content-type" content=3D"text/html; charset=3DUTF-8">
</head>
<body text=3D"#000099" bgcolor=3D"#ffffcc">
<small><small><font size=3D"+1"><small><small><tt>Hello everybody!<br>
<br>
I am currently working on a CD ripper front end for cdparanoia. My
problem is to find a way to get the current sector of the CD that is
being ripped to update the respective progress bar of the application's
gui. At the moment I use a python method like this:<br>
<br>
=C2=A0=C2=A0=C2=A0 def button1_clicked(self, widget):<br>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 task =3D self.actRip(11)<br>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 gobject.idle_add(task.next)<br=
>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0<br>
=C2=A0=C2=A0=C2=A0 def actRip(self, n):<br>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 cmd =3D ("cdparanoia", "-e", "=
-Z", "-B", "-v", "-d", "/dev/scd0",
str(n), "/home/atarax/Desktop/Rip/ripper03/wav")<br>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ripping =3D subprocess.Popen(c=
md, stderr=3Dsubprocess.PIPE)<br>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 log =3D open("/home/atarax/Des=
ktop/Rip/ripper03/log", "w")<br>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 for line in ripping.stderr:<br=
>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if "[r=
ead]" in line:<br>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0 low =3D 187762512.0=C2=A0 # offset value found in log fil=
e<br>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0 high =3D 197609160.0=C2=A0 # finish value found in log fi=
le<br>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0 position =3D float(line[(line.rfind(" ") + 1):-1])<br>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0 self.entry1.set_text(str(position))<br>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0 fraction =3D (position - low) / (high - low)<br>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0 self.progressbar1.set_fraction(fraction)<br>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0 percent =3D int(fraction * 100)<br>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0 self.progressbar1.set_text("Track " + str(n) + ": " +
str(percent) + " %")<br>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0 log.write(line)<br>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 yield =
True<br>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 yield False<br>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0<br>
This is just a reduced snippet as an example of the procedure. The
output of ripping.stderr returns lines that contain completely
different values as the track info created by cdparanoia -Q, like this:<b=
r>
##: 0 [read] @ 187984776<br>
I cannot find an obvious relationship between those values of
ripping.stderr and the sector values. Even the values of [read] and
[wrote] are not congruent. When ripping the CD via command line I get
the rich bargraph (<a class=3D"moz-txt-link-freetext" href=3D"http://www.=
xiph.org/paranoia/faq.html#progbar">http://www.xiph.org/paranoia/faq.html=
#progbar</a>) that
seems to be pretty useful, but how can I redirect this output to my
script, while ripping.stderr offers much poorer information?<br>
<br>
Thank you for your assistance.<br>
Holger Koch</tt></small></small></font></small></small>
</body>
</html>

--------------080504090705060607000904--

--===============0114433137==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Paranoia mailing list
[email protected]
http://lists.xiph.org/mailman/listinfo/paranoia

--===============0114433137==--