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

From MythTV Official Wiki
Jump to: navigation, search
m (Undo revision 55391 by Hugh (talk) It already does this. During the delete, it tells the backend to mark the recording as available to be rerecorded.)
(Error executing find_orphans.py)
 
(6 intermediate revisions by 4 users not shown)
Line 27: Line 27:
 
                 break
 
                 break
 
</pre>
 
</pre>
 +
 +
== Doesn't handle TB sized files/totals ==
 +
 +
Had to add 'TB' to the list of units on line 15 otherwise it complained about out-of-range:
 +
 +
return str(round(s,1))+('B ','KB','MB','GB','TB')[o]
 +
 +
== MacPorts edit ==
 +
 +
I was able to run this successfully on the Mac OS 10.9.5, MacPorts prebuilt 0.27.4 version of Myth TV (https://www.mythtv.org/wiki/Myth_on_Mac_OS_X#Pre-built_Downloads), by making some minor edits and adjusting for file location changes.
 +
 +
First line " #!/usr/bin/env python2 " is changed to " #!/opt/dvr/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 "
 +
 +
and the script is saved in the "/opt/dvr/share/mythtv/contrib" folder. Ownership was changed to root and group to Admin.
 +
 +
I have been looking for weeks for a solution to the UPnP server showing dead links. Thank you.
 +
 +
== Download file ==
 +
 +
It would be handy if the script were available as a download, rather than just as a pre-formatted text box. I think this should be possible using the file link and embedded file options, but since this is not my page, I offer this as a suggestion/request to the author.
 +
 +
== Error executing find_orphans.py ==
 +
 +
<pre>File "/usr/local/bin/mythFindOrphans.pl", line 27
 +
    name = u'%s: %s' % (self.host, os.path.join(self.path, self))
 +
                    ^
 +
SyntaxError: invalid syntax</pre>
 +
 +
I'm on Arch Linux 64-bit, and MythTV 29.0

Latest revision as of 10:57, 2 September 2017

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

Doesn't handle TB sized files/totals

Had to add 'TB' to the list of units on line 15 otherwise it complained about out-of-range:

return str(round(s,1))+('B ','KB','MB','GB','TB')[o]

MacPorts edit

I was able to run this successfully on the Mac OS 10.9.5, MacPorts prebuilt 0.27.4 version of Myth TV (https://www.mythtv.org/wiki/Myth_on_Mac_OS_X#Pre-built_Downloads), by making some minor edits and adjusting for file location changes.

First line " #!/usr/bin/env python2 " is changed to " #!/opt/dvr/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 "

and the script is saved in the "/opt/dvr/share/mythtv/contrib" folder. Ownership was changed to root and group to Admin.

I have been looking for weeks for a solution to the UPnP server showing dead links. Thank you.

Download file

It would be handy if the script were available as a download, rather than just as a pre-formatted text box. I think this should be possible using the file link and embedded file options, but since this is not my page, I offer this as a suggestion/request to the author.

Error executing find_orphans.py

File "/usr/local/bin/mythFindOrphans.pl", line 27
    name = u'%s: %s' % (self.host, os.path.join(self.path, self))
                     ^
SyntaxError: invalid syntax

I'm on Arch Linux 64-bit, and MythTV 29.0