From 5a8662ae03bb8d590e017a876f739f6187613fd1 Mon Sep 17 00:00:00 2001 From: Marcos Pinto Date: Thu, 10 Jul 2008 04:19:22 +0000 Subject: [PATCH] fix windows launching of daemon --- deluge/main.py | 8 -------- deluge/ui/gtkui/connectionmanager.py | 22 +++++++++++++++++----- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/deluge/main.py b/deluge/main.py index 9e6591928..ae4f27bc0 100644 --- a/deluge/main.py +++ b/deluge/main.py @@ -124,14 +124,6 @@ def start_daemon(): else: os._exit(0) - if deluge.common.windows_check() and not options.donot: - port = 58846 - if options.port: - port = options.port - import subprocess - subprocess.Popen(["deluged", "-p %s" % port]) - os._exit(0) - from deluge.core.daemon import Daemon Daemon(options, args) diff --git a/deluge/ui/gtkui/connectionmanager.py b/deluge/ui/gtkui/connectionmanager.py index ac8be1b3f..70ab8ebc9 100644 --- a/deluge/ui/gtkui/connectionmanager.py +++ b/deluge/ui/gtkui/connectionmanager.py @@ -36,7 +36,6 @@ import pkg_resources import gobject import socket import os -import subprocess import time import threading @@ -60,6 +59,10 @@ HOSTLIST_STATUS = [ "Online", "Connected" ] + +if deluge.common.windows_check(): + import win32api + class ConnectionManager(component.Component): def __init__(self): component.Component.__init__(self, "ConnectionManager") @@ -121,7 +124,10 @@ class ConnectionManager(component.Component): # If classic mode is set, we just start up a localhost daemon and connect to it if self.gtkui_config["classic_mode"]: uri = "http://localhost:58846" - subprocess.Popen(["deluged", "-p 58846"]) + if deluge.common.windows_check(): + win32api.WinExec("deluged -p 58846") + else: + os.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): @@ -153,7 +159,10 @@ class ConnectionManager(component.Component): port = uri[7:].split(":")[1] # First add it to the list self.add_host("localhost", port) - subprocess.Popen(["deluged", "-p %s" % port]) + if deluge.common.windows_check(): + win32api.WinExec("deluged -p %s" % port) + else: + os.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) @@ -425,8 +434,11 @@ class ConnectionManager(component.Component): port = str(port) log.info("Starting localhost:%s daemon..", port) # Spawn a local daemon - subprocess.Popen(["deluged", "-p %s" % port]) - + if deluge.common.windows_check(): + win32api.WinExec("deluged -p %s" % port) + else: + os.popen("deluged -p %s" % port) + def on_button_close_clicked(self, widget): log.debug("on_button_close_clicked") self.hide()