From b4145e683a3ca9e1a64eca045c0f46bb189a7518 Mon Sep 17 00:00:00 2001 From: Markus Hitter Date: Tue, 9 Jun 2015 01:59:00 +0200 Subject: [PATCH] Configtool: work around a URL-open bug on some Linuxes. Not exactly ideal, but the best I could find so far. This is work related to issue #159. --- configtool.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/configtool.py b/configtool.py index c421e8c..3862d0a 100755 --- a/configtool.py +++ b/configtool.py @@ -535,6 +535,8 @@ class ConfigFrame(wx.Frame): def onReportProblem(self, evt): import urllib import webbrowser + import subprocess + from sys import platform # Testing allowed URLs up to 32 kB in size. Longer URLs are simply chopped. mailRecipients ="reply+0004dc756da9f0641af0a3834c580ad5be469f4f6b" \ @@ -566,6 +568,27 @@ class ConfigFrame(wx.Frame): url = "mailto:" + urllib.quote(mailRecipients) + \ "?subject=" + urllib.quote(mailSubject) + \ "&body=" + urllib.quote(mailBody) + + # This is a work around a bug in gvfs-open coming with (at least) Ubuntu + # 15.04. gvfs-open would open mailto:///user@example.com instead of + # the requested mailto:user@example.com. + if platform.startswith("linux"): + try: + subprocess.check_output(["gvfs-open", "--help"]) + + # Broken gvfs-open exists, so it might be used. + # Try to open the URL directly. + for urlOpener in "thunderbird", "evolution", "firefox", "mozilla", \ + "epiphany", "konqueror", "chromium-browser", \ + "google-chrome": + try: + subprocess.check_output([urlOpener, url], stderr=subprocess.STDOUT) + return + except: + pass + except: + pass + webbrowser.open_new(url) def onAbout(self, evt):