[mythtv-users] Converting scripts to not use the database directly

Bill Meek keemllib at gmail.com
Mon Nov 3 04:05:26 UTC 2014


On 11/01/2014 08:47 PM, Mike Rice wrote:
>
> As far as I can tell you need to supply each parameter to the function:
>
> bool Channel::UpdateDBChannel( uint          MplexID,
>                                 uint          SourceID,
>                                 uint          ChannelID,
>                                 const QString &CallSign,
>                                 const QString &ChannelName,
>                                 const QString &ChannelNumber,
>                                 uint          ServiceID,
>                                 uint          ATSCMajorChannel,
>                                 uint          ATSCMinorChannel,
>                                 bool          UseEIT,
>                                 bool          visible,
>                                 const QString &FrequencyID,
>                                 const QString &Icon,
>                                 const QString &Format,
>                                 const QString &XMLTVID,
>                                 const QString &DefaultAuthority )
>
> If you don't supply the parameter it ends up zero and your table is updated
> with a zero value for that column.  If I am careful I can get this right
> now but if someone adds a parameter here and does not add it with the same
> name in the GET function (or if my script doesn't use those keys) it will
> be zero when I call the function.
>
> I guess my script would need to abort if the ProtoVer changes then go in
> and look at the source to see if I am okay.
>
> Is it a bug that the keys do not match between GetChannelInfoList and
> UpdateDBChannel?  Or am I going about this incorrectly?

It appears that the intent is to use GetChannelInfo as a template for
changing the data with UpdataDBChannel, which would make either of our
solutions spot on.

I'd say bug. I can see how to submit a patch that would check for empty
strings, but not how to check for missing uints or bools. It also looks
like the UpdateDBChannel and AddDBChannel endpoints use the same names,
so GetChannelInfo is the odd-man-out. Changing GetChannelInfo only would
break WebFrontend in 0.28-pre, so the fix probably needs to care for
that too.

I'd add, if the returned parameter is empty (e.g. DefaultAuthority in my case), then
is doesn't have to be sent. The good news is that my original pastebin's will go
away in 28 days. The bad news is that 171 folks looked at them and might not
read the rest of this thread. If used, bad things *will* happen, as Mike noted.

The 'offending' keys are (GET:POST order):

         'ChanId':'ChannelID', \
         'ChanNum':'ChannelNumber', \
         'ATSCMajorChan':'ATSCMajorChannel', \
         'ATSCMinorChan':'ATSCMinorChannel', \
         'IconURL':'Icon

If user's contributed libraries, then the original task of setting visible
to false would look like this (in Python):

     import Channel
     Host='someHostName'
     for chanid in '1021', '1091', etc.
         channelDict = Channel.GetChannelInfo(host=Host, chanid=chanid)
         channelDict['Visible'] = 'false'
         Channel.UpdateDBChannel(host=Host, rdict=channelDict)

I'd say that's a very reasonable substitute for the SQL, and much safer, Once
the key issue is resolved (easily handled in the Channel module for now.)

-- 
Bill


More information about the mythtv-users mailing list