[mythtv-users] python bindings and timezones

Stephen Robertson stephengrobertson at gmail.com
Sat Dec 29 07:30:08 UTC 2012


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:
>>
>> There is something funny with my system and it seems to be related to
>> timezones.
>>
>> As far as I can tell my system is set for the correct timezone:
>>
>> $ cat /etc/timezone
>> Europe/London
>
>
> The '/etc/timezone' file is not any standard behavior. Timezone data is
> stored in '/etc/localtime', and is actually a copy of the zoneinfo file, not
> just the name of one. Near as I can tell, '/etc/timezone' is just some
> particular behavior of Debian and company, used to pre-populate the TZ
> environmental variable, which is standard behavior and should be used by the
> python bindings but isn't.
>
>
>>>>> 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.
>
>
>> 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)


More information about the mythtv-users mailing list