[Python-modules-commits] [sphinx] 01/01: Use implementation of jstest from Iain Lane in hope it succeeds on buildds.
Dmitry Shachnev
mitya57 at moszumanska.debian.org
Thu Mar 3 17:19:56 UTC 2016
This is an automated email from the git hooks/post-receive script.
mitya57 pushed a commit to branch master
in repository sphinx.
commit 736b3e4cf658d776aaa1e6afbc271e3f0582db94
Author: Dmitry Shachnev <mitya57 at gmail.com>
Date: Thu Mar 3 20:19:32 2016 +0300
Use implementation of jstest from Iain Lane in hope it succeeds on buildds.
---
debian/changelog | 7 ++++++
debian/jstest/jstest.py | 57 ++++++++++++++++++++++---------------------------
2 files changed, 33 insertions(+), 31 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index 6b00436..f6f8642 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+sphinx (1.3.6-2) unstable; urgency=medium
+
+ * Use implementation of jstest from Iain Lane in hope it succeeds on
+ buildds.
+
+ -- Dmitry Shachnev <mitya57 at debian.org> Thu, 03 Mar 2016 20:17:15 +0300
+
sphinx (1.3.6-1) unstable; urgency=medium
* New upstream bugfix release.
diff --git a/debian/jstest/jstest.py b/debian/jstest/jstest.py
index bc5ce18..2b00c57 100644
--- a/debian/jstest/jstest.py
+++ b/debian/jstest/jstest.py
@@ -35,10 +35,9 @@ import gi
gi.require_version('Gtk', '3.0')
gi.require_version('WebKit2', '4.0')
-from gi.repository import Gio, GLib, Gtk, WebKit2
+from gi.repository import GLib, Gtk, WebKit2
-default_time_limit = 10.0
-time_step = 0.1
+default_time_limit = 40.0
# HTTP browser
# ============
@@ -52,44 +51,40 @@ class Browser(object):
settings = WebKit2.Settings()
settings.set_property('allow-file-access-from-file-urls', True)
self._time_limit = 0
- self._view = WebKit2.WebView()
- self._view.set_settings(settings)
+ self._view = WebKit2.WebView.new_with_settings(settings)
+ self._view.connect('notify::title', self._on_title_changed)
self._result = None
+ self._id = 0
+
+ def _on_title_changed(self, webview, user_data):
+ contents = webview.get_property('title')
+ webview.run_javascript('document.title = ""')
+ found = "Search finished" in contents
+ if found:
+ self._result = contents
+ Gtk.main_quit()
+ GLib.source_remove(self._id)
+ self._id = 0
+
+ def _quit(self):
+ self._view.run_javascript('document.title = document.documentElement.innerHTML')
+ if self._time_limit < 0:
+ self._result = None
+ Gtk.main_quit()
+ return GLib.SOURCE_REMOVE
+
+ self._time_limit -= 1
+ return GLib.SOURCE_CONTINUE
def wget(self, url, time_limit=default_time_limit):
self._view.load_uri(url)
self._time_limit = time_limit
- GLib.timeout_add(int(1000 * time_step), self._check)
+ self._id = GLib.timeout_add_seconds(time_limit, self._quit)
Gtk.main()
if self._result is None:
raise Timeout
return self._result
- def _js_callback(self, source, result):
- self._view.run_javascript_finish(result)
- self._result = self._view.get_title()
-
- def _extract_html(self):
- # There is not obvious way to extract HTML from WebKit.
- # We use a trick from <http://code.google.com/p/pywebkitgtk/wiki/HowDoI> instead.
- cancellable = Gio.Cancellable()
- self._view.run_javascript('document.title = document.body.innerHTML',
- cancellable, self._js_callback)
-
- def _check(self):
- if self._result is not None:
- match = re_done.search(self._result)
- if match is not None:
- Gtk.main_quit()
- return
- self._time_limit -= time_step
- if self._time_limit < 0:
- self._result = None
- Gtk.main_quit()
- else:
- self._extract_html()
- GLib.timeout_add(int(1000 * time_step), self._check)
-
# Actual tests
# ============
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/sphinx.git
More information about the Python-modules-commits
mailing list