tvgrabbers / tvgrabnlpy

Deze versie is deprecated zie: tvgrabpyAPI
https://github.com/tvgrabbers/tvgrabpyAPI
GNU General Public License v2.0
27 stars 8 forks source link

Error with new nieuwsblad.be source #48

Closed kyl416 closed 8 years ago

kyl416 commented 8 years ago

I get the following when I try to run configure after you added the nieuwsblad.be source

Traceback (most recent call last):
  File "tv_grab_nl.py", line 11516, in get_channels
    strdata = self.get_page(self.get_url('base'))
  File "tv_grab_nl.py", line 11494, in get_url
    locale.setlocale(locale.LC_TIME, ('nl_NL', 'utf-8'))
  File "/usr/lib/python2.7/locale.py", line 579, in setlocale
    return _setlocale(category, locale)
Error: unsupported locale setting
hikavdh commented 8 years ago

You are running it under Windows? I didn't test it there.

kyl416 commented 8 years ago

Linux, Ubuntu 15.10

hikavdh commented 8 years ago

Can you check what your locale is in python. First you open the interpreter by starting python2 Then you load the locale module with import locale If you then run print locale.getlocale() you should get (None, None) So you load your locale with: locale.setlocale(locale.LC_ALL, '') and run again print locale.getlocale(). What then do you get?

kyl416 commented 8 years ago
Python 2.7.10 (default, Oct 14 2015, 16:09:02) 
[GCC 5.2.1 20151010] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import locale
>>> print locale.getlocale()
(None, None)
>>> locale.setlocale(locale.LC_ALL, '')
'en_US.UTF-8'
>>> print locale.getlocale()
('en_US', 'UTF-8')

Just a guess, maybe LC_TIME should be something else in the following line locale.setlocale(locale.LC_TIME, ('nl_NL', 'utf-8'))

hikavdh commented 8 years ago

You mean the space after the , ? No

kyl416 commented 8 years ago

I'm just throwing random guesses out, perhaps it's case-sensitive and should be UTF-8?

hikavdh commented 8 years ago

I'm at present testing some thing in Windows and there the natural string is ('Dutch_Netherlands, '1252') and anything different gives an error. The Python manual says that both utf-8, UTF-8, utf8, UTF8, utf_8 and UTF_8 or even just U8 are equal, but the official name is utf_8. But they all give an error. Itś there because I need the Dutch weekday names for the url. Not the English.

kyl416 commented 8 years ago

Just a guess, but should it say locale.LC_TIME or locale.LC_ALL on that line? I tried entering the same commands with local.LC_TIME instead and this was the result:

Python 2.7.10 (default, Oct 14 2015, 16:09:02) 
[GCC 5.2.1 20151010] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import locale
>>> print locale.getlocale()
(None, None)
>>> locale.setlocale(locale.LC_TIME, '')
'en_US.UTF-8'
>>> print locale.getlocale()
(None, None)
hikavdh commented 8 years ago

LC_TIME is a subset of LC_ALL and I didn't want to change more then needed. If you ask print locale.getlocale(locale.LC_TIME) You get that one else you get ALL

hikavdh commented 8 years ago

I've set it back to beta. I might have to set up an Ubuntu system to test. At present I do not understand. Except possibly that you simply do not have the Dutch locale definition on your system. But as far as I know those are always present on Linux, only possibly not under Windows. I might have to create my own weekdaynumber to weekday table.

hikavdh commented 8 years ago

What do you get on locale.setlocale(locale.LC_TIME, ('nl_NL', 'UTF-8'))?

hikavdh commented 8 years ago

Oh if you want to get out of the Python interpreter you press Ctrl-D

kyl416 commented 8 years ago

It looks like at least Ubuntu only activates your own locales, here's the output of locale -a

C
C.UTF-8
en_AG
en_AG.utf8
en_AU.utf8
en_BW.utf8
en_CA.utf8
en_DK.utf8
en_GB.utf8
en_HK.utf8
en_IE.utf8
en_IN
en_IN.utf8
en_NG
en_NG.utf8
en_NZ.utf8
en_PH.utf8
en_SG.utf8
en_US.utf8
en_ZA.utf8
en_ZM
en_ZM.utf8
en_ZW.utf8
POSIX

And this was the output:

locale.setlocale(locale.LC_TIME, ('nl_NL', 'UTF-8'))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/locale.py", line 579, in setlocale
    return _setlocale(category, locale)
locale.Error: unsupported locale setting

After I manually use the locale-gen command to add nl_NL, nl_NL.utf8, nl_BE and nl_BE.utf8 they showed up on the list:

C
C.UTF-8
en_AG
en_AG.utf8
en_AU.utf8
en_BW.utf8
en_CA.utf8
en_DK.utf8
en_GB.utf8
en_HK.utf8
en_IE.utf8
en_IN
en_IN.utf8
en_NG
en_NG.utf8
en_NZ.utf8
en_PH.utf8
en_SG.utf8
en_US.utf8
en_ZA.utf8
en_ZM
en_ZM.utf8
en_ZW.utf8
nl_BE
nl_BE.iso88591
nl_BE.utf8
nl_NL
nl_NL.iso88591
nl_NL.utf8
POSIX

And now the command works:

locale.setlocale(locale.LC_TIME, ('nl_NL', 'UTF-8'))
'nl_NL.UTF-8'
hikavdh commented 8 years ago

So I guess I create a lookup table for those weekdays

kyl416 commented 8 years ago

Yeah, I'm not sure how other Linux distributions behave when it comes to the default set of locales

hikavdh commented 8 years ago

Nah, my assumption was mistaken, the tables are there by default but as you pointed out, you need to generate the locale out of it. I forgot.

hikavdh commented 8 years ago

And in Windows you have to download them. I think

hikavdh commented 8 years ago

Ok try again. It should now work properly

winfried commented 8 years ago

On 11/16/2015 10:07 PM, Hika van den Hoven wrote:

Hi,

But as far as I know those are always present on Linux, only possibly not under Windows. I might have to create my own weekdaynumber to weekday table.

On Debian/Ubuntu bases systems (and AFAIK on all Linux systems) you are asked what default locale you want to have when installing the system and what additional locales you want to have. Changing it later or adding locales is perfectly possible: https://help.ubuntu.com/community/Locale https://people.debian.org/~schultmc/locales.html

Winfried

hikavdh commented 8 years ago

I should have known, I just didn't realize at the moment.