Difference between revisions of "Talk:Find orphans.py"

From MythTV Official Wiki
Jump to: navigation, search
(patch to make it work for me (Hugh))
(request an update to the Previously Recorded state.)
Line 27: Line 27:
 
                 break
 
                 break
 
</pre>
 
</pre>
 +
== delete Previously Recorded state when deleting a recording ==
 +
When a recording is being deleted, it sure would be nice if it was removed from the Previous Recorded state.  Previously Recorded is used to prevent the user from recording something a second time.  But since the recording has been lost, the user probably does want to record it again.

Revision as of 02:49, 2 July 2012

patch to make it work for me (Hugh)

This script didn't quite work for me with MythTV 0.24 + fixes as produced by MythBuntu on Ubuntu 10.04 LTS on 2012 July 1.

When directed to "Delete orphaned recording entries", it would delete a few, catch an exception, and stop.

To fix the problem, I copied the exception handling code into the for-each-recording-to-be-deleted loop so that a failure to delete one recording would not prevent subsequent deletions.

Not only did this work, it seemed to not print any diagnostics. I'm not sure why. It could be that there were only a few recordings that caused the exception and that I had already powered through them by the time I ran the modified script.

$ diff -u bin/find_orphans.py bin/find_orphans.fudged.py
--- bin/find_orphans.py 2012-07-01 17:37:34.000000000 -0400
+++ bin/find_orphans.fudged.py  2012-07-01 19:52:42.000000000 -0400
@@ -126,7 +126,13 @@
         while True:
             if res == 'yes':
                 for rec in recs:
-                    rec.delete(True, True)
+                    try:
+                        rec.delete(True, True)
+                    except MythError:
+                        name = u'{0.hostname}: {0.title}'.format(rec)
+                        if rec.subtitle:
+                            name += ' - '+rec.subtitle
+                        print "Ignoring: Failed to delete '" + name + "'"
                 break
             elif res == 'no':
                 break

delete Previously Recorded state when deleting a recording

When a recording is being deleted, it sure would be nice if it was removed from the Previous Recorded state. Previously Recorded is used to prevent the user from recording something a second time. But since the recording has been lost, the user probably does want to record it again.