jamu.py crashed in Program._init_() from MythTV.py

Bug #452790 reported by Konrad Klimaszewski on 2009-10-16
32
This bug affects 3 people
Affects Status Importance Assigned to Milestone
mythplugins
Fix Released
Unknown
mythplugins (Ubuntu)
Undecided
Unassigned

Bug Description

Binary package hint: mythplugins

The /etc/cron.hourly/mythvideo crashes repeatably.

ProblemType: Crash
Architecture: i386
Date: Fri Oct 16 03:17:02 2009
DistroRelease: Ubuntu 9.10
ExecutablePath: /usr/share/mythtv/mythvideo/scripts/jamu.py
InterpreterPath: /usr/bin/python2.6
NonfreeKernelModules: nvidia
Package: mythvideo 0.22.0~zrc1-0ubuntu1
ProcCmdline: /usr/bin/python /usr/share/mythtv/mythvideo/scripts/jamu.py -MW
ProcEnviron:
 LANG=pl_PL.UTF-8
 SHELL=/bin/sh
ProcVersionSignature: Ubuntu 2.6.31-13.44-generic
PythonArgs: ['/usr/share/mythtv/mythvideo/scripts/jamu.py', '-MW']
SourcePackage: mythplugins
Title: jamu.py crashed with ValueError in __init__()
Uname: Linux 2.6.31-13-generic i686
UserGroups: audio cdrom dialout video

Related branches

Konrad Klimaszewski (graag) wrote :
tags: removed: need-duplicate-check
visibility: private → public
Changed in mythplugins (Ubuntu):
assignee: nobody → doug (r-d-vaughan)
Raymond (raymond-wagnerrp) wrote :

As far as I can tell, python should default to whatever C uses, and processing floats should "just work", however that never turns out as planned... I can work around this using 'locale.atof()' instead of 'float()', assuming python interprets your localizations settings properly.

Can you open python on the command line, run:

import locale
locale.localeconv()['decimal_point']

and see if it is set properly?

Mario Limonciello (superm1) wrote :

It lookes like you should be able to key off that.

http://www.doughellmann.com/PyMOTW/locale/index.html

Mario Limonciello (superm1) wrote :

(To add, you can do more experiments by setting LANG env variables)

Here goes python output:

>>> import locale
>>> locale.getdefaultlocale()
('pl_PL', 'UTF8')
>>> locale.localeconv()['decimal_point']
'.'
>>> locale.atof("100,1")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.6/locale.py", line 292, in atof
    return func(string)
ValueError: invalid literal for float(): 100,1

Seems it does not work. The decimal point used in Poland is ','.

Yet /usr/share/i18n/locales/pl_PL seems to be set correctly ...

Konrad Klimaszewski (graag) wrote :

Once again

>>> import locale
>>> locale.getlocale()
(None, None)
>>> locale.setlocale(locale.LC_ALL, '')
'pl_PL.UTF-8'
>>> locale.localeconv()['decimal_point']
','
>>> locale.atof("100,1")
100.09999999999999

So after setting the locale it worked.

Raymond (raymond-wagnerrp) wrote :

http://svn.mythtv.org/trac/ticket/7346

Should set the defaults from the environment, and adjusts all conversion between floats and strings to use their respective counterpart functions in locale.

Changed in mythplugins (Ubuntu):
status: New → In Progress
assignee: doug (r-d-vaughan) → nobody
Changed in mythplugins:
status: Unknown → Fix Released
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package mythplugins - 0.22.0+fixes22594-0ubuntu1

---------------
mythplugins (0.22.0+fixes22594-0ubuntu1) karmic; urgency=low

  * New upstream checkout.
    - Fixes jamu crash with non english locales. (LP: #452790)
    - Needs to be updated to due new binary version of the main package.

 -- Mario Limonciello <email address hidden> Mon, 26 Oct 2009 00:26:27 -0500

Changed in mythplugins (Ubuntu):
status: In Progress → Fix Released
georgaeie (georg-gac) wrote :

Hello guys,

I have the same behaviour, even with mythplugins - 0.22.0+fixes22594-0ubuntu1 installed.

Anyway, the fix seems to be in the file /usr/lib/python2.6/dist-packages/MythTV/MythTV.py, belonging to libmyth-python (also 0.22.0+fixes22594-0ubuntu1), and my file has the fix, as referred to in http://svn.mythtv.org/trac/attachment/ticket/7346/pyth.locale.patch,
but it still does not work.

Any ideas?

root@mythbuntu-backend:~# echo $LANG
nb_NO.UTF-8

Any information I can provide?

Thanks!

Georg

georgaeie (georg-gac) wrote :

I think this is the root of the problem:

>>> import locale
>>> locale.getlocale()
(None, None)
>>> locale.setlocale(locale.LC_ALL, '')
'nb_NO.UTF-8'
>>> locale.getlocale()
('nb_NO', 'UTF8')
>>> locale.localeconv()['decimal_point']
','
>>> locale.localeconv()['thousands_sep']
'\xc2\xa0'

It probably should have returned '.', I guess.

Regards,
Georg

georgaeie (georg-gac) wrote :

Fixed temporarily by setting locale explicitly in /etc/cron.hourly/mythvideo:

Original:

#!/bin/sh
#Hourly massive update to ensure users see graphics coming in for upcoming recordings and current recordings
DIRECTORY=$(grep ^mythtv /etc/passwd | awk -F : '{print $6}')
if [ -f "$DIRECTORY/.mythtv/config.xml" ]; then
    su mythtv -c ""/usr/bin/python /usr/share/mythtv/mythvideo/scripts/jamu.py -MW >> '/var/log/mythtv/jamu.log'"
fi

Amended script:

#!/bin/sh
#Hourly massive update to ensure users see graphics coming in for upcoming recordings and current recordings
DIRECTORY=$(grep ^mythtv /etc/passwd | awk -F : '{print $6}')
if [ -f "$DIRECTORY/.mythtv/config.xml" ]; then
    su mythtv -c ""export LANG=en_US.UTF-8; /usr/bin/python /usr/share/mythtv/mythvideo/scripts/jamu.py -MW >> '/var/log/mythtv/jamu.log'"
fi

Georg

georgaeie (georg-gac) wrote :

Sorry, I have and an extra quotation mark in the above post.
This is the correct one:

su mythtv -c "export LANG=en_US.UTF-8; /usr/bin/python /usr/share/mythtv/mythvideo/scripts/jamu.py -MW >> '/var/log/mythtv/jamu.log'"

Georg

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.