[mythtv-users] Rename a file problems

Raymond Wagner raymond at wagnerrp.com
Fri Feb 10 12:34:37 UTC 2012


On 2/10/2012 06:51, David Crawford wrote:
> Since it works in perl and mythlink.pl <http://mythlink.pl> and 
> mythrenam.pl <http://mythrenam.pl>, does anyone know a way whereby I 
> could pull the info in the same way as in mythlink using perl and 
> perhaps add that to my python script?

As mentioned, the problem isn't that you can't access that data through 
the bindings, but that in order to access that data in the right place, 
you would either incur a circular import, or break the intended location 
of classes.

The command you were using was in mythproto.py, intended for methods and 
objects returned by the backend over Myth's internal protocol.
https://github.com/MythTV/mythtv/blob/master/mythtv/bindings/python/MythTV/mythproto.py#L977

The information you need is accessible through dataheap.py, intended as 
a heap of classes used to access the database.
https://github.com/MythTV/mythtv/blob/master/mythtv/bindings/python/MythTV/dataheap.py#L649

dataheap.py already imports elements out of mythproto.py, which means 
mythproto.py cannot in turn import anything out of dataheap.py, as the 
Python interpreter will simply skip over it.

In your own code, sitting above the bindings, you could extract such 
information using...

from MythTV import Channel
path = '%cn %cc %cN.srt'
chan = Channel(<chanid>)
for (tag, data) in (('cn', 'channum'),('cc','callsign'),('cN','name')):
     tmp = unicode(chan[data]).replace('/','-')
     path = path.replace('%'+tag, tmp)
print path

But to be honest, substituting those values in manually, and then 
substituting everything else in through the Program.formatPath method, 
just feels clumsy to me.  On the other hand, there is no simple way to 
fix it in the bindings, besides arbitrarily moving the Channel class 
into the wrong file.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.mythtv.org/pipermail/mythtv-users/attachments/20120210/3cf51826/attachment.html 


More information about the mythtv-users mailing list