jeanphix / Ghost.py

Webkit based scriptable web browser for python.
http://ghost-py.readthedocs.org/en/latest/
2.76k stars 380 forks source link

sslErrors attribute in anaconda python #177

Open aflaxman opened 10 years ago

aflaxman commented 10 years ago

I'm trying to use Ghost.py with the anaconda python distribution, and running into an issue with the self.manager.sslErrors.connect call. Do you have any ideas for a fix or work-around?

Here is the full error:

C:\Users\abie\AppData\Local\Continuum\Anaconda>ipython
Python 2.7.6 |Anaconda 1.9.1 (64-bit)| (default, Nov 11 2013, 10:49:15) [MSC v.1500 64 bit (AMD64)]
Type "copyright", "credits" or "license" for more information.

IPython 2.1.0 -- An enhanced Interactive Python.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://binstar.org
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: from ghost import Ghost

In [2]: ghost = Ghost()
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-2-570d03f31ecf> in <module>()
----> 1 ghost = Ghost()

C:\Users\abie\AppData\Local\Continuum\Anaconda\lib\site-packages\ghost\ghost.pyc in __init__(self, user_agent, wait_timeout, wait_ca
llback, log_level, display, viewport_size, ignore_ssl_errors, cache_dir, plugins_enabled, java_enabled, plugin_path, download_images
, qt_debug, show_scroolbars)
    330         self.manager = self.page.networkAccessManager()
    331         self.manager.finished.connect(self._request_ended)
--> 332         self.manager.sslErrors.connect(self._on_manager_ssl_errors)
    333         # Cache
    334         if cache_dir:

AttributeError: 'PySide.QtNetwork.QNetworkAccessManager' object has no attribute 'sslErrors'

This is using pyside 1.2.1:

C:\Users\abie\AppData\Local\Continuum\Anaconda>conda update pyside
Fetching package metadata: ..
# All requested packages already installed.
# packages in environment at C:\Users\abie\AppData\Local\Continuum\Anaconda:
#
pyside                    1.2.1                    py27_0

Maybe @asmeurer or someone else from @ContinuumIO will know, so I've post a similar question in the anaconda issue tracker here as well.

brandon-rhodes commented 10 years ago

This error occurs when Ghost.py is running against any PyQt or PySide that was compiled in the absence (or ignorance) of the OpenSSL headers and libraries. Something like the following maneuver can at least allow Ghost.py to start up in such a case, and load non-SSL pages successfully:

try:
    self.manager.sslErrors.connect(self._on_manager_ssl_errors)
except AttributeError:
    pass

Thanks to such a maneuver, I have gotten Ghost.py working this evening and might therefore be able to include it in this revised copy of my Python Network Programming books. Is there any chance this change can make it into Ghost.py itself so that the example will also work for my readers, if their PyQt or PySide lacks SSL support?

brandon-rhodes commented 10 years ago

(And: thanks for writing Ghost.py!)

asmeurer commented 10 years ago

Is it PyQT or QT itself that lacks the OpenSSL support?

brandon-rhodes commented 10 years ago

(Am answering the Anaconda-related question over at https://github.com/ContinuumIO/anaconda-issues/issues/140 to keep this issue focused on whether Ghost.py can be improved so as to survive qt libraries that lack SSL support)