hi, recently the hard disk in my Freevo box became faulty; I have then used the good GNU tool 'ddrescue' and I have saved roughly half the recorded movies. While recovering the files, for each file named xxxx , I instructed 'ddrescue' to save its log in the file xxxx.ddrescue
I want to share with you some code snippets. - ddrescue.py is an utility that scans the logfile and summarizes the quality of the recovered file - videoitem.py.diff is a patch that uses the above code to recover the information and make it available to the skins - Panorama.fxd.diff is a patch that shows the above info in the file summary in the skin Panorama (other skins may be similarly modified) So with the above code, when I browse my recovered files with Freevo, I can see how well they were recovered. a.
#!/usr/bin/python
# (c) A Mennucc 2009
# License: GNU General Public License v 2
import sys, os
from math import floor
statuslabel={
'?':'non-tried',
'*':'non-trimmed',
'/':'non-split',
'-':'bad',
'+':'finished'}
def ls(filename, verbose=False):
totalsize=os.path.getsize(filename)
F= open(filename+".ddrescue")
F.readline()
F.readline()
F.readline()
for a in F:
a=a.rstrip('\n')
if a[0] == "#": continue
(where,null,size,null,status)=a.split(" ")
where=a.split(" ")[0]
where=int(where,16)
size=int(size,16)
if (where+size) > totalsize:
totalsize=where+size
#def p(j):
# return " %sKiB %4.1f%% " % (j/1024,float(j)/float(totalsize)*100.0)
def p(j):
s=(float(j)/float(totalsize)*100.0)
if j > 10000000:
return "%3.1f%% %sMiB" % (s,j/(1024*1024),)
if j < 10000:
return "%3.1f%% %sB" % (s,j,)
return "%3.1f%% %sKiB" % (s,j/1024,)
F= open(filename+".ddrescue")
a= F.readline()
while a[0]=="#":
a= F.readline()
a=a.rstrip('\n').split(" ")
(currentpos,currentstatus) = (a[0],a[-1])
currentpos=int(currentpos,16)
#what is this for???
#print 'arrived at %s status %s ' % (p(currentpos), statuslabel[currentstatus])
good=0
bad=0
nontrimmed=0
nonsplit=0
untried=0
s=''
for a in F:
a=a.rstrip('\n')
if a[0] == "#": continue
(where,null,size,null,status)=a.split(" ")
where=int(where,16)
size=int(size,16)
if verbose>1:
s+= ' at '+p(where)+' size '+p(size)+' status '+statuslabel[status]+'\n'
if status == '+':
good+=size
elif status == '-':
bad+=size
elif status == '?':
untried+=size
elif status == '/':
nonsplit+=size
elif status == '*':
nontrimmed+=size
else: raise AssertError(status)
if verbose == 0:
return 'good '+p(good)+'\n'
else:
return 'good '+p(good)+', untried '+p(untried)+\
', nontrimmed '+p(nontrimmed)+', nonsplit '+p(nonsplit)+', bad '+p(bad) +'\n'+ s
if __name__ == "__main__":
VERBOSE=0
argv=sys.argv[1:]
while argv[0] == '-v':
argv=argv[1:]
VERBOSE+=1
for filename in argv:
if os.path.isfile(filename) and filename[-9:] != '.ddrescue':
print 'file:',filename
try:
print 'ddrescue says: '+ls(filename, verbose=VERBOSE)
except Exception,s:
print ' error ',s
--- /usr/share/freevo/skins/main/Panorama.fxd~ 2009-04-07 20:32:05.000000000 +0200
+++ /usr/share/freevo/skins/main/Panorama+ddrescue.fxd 2009-09-01 23:59:00.000000000 +0200
@@ -146,6 +146,10 @@
<text font="info value" expression="runtime" />
<newline />
</if>
+ <if expression="ddrescue">
+ <goto_pos x="20" mode="relative" />
+ <text font="info value" expression="ddrescue" />
+ </if>
</item>
<item type="dir">
<text font="info tagline" width="max" expression="name" />
--- /usr/share/pyshared/freevo/video/videoitem.py~orig~ 2009-08-25 22:19:01.000000000 +0200
+++ /usr/share/pyshared/freevo/video/videoitem.py 2009-09-08 11:05:16.000000000 +0200
@@ -54,6 +54,7 @@
from event import *
from skin.widgets import ScrollableTextScreen
+import ddrescue
class VideoItem(Item):
"""
@@ -394,6 +395,15 @@
return total
+ if key == "ddrescue":
+ if os.path.isfile(self.filename+'.ddrescue'):
+ try:
+ return ddrescue.ls(self.filename)
+ except Exception,e:
+ return 'ddrescue error: '+str(e)
+ else:
+ return '[no ddrescue]'
+
return Item.__getitem__(self, key)
@@ -854,6 +864,8 @@
description += _('Year')+u' : '+movie['year'] + u'\n'
if movie['rating']:
description += _('Rating')+u' : '+movie['rating'] + u'\n'
+
+ description += movie['ddrescue'] + u'\n'
# that's all, we can show this to the user
ScrollableTextScreen.__init__(self, 'tvguideinfo', description)
signature.asc
Description: OpenPGP digital signature
------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________ Freevo-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/freevo-devel
