[mythtv-users] python bindings and timezones

Stephen Robertson stephengrobertson at gmail.com
Sat Dec 29 11:05:14 UTC 2012


Sorry just discovered a new keyboard shortcut to send emails before
I've finished!

> On Sat, Dec 29, 2012 at 1:54 AM, Raymond Wagner <raymond at wagnerrp.com> wrote:
>> On 12/28/2012 18:06, Stephen Robertson wrote:

>>>>>> recorded_list =
>>>>>> list(db.searchRecorded(basename="7940_20121228185800.mpg"))
>>>>>> recorded_list
>>>
>>> [<Recorded 'Earthflight','2012-12-28 19:58:00+01:00' at 0xb663ee3cL>]
>>
>>
>> Since the python bindings are ignoring that TZ variable, either you have
>> stored the wrong zoneinfo file in '/etc/localtime', or I screwed up the
>> parser that reads and interprets those zoneinfo files. To be honest, this
>> one could go either way.

I've tried dpkg-reconfigure tzdata and made sure I chose Europe/London
(it seemed to be the currently selected option), as far as I can tell
this is what I need to do to set this appropriately.

>>> and is basically that I cannot delete recordings using the python
>>> bindings.
>>
>>
>> Now this part doesn't make much sense. The local timezone display in the
>> python bindings is purely cosmetic. All communication with the database and
>> backend is in UTC, and the local timezone conversion is only used for
>> convenient display for the user. If the times are converted improperly in
>> one direction, they should similarly be converted back improperly in the
>> other direction, and deletes should work just fine. That is unless you are
>> supplying the time that should be deleted, and the conversion is only
>> happening one way. Without seeing the code, I can't know if this is the
>> case.
> $ python
> Python 2.7.3 (default, Aug  1 2012, 05:16:07)
> [GCC 4.6.3] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> from MythTV import MythDB, MythBE, Recorded
>>>> db = MythDB()
>>>> be = MythBE(backend=db.gethostname(), db=db)
>>>> recorded_list = list(db.searchRecorded(basename="7940_20121228185800.mpg"))
>>>> recorded_list
> [<Recorded 'Earthflight','2012-12-28 19:58:00+01:00' at 0x89f9e3c>]
>>>> recorded=recorded_list[0]
>>>> recorded
> <Recorded 'Earthflight','2012-12-28 19:58:00+01:00' at 0x89f9e3c>
>>>> program = be.getRecording(chanid=recorded.chanid,starttime=recorded.starttime)
>>>> program
> <Program 'Earthflight','2012-12-28 20:00:00+01:00' at 0x89fddac>
>>>> result = be.deleteRecording(program, force=True)

results in

mythbackend[15621]: E DeleteThread mainserver.cpp:1954
(DoDeleteThread) ERROR retrieving program info when trying to delete
program for chanid 7940 recorded at 2012-12-28T19:58:00Z. Recording
will NOT be deleted.

also:
>>> recorded.starttime
datetime(2012, 12, 28, 19, 58, tzinfo=<MythTV.utility.dt.offsettzinfo
object at 0x8946c6c>)

I've tried changing the system timezone(dpkg-reconfigure tzdata and a
reboot) to etc/gmt+0 ( which is the same as my current timezone
Europe/London) and in that case then I get:
<Program 'Earthflight','2012-12-28 19:00:00+00:00' at 0x89fddac>

and I can delete the recordings using

be.deleteRecording(program, force=True)

so it does seem to be timezone dependent.

I'll keep investigating
Stephen


More information about the mythtv-users mailing list