Problem with HTTPS in python

  • I want to write plugin with support to connect to a server via https. I think that "DM version" of python 2.6.4 is not compiled with ssl support.

    This simple python code doesn't work:

    import urllib2

    opener = urllib2.build_opener(urllib2.HTTPCookieProcessor())"")

    and return the error urllib2.URLError: <urlopen error unknown url type: https>

    Is it possible to solve my problem?

    Many thanks.

    PS: The command hasattr(socket, 'ssl') returns True, but hasattr(httplib, 'HTTPS') returns False and that is problem :(

  • Take a look at the modules. tries to import _ssl.
    hasattr(socket, 'ssl') returns True, so the package "python-io" is installed on your system. tries to import ssl, without _.
    hasattr(httplib, 'HTTPS') returns False, so the package "python-misc" is not installed on your system.

    "ipkg update && ipkg install python-misc" should solve your problem.

    Your simple code is ok on my box.

  • I have already installed python-misc package, of course with some openssl packages. Maybe another package is missing.

    I have no problem with above script on my desktop PC with linux.

    On which image hasattr(httplib, 'HTTPS') returns True? I would like to install it and try.


    PS: The command "import _ssl" was executed without error.

  • At the moment I use the latest OoZooN Image.

    "import ssl" should give the right error message.
    Is python-textutils installed?

  • Many thanks, the python-textutils was missing! I have to manual download it from the web because in my iCVS repo's was not such package.

    >>> import httplib
    >>> hasattr(httplib, 'HTTPS')

    :) :)