From 7280465cd5c1ec7b2b53e43d69e696909e624d10 Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Wed, 25 Jun 2008 04:37:43 +0000 Subject: [PATCH] Some windows stuff --- deluge/main.py | 14 +++++++++++++- deluge/ui/gtkui/gtkui.py | 10 ++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/deluge/main.py b/deluge/main.py index b01141793..336f551d2 100644 --- a/deluge/main.py +++ b/deluge/main.py @@ -53,10 +53,22 @@ def start_ui(): help="The UI that you wish to launch", action="store", type="str") parser.add_option("-c", "--config", dest="config", help="Set the config location", action="store", type="str") - + parser.add_option("-l", "--logfile", dest="logfile", + help="Output to designated logfile instead of stdout", action="store", type="str") + # Get the options and args from the OptionParser (options, args) = parser.parse_args() + if deluge.common.windows_check(): + if options.config: + logfile = os.path.join(options.config, "deluge.log") + else: + logfile = deluge.common.get_config_dir("deluge.log") + + sys.stdout = open(logfile, "wb") + sys.stderr = stdout + sys.stdin = None + from deluge.log import LOG as log version = deluge.common.get_version() diff --git a/deluge/ui/gtkui/gtkui.py b/deluge/ui/gtkui/gtkui.py index 8d6680553..575ecfeef 100644 --- a/deluge/ui/gtkui/gtkui.py +++ b/deluge/ui/gtkui/gtkui.py @@ -129,6 +129,16 @@ class GtkUI: signal.signal(signal.SIGINT, self.shutdown) signal.signal(signal.SIGTERM, self.shutdown) + if deluge.common.windows_check(): + from win32api import SetConsoleCtrlHandler + from win32con import CTRL_CLOSE_EVENT + result = 0 + def win_handler(self, ctrl_type): + if ctrl_type == CTRL_CLOSE_EVENT: + self.shutdown() + return 1 + SetConsoleCtrlHandler(win_handler) + # Make sure gtkui.conf has at least the defaults set self.config = deluge.configmanager.ConfigManager("gtkui.conf", DEFAULT_PREFS)