Skip to content
This repository was archived by the owner on May 30, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions python/csconverter.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
'''

import sys, resources
from PyQt4.QtCore import QObject, QFile, QVariant, QString
from PyQt4.QtWebKit import QWebPage, QWebFrame
from PyQt4.QtWebKit import QWebPage

class CSConverter(QObject):
def __init__(self, parent = None):
Expand Down
13 changes: 10 additions & 3 deletions python/networkaccessmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,22 @@

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
'''
'''

from PyQt4.QtGui import QDesktopServices
from PyQt4.QtCore import SIGNAL, QString, qDebug, qWarning
from PyQt4.QtNetwork import QNetworkRequest, QNetworkAccessManager
from PyQt4.QtNetwork import QNetworkAccessManager, QNetworkDiskCache

class NetworkAccessManager(QNetworkAccessManager):
def __init__(self, parent = None):
def __init__(self, diskCacheEnabled, parent = None):
QNetworkAccessManager.__init__(self, parent)
self.connect(self, SIGNAL('finished(QNetworkReply *)'), self.handleFinished)

if diskCacheEnabled == 'yes':
m_networkDiskCache = QNetworkDiskCache()
m_networkDiskCache.setCacheDirectory(QDesktopServices.storageLocation(QDesktopServices.CacheLocation))
self.setCache(m_networkDiskCache)

def createRequest(self, op, req, outgoingData):
if op == QNetworkAccessManager.GetOperation:
qDebug('HTTP/1.1 GET Request')
Expand All @@ -48,6 +54,7 @@ def createRequest(self, op, req, outgoingData):

def handleFinished(self, reply):
qDebug('HTTP/1.1 Response')
qDebug(QString('URL %s' % reply.url().toString()))

headerPairs = reply.rawHeaderPairs()
for pair in headerPairs:
Expand Down
11 changes: 7 additions & 4 deletions python/phantom.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@
from webpage import WebPage
from networkaccessmanager import NetworkAccessManager

from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtWebKit import *
from PyQt4.QtCore import pyqtProperty, pyqtSlot, Qt, QObject, QString, \
QRect, SIGNAL, SLOT, QTimer, QUrl, QFileInfo, \
QDir, QSize, QSizeF, QTime, QEventLoop, qDebug
from PyQt4.QtGui import QPalette, QDesktopServices, qApp, QPrinter, \
QImage, QPainter, QRegion, QApplication
from PyQt4.QtWebKit import QWebSettings, QWebPage
from PyQt4.QtNetwork import QNetworkProxy, QNetworkProxyFactory

# Different defaults.
Expand Down Expand Up @@ -85,7 +88,7 @@ def __init__(self, args, parent = None):
os.chdir(os.path.dirname(self.m_scriptFile))

if self.m_verbose:
m_netAccessMan = NetworkAccessManager(self)
m_netAccessMan = NetworkAccessManager(args.disk_cache, self)
self.m_page.setNetworkAccessManager(m_netAccessMan)

# inject our properties and slots into javascript
Expand Down
2 changes: 1 addition & 1 deletion python/pyphantomjs.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from utils import argParser, MessageHandler, version

from PyQt4.QtCore import QString, qInstallMsgHandler, qFatal
from PyQt4.QtGui import *
from PyQt4.QtGui import QIcon, QApplication

# make keyboard interrupt quit program
import signal
Expand Down
8 changes: 6 additions & 2 deletions python/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ def argParser():
formatter_class=argparse.RawTextHelpFormatter
)

parser.add_argument('script', metavar='script.[js|coffee]', nargs='*',
help='The script to execute, and any args to pass to it'
)
parser.add_argument('--load-images', default='yes',
choices=['yes', 'no'],
help='Load all inlined images (default: %(default)s)'
Expand All @@ -67,8 +70,9 @@ def argParser():
parser.add_argument('--upload-file', nargs='*',
metavar='tag=file', help='Upload 1 or more files'
)
parser.add_argument('script', metavar='script.[js|coffee]', nargs='*',
help='The script to execute, and any args to pass to it'
parser.add_argument('--disk-cache', default='no',
choices=['yes', 'no'],
help='Enable disk cache (default: %(default)s)'
)
parser.add_argument('-v', '--verbose', action='store_true',
help='Show verbose debug messages'
Expand Down
5 changes: 3 additions & 2 deletions python/webpage.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
'''

from PyQt4.QtCore import *
from PyQt4.QtWebKit import *
from PyQt4.QtCore import SIGNAL, QString, QUrl, QEventLoop, qDebug
from PyQt4.QtGui import QApplication
from PyQt4.QtWebKit import QWebPage

class WebPage(QWebPage):
def __init__(self, parent = None):
Expand Down
3 changes: 2 additions & 1 deletion src/networkaccessmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ QNetworkReply *NetworkAccessManager::createRequest(Operation op, const QNetworkR
break;
}
}
qDebug() << "URL" << req.url();
qDebug() << "URL" << qPrintable(req.url().toString());

// Pass duty to the superclass - Nothing special to do here (yet?)
return QNetworkAccessManager::createRequest(op, req, outgoingData);
Expand All @@ -97,6 +97,7 @@ QNetworkReply *NetworkAccessManager::createRequest(Operation op, const QNetworkR
void NetworkAccessManager::handleFinished(QNetworkReply *reply)
{
qDebug() << "HTTP/1.1 Response";
qDebug() << "URL" << qPrintable(reply->url().toString());
QList<QNetworkReply::RawHeaderPair> headerPairs = reply->rawHeaderPairs();
foreach ( QNetworkReply::RawHeaderPair pair, headerPairs ) {
qDebug() << pair.first << "=" << pair.second;
Expand Down