From 507f8a413985cb7e3f6b0fa3b8d201d1c4aafc4b Mon Sep 17 00:00:00 2001 From: Marcos Pinto Date: Mon, 23 Jul 2007 21:52:13 +0000 Subject: [PATCH] add spawning to deal with 2.5 being stupid with threading --- src/browser.py | 4 ++++ src/common.py | 28 +++++++++++----------------- 2 files changed, 15 insertions(+), 17 deletions(-) create mode 100644 src/browser.py diff --git a/src/browser.py b/src/browser.py new file mode 100644 index 000000000..da7437164 --- /dev/null +++ b/src/browser.py @@ -0,0 +1,4 @@ +#!/usr/bin/env python +import webbrowser +import sys +webbrowser.open(sys.argv[1]) diff --git a/src/common.py b/src/common.py index 6a6adba7b..c690dfd74 100644 --- a/src/common.py +++ b/src/common.py @@ -1,4 +1,5 @@ -# dcommon.py +#!/usr/bin/env python +# -*- coding: utf-8 -*- # # Copyright (C) Zach Tibbitts 2006 # @@ -119,22 +120,15 @@ def get_pixmap(fname): return os.path.join(PIXMAP_DIR, fname) def open_url_in_browser(link): - import webbrowser - - # why this method with causes up to 1 minutes delays when opening url in - # deluge ? when you run it from console - works instantly. maybe it has - # something to do with libtorrent's threads or with boost mt/nomt ? - - #import threading - #class LaunchBrowser(threading.Thread): - # def run(self): - # try: - # webbrowser.open(link) - # except webbrowser.Error: - # print _("Error: no webbrowser found") - #LaunchBrowser().start() - - webbrowser.open(link) + import platform + if platform.system() == "Windows": + import webbrowser + webbrowser.open(link) + else: + import os, sys + version = sys.version[:3] + file = '/usr/lib/python' + version + '/site-packages/deluge/browser.py' + os.spawnlp(os.P_NOWAIT, 'python', 'python', file, link) def is_url(url): import re