Some windows stuff

This commit is contained in:
Andrew Resch 2008-06-25 04:37:43 +00:00
parent 9648d2c6b0
commit 7280465cd5
2 changed files with 23 additions and 1 deletions

View File

@ -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()

View File

@ -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)