aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Weiske <cweiske@cweiske.de>2011-11-24 18:19:40 +0100
committerChristian Weiske <cweiske@cweiske.de>2011-11-24 18:19:40 +0100
commit48dcd6c40effaf3e783959edbf9257525a773319 (patch)
tree73b2ce4769b1abf09031df0b141d144bf40b423f /src
parenta36b80acbdee4586c8f6d28bdc46b268293c39e8 (diff)
downloadenigma2-curlytx-48dcd6c40effaf3e783959edbf9257525a773319.tar.gz
enigma2-curlytx-48dcd6c40effaf3e783959edbf9257525a773319.zip
Show headers when pressing info button
Diffstat (limited to 'src')
-rw-r--r--src/CurlyTx.py46
1 files changed, 43 insertions, 3 deletions
diff --git a/src/CurlyTx.py b/src/CurlyTx.py
index 09d9ad1..b6df45d 100644
--- a/src/CurlyTx.py
+++ b/src/CurlyTx.py
@@ -8,6 +8,7 @@ from Components.ScrollLabel import ScrollLabel
from Components.ActionMap import ActionMap
from Components.Sources.StaticText import StaticText
from twisted.web import client
+from twisted.web.client import _makeGetterFactory, HTTPClientFactory
from enigma import gFont
from . import config
@@ -30,6 +31,8 @@ class CurlyTx(Screen,HelpableScreen):
currentUrl = None
currentPage = None
currentFontSize = 20
+ httpGetterFactory = None
+ showingHeaders = False
def __init__(self, session, args = None):
#self.skin = CurlyTx.skin
@@ -46,7 +49,7 @@ class CurlyTx(Screen,HelpableScreen):
self["actions"] = ActionMap(
- ["WizardActions", "ColorActions", "InputActions"], {
+ ["WizardActions", "ColorActions", "InputActions", "InfobarEPGActions"], {
"ok": self.close,
"back": self.close,
"up": self.pageUp,
@@ -55,7 +58,9 @@ class CurlyTx(Screen,HelpableScreen):
"red": self.showSettings,
"green": self.reload,
"yellow": self.prevPage,
- "blue": self.nextPage
+ "blue": self.nextPage,
+
+ "showEventInfo": self.showHeader
}, -1)
self.loadHelp()
@@ -71,6 +76,9 @@ class CurlyTx(Screen,HelpableScreen):
self["actions"], "WizardActions",
[("down", _("Scroll page contents down"))]))
self.helpList.append((
+ self["actions"], "InfobarEPGActions",
+ [("showEventInfo", _("Show HTTP response headers"))]))
+ self.helpList.append((
self["actions"], "ColorActions",
[("red", _("Show program settings"))]))
self.helpList.append((
@@ -166,7 +174,7 @@ class CurlyTx(Screen,HelpableScreen):
self.setTextFont()
self["text"].setText("Loading ...\n" + url);
- client.getPage(url).addCallback(self.urlLoaded).addErrback(self.urlFailed, url)
+ self.getPageWebClient(url).addCallback(self.urlLoaded).addErrback(self.urlFailed, url)
def setTextFont(self):
if self["text"].long_text is not None:
@@ -184,6 +192,19 @@ class CurlyTx(Screen,HelpableScreen):
def loadNoPage(self):
self["text"].setText("Go and add a page in the settings");
+ def showHeader(self):
+ if self.showingHeaders:
+ self["text"].setText(self.pageContent)
+ self.pageContent = None
+ self.showingHeaders = False
+ else:
+ headers = "HTTP response headers for\n" + self.currentUrl + "\n\n"
+ for (k, v) in self.httpGetterFactory.response_headers.items():
+ headers += k + ": " + ("\n" + k + ": ").join(v) + "\n"
+ self.pageContent = self["text"].getText()
+ self["text"].setText(headers)
+ self.showingHeaders = True
+
def showSettings(self):
from CurlyTxSettings import CurlyTxSettings
self.session.openWithCallback(self.onSettingsChanged, CurlyTxSettings)
@@ -196,3 +217,22 @@ class CurlyTx(Screen,HelpableScreen):
elif self.currentPage == None:
self.currentPage = 0
self.loadUrl(self.currentPage)
+
+
+ def getPageWebClient(self, url, contextFactory=None, *args, **kwargs):
+ """
+ Download a web page as a string.
+
+ COPY OF twisted.web.client.getPage to store the factory
+
+ Download a page. Return a deferred, which will callback with a
+ page (as a string) or errback with a description of the error.
+
+ See L{HTTPClientFactory} to see what extra arguments can be passed.
+ """
+ self.httpGetterFactory = _makeGetterFactory(
+ url,
+ HTTPClientFactory,
+ contextFactory=contextFactory,
+ *args, **kwargs)
+ return self.httpGetterFactory.deferred