From aaad0651e2da7cc3788cc060256dd279dd676d1f Mon Sep 17 00:00:00 2001 From: Marcos Pinto Date: Tue, 15 Jul 2008 22:29:35 +0000 Subject: [PATCH] move from os.popen and os.popen2 to subproces.Popen for 2.6 compatibility as they've been deprecated --- deluge/common.py | 3 ++- deluge/ui/gtkui/connectionmanager.py | 7 ++++--- deluge/ui/webui/utils.py | 3 ++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/deluge/common.py b/deluge/common.py index 1ff4a53e1..a404707b8 100644 --- a/deluge/common.py +++ b/deluge/common.py @@ -34,6 +34,7 @@ """Common functions for various parts of Deluge to use.""" import os +import subprocess import pkg_resources import xdg, xdg.BaseDirectory @@ -146,7 +147,7 @@ def open_file(path): if windows_check(): os.startfile("'%s'" % path) else: - os.popen("xdg-open '%s'" % path) + subprocess.Popen(["xdg-open", "%s" % path]) def open_url_in_browser(url): """Opens link in the desktop's default browser""" diff --git a/deluge/ui/gtkui/connectionmanager.py b/deluge/ui/gtkui/connectionmanager.py index 70ab8ebc9..e751841f7 100644 --- a/deluge/ui/gtkui/connectionmanager.py +++ b/deluge/ui/gtkui/connectionmanager.py @@ -36,6 +36,7 @@ import pkg_resources import gobject import socket import os +import subprocess import time import threading @@ -127,7 +128,7 @@ class ConnectionManager(component.Component): if deluge.common.windows_check(): win32api.WinExec("deluged -p 58846") else: - os.popen("deluged -p 58846") + subprocess.Popen(["deluged", "-p 58846"]) time.sleep(0.1) # We need to wait for the host to start before connecting while not self.test_online_status(uri): @@ -162,7 +163,7 @@ class ConnectionManager(component.Component): if deluge.common.windows_check(): win32api.WinExec("deluged -p %s" % port) else: - os.popen("deluged -p %s" % port) + subprocess.Popen(["deluged", "-p %s" % port]) # We need to wait for the host to start before connecting while not self.test_online_status(uri): time.sleep(0.01) @@ -437,7 +438,7 @@ class ConnectionManager(component.Component): if deluge.common.windows_check(): win32api.WinExec("deluged -p %s" % port) else: - os.popen("deluged -p %s" % port) + subprocess.Popen(["xdg-open", "-p %s" % port]) def on_button_close_clicked(self, widget): log.debug("on_button_close_clicked") diff --git a/deluge/ui/webui/utils.py b/deluge/ui/webui/utils.py index 0a2096948..71bd3bff1 100644 --- a/deluge/ui/webui/utils.py +++ b/deluge/ui/webui/utils.py @@ -31,6 +31,7 @@ # statement from all source files in the program, then also delete it here. import os +import subprocess import traceback import random from operator import attrgetter @@ -211,7 +212,7 @@ def daemon_start_localhost(port): port = str(port) log.info("Starting localhost:%s daemon..", port) # Spawn a local daemon - os.popen("deluged -p %s" % port) + subprocess.Popen(["deluged", "-p %s" % port]) def daemon_connect(uri): if config.get('daemon') <> uri: