From b396b11611be9c828090d1dafedfb3cd3bf092f3 Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Sat, 3 Mar 2012 02:18:13 +0000 Subject: [PATCH] Set process name to match application using setproctitle Using the setproctitle module the process name displayed in top and other places will correctly reflect the binary name. This is an optional dependency --- ChangeLog | 1 + DEPENDS | 1 + deluge/ui/gtkui/gtkui.py | 9 +++++++++ deluge/ui/ui.py | 11 ++++++++++- 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 2c0f8cf21..4f51e5a55 100644 --- a/ChangeLog +++ b/ChangeLog @@ -50,6 +50,7 @@ * #2021: Fix share ratio limit not obeyed for seeded torrents added to session * Add optparse custom version to prevent unnecessary loading of libtorrent * #1554: Fix seeding on share ratio failing for partially selected torrents + * Add proper process title naming in ps, top etc. (Depends: setproctitle) ==== GtkUI ==== * #1918: Fix Drag'n'Drop not working in Windows diff --git a/DEPENDS b/DEPENDS index 2288a6d94..cfb1422b9 100644 --- a/DEPENDS +++ b/DEPENDS @@ -10,6 +10,7 @@ * pyxdg * chardet * geoip-database (optional) + * setproctitle (optional) * libtorrent >= 0.14, or build the included version diff --git a/deluge/ui/gtkui/gtkui.py b/deluge/ui/gtkui/gtkui.py index 9d64340bb..5726eea50 100644 --- a/deluge/ui/gtkui/gtkui.py +++ b/deluge/ui/gtkui/gtkui.py @@ -46,6 +46,12 @@ import logging log = logging.getLogger(__name__) +try: + from setproctitle import setproctitle, getproctitle +except ImportError: + setproctitle = lambda t: None + getproctitle = lambda: None + import deluge.component as component from deluge.ui.client import client from mainwindow import MainWindow @@ -172,6 +178,9 @@ class GtkUI(object): return 1 SetConsoleCtrlHandler(win_handler) + # Set process name again to fix gtk issue + setproctitle(getproctitle()) + # Attempt to register a magnet URI handler with gconf, but do not overwrite # if already set by another program. common.associate_magnet_links(False) diff --git a/deluge/ui/ui.py b/deluge/ui/ui.py index d7ae77589..792f416c2 100644 --- a/deluge/ui/ui.py +++ b/deluge/ui/ui.py @@ -42,6 +42,11 @@ import deluge.common import deluge.configmanager import deluge.log +try: + from setproctitle import setproctitle +except ImportError: + setproctitle = lambda t: None + def version_callback(option, opt_str, value, parser): print os.path.basename(sys.argv[0]) + ": " + deluge.common.get_version() try: @@ -126,10 +131,12 @@ class _UI(object): log.error("There was an error setting the config dir! Exiting..") sys.exit(1) + setproctitle("deluge-%s" % self.__name) + log.info("Deluge ui %s", deluge.common.get_version()) log.debug("options: %s", self.__options) log.debug("args: %s", self.__args) - log.info("Starting ui..") + log.info("Starting %s ui..", self.__name) class UI: def __init__(self, options, args, ui_args): @@ -147,6 +154,8 @@ class UI: else: selected_ui = options.ui + setproctitle("deluge") + config.save() del config