tags 310478 + patch pending
thanks
* Martin Michlmayr <[EMAIL PROTECTED]> [2005-05-23 21:31]:
> When cdparanoia fails, the following ugly traceback is produced:
>
> Traceback (most recent call last):
> File "/home/tbm/bin/jack-3.1", line 225, in ?
> global_error = jack_main_loop.main_loop(mp3s_todo, wavs_todo, space,
> dae_queue, enc_queue, track1_offset)
> File "/usr/lib/python2.3/site-packages/jack_main_loop.py", line 293, in
> main_loop
> jack_status.dae_stat_upd(num,
> string.strip(string.split(exited_proc['buf'], "\n")[-2]))
> IndexError: list index out of range
> *warning* abnormal exit
The patch below makes the parsing of the ripper output more robust:
diff -urN jack-3.1.1~/jack_helpers.py jack-3.1.1/jack_helpers.py
--- jack-3.1.1~/jack_helpers.py 2005-07-28 22:31:02.924899792 +0100
+++ jack-3.1.1/jack_helpers.py 2005-07-28 23:01:19.584725520 +0100
@@ -260,9 +260,12 @@
'status_fkt': r"""
# (== PROGRESS == [ | 013124 00 ] == :^D * ==)
# (== PROGRESS == [ > .| 011923 00 ] == :-) . ==)
-tmp = string.split(i['buf'], '\r')[-2] + " "
-new_status = tmp[17:48] + tmp[49:69] # 68->69 because of newer version
-#new_status = string.split(i['buf'], '\r')[-2][17:69] # 68->69 because of
newer version
+tmp = string.split(i['buf'], "\r")
+if len(tmp) >= 2:
+ tmp = tmp[-2] + " "
+ new_status = tmp[17:48] + tmp[49:69] # 68->69 because of newer version
+else:
+ new_status = "Cannot parse status"
""",
'otf-status_fkt': r"""
buf = i['buf']
@@ -316,11 +319,14 @@
'status_blocksize': 200,
'status_start': "percent_done:",
'status_fkt': r"""
-x = string.split(i['buf'], '\r')[-2]
-if string.find(x, '%') != -1:
- new_status = "ripping: " + string.strip(string.split(i['buf'], '\r')[-2])
+tmp = string.split(i['buf'], "\r")
+if len(tmp) >= 2:
+ if string.find(tmp[-2], '%') != -1:
+ new_status = "ripping: " + string.strip(tmp[-2])
+ else:
+ new_status = "waiting..."
else:
- new_status = "waiting..."
+ new_status = "Cannot parse status"
""",
'final_status_fkt': r"""
final_status = ("%s" % jack_functions.pprint_speed(speed)) + "x [ DAE done
with cdda2wav ]"
@@ -419,11 +425,14 @@
'status_blocksize': 100,
'status_start': "total:",
'status_fkt': r"""
-x = string.split(i['buf'], '\r')[-2]
-if string.find(x, 'total:') != -1:
- new_status = string.strip(string.split(i['buf'], '\r')[-2])
+tmp = string.split(i['buf'], "\r")
+if len(tmp) >= 2:
+ if string.find(tmp[-2], 'total:') != -1:
+ new_status = string.strip(tmp[-2])
+ else:
+ new_status = "waiting..."
else:
- new_status = "waiting..."
+ new_status = "Cannot parse status"
""",
'final_status_fkt': r"""
final_status = ("%s" % jack_functions.pprint_speed(speed)) + "x [ DAE done
with dagrab ]"
diff -urN jack-3.1.1~/jack_main_loop.py jack-3.1.1/jack_main_loop.py
--- jack-3.1.1~/jack_main_loop.py 2005-07-28 22:31:02.925899640 +0100
+++ jack-3.1.1/jack_main_loop.py 2005-07-28 23:00:17.783120792 +0100
@@ -285,9 +285,9 @@
if os.path.exists(track[NAME] + ".wav"):
if jack_functions.tracksize(track)[WAV] !=
jack_utils.filesize(track[NAME] + ".wav"):
res = 242
- jack_status.dae_stat_upd(num,
string.strip(string.split(exited_proc['buf'], "\n")[-2]))
+ jack_status.dae_stat_upd(num,
jack_status.get_2_line(exited_proc['buf']))
else:
- jack_status.dae_stat_upd(num,
string.strip(string.split(exited_proc['buf'], "\n")[-2]))
+ jack_status.dae_stat_upd(num,
jack_status.get_2_line(exited_proc['buf']))
res = 243
global_error = global_error + res
if res and not cf['_sloppy']:
@@ -304,7 +304,7 @@
jack_status.dae_stat_upd(num, 'DAE failed with
status ' + `res` + ", wav removed.")
else:
if exited_proc['type'] == "image_reader":
- jack_status.dae_stat_upd(num,
string.strip(string.split(exited_proc['buf'], "\n")[-2]))
+ jack_status.dae_stat_upd(num,
jack_status.get_2_line(exited_proc['buf']))
else:
if exited_proc['otf'] and
jack_helpers.helpers[exited_proc['prog']].has_key('otf-final_status_fkt'):
exec(jack_helpers.helpers[exited_proc['prog']]['otf-final_status_fkt']) in
globals(), locals()
@@ -391,12 +391,10 @@
#jack_term.tmod.dae_stat_upd(i['track'][NUM],
None, i['percent'])
elif i['type'] == "image_reader":
- line = string.split(i['buf'], "\n")
- if len(line) >= 2:
- line = string.strip(line[-2])
- jack_status.dae_stat_upd(i['track'][NUM], line)
- if line[:5] == "Error":
- global_error = global_error + 1
+ line = string.strip(jack_status.get_2_line(i['buf']))
+ jack_status.dae_stat_upd(i['track'][NUM], line)
+ if line.startswith("Error"):
+ global_error = global_error + 1
else:
error("unknown subprocess type \"" + i['type'] + "\".")
diff -urN jack-3.1.1~/jack_status.py jack-3.1.1/jack_status.py
--- jack-3.1.1~/jack_status.py 2005-07-28 22:31:02.926899488 +0100
+++ jack-3.1.1/jack_status.py 2005-07-28 22:54:21.874227168 +0100
@@ -16,6 +16,8 @@
### along with this program; if not, write to the Free Software
### Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+import string
+
from jack_globals import NUM, cf
import jack_term
import jack_ripstuff
@@ -55,3 +57,10 @@
else:
print jack_ripstuff.printable_names[i[NUM]] + ":",
dae_status[i[NUM]], enc_status[i[NUM]]
+def get_2_line(buf, default="A failure occured"):
+ tmp = string.split(buf, "\n")
+ if len(tmp) >= 2:
+ return string.strip(tmp[-2])
+ else:
+ return default
+
--
Martin Michlmayr
http://www.cyrius.com/
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]