Author: andar

Revision: 6098

Log:
        Fix #1128 Show an error dialog when unable to start a 'deluged' process

Diff:
Modified: branches/1.2_RC/ChangeLog
===================================================================
--- branches/1.2_RC/ChangeLog   2010-01-17 22:18:45 UTC (rev 6097)
+++ branches/1.2_RC/ChangeLog   2010-01-18 02:36:03 UTC (rev 6098)
@@ -1,3 +1,7 @@
+=== Deluge 1.2.1 ===
+==== GtkUI ====
+       * Fix #1128 Show an error dialog when unable to start a 'deluged' 
process
+       
 === Deluge 1.2.0 - "Bursting like an infected kidney" (10 January 2010) ===
 ==== Core ====
        * Fix file renaming

Modified: branches/1.2_RC/deluge/ui/client.py
===================================================================
--- branches/1.2_RC/deluge/ui/client.py 2010-01-17 22:18:45 UTC (rev 6097)
+++ branches/1.2_RC/deluge/ui/client.py 2010-01-18 02:36:03 UTC (rev 6098)
@@ -535,10 +535,15 @@
         """
         Starts a daemon process.
 
-        :param port: int, the port for the daemon to listen on
-        :param config: str, the path to the current config folder
+        :param port: the port for the daemon to listen on
+        :type port: int
+        :param config: the path to the current config folder
+        :type config: str
         :returns: True if started, False if not
+        :rtype: bool
 
+        :raises OSError: received from subprocess.call()
+        
         """
         try:
             if deluge.common.windows_check():
@@ -547,6 +552,9 @@
                 subprocess.call(["nohup", "deluged", "--port=%s" % port, 
"--config=%s" % config])
             else:
                 subprocess.call(["deluged", "--port=%s" % port, "--config=%s" 
% config])
+        except OSError, e:
+            log.exception(e)
+            raise e
         except Exception, e:
             log.error("Unable to start daemon!")
             log.exception(e)

Modified: branches/1.2_RC/deluge/ui/gtkui/connectionmanager.py
===================================================================
--- branches/1.2_RC/deluge/ui/gtkui/connectionmanager.py        2010-01-17 
22:18:45 UTC (rev 6097)
+++ branches/1.2_RC/deluge/ui/gtkui/connectionmanager.py        2010-01-18 
02:36:03 UTC (rev 6098)
@@ -49,6 +49,7 @@
 import deluge.ui.common
 from deluge.configmanager import ConfigManager
 from deluge.log import LOG as log
+import dialogs
 
 DEFAULT_HOST = "127.0.0.1"
 DEFAULT_PORT = 58846
@@ -396,6 +397,30 @@
         self.glade.get_widget("label_startdaemon").set_use_underline(
             True)
 
+    def start_daemon(self, port, config):
+        """
+        Attempts to start a daemon process and will show an ErrorDialog if 
unable
+        to.
+        """
+        try:
+            return client.start_daemon(port, config)
+        except OSError, e:
+            if e.errno == 2:
+                dialogs.ErrorDialog(
+                    _("Unable to start daemon!"),
+                    _("Deluge cannot find the 'deluged' executable, it is 
likely \
+that you forgot to install the deluged package or it's not in your 
PATH.")).run()
+            else:
+                raise e
+        except Exception, e:
+            import traceback
+            import sys
+            tb = sys.exc_info()
+            dialogs.ErrorDialog(
+                _("Unable to start daemon!"),
+                _("Please examine the details for more information."),
+                details=traceback.format_exc(tb[2])).run()
+
     # Signal handlers
     def __on_connected(self, connector, host_id):
         if self.gtkui_config["autoconnect"]:
@@ -423,7 +448,7 @@
         if status == _("Offline") and 
self.glade.get_widget("chk_autostart").get_active() and\
             host in ("127.0.0.1", "localhost"):
             # We need to start this localhost
-            client.start_daemon(port, deluge.configmanager.get_config_dir())
+            self.start_daemon(port, deluge.configmanager.get_config_dir())
 
             def on_connect_fail(result, try_counter):
                 log.error("Connection to host failed..")
@@ -504,7 +529,7 @@
             # There is nothing in the list, so lets create a localhost entry
             self.add_host(DEFAULT_HOST, DEFAULT_PORT)
             # ..and start the daemon.
-            client.start_daemon(DEFAULT_PORT, 
deluge.configmanager.get_config_dir())
+            self.start_daemon(DEFAULT_PORT, 
deluge.configmanager.get_config_dir())
             return
 
         paths = self.hostlist.get_selection().get_selected_rows()[1]
@@ -538,7 +563,7 @@
                 c.connect(host, port, user, password).addCallback(on_connect, 
c)
 
         elif status == _("Offline"):
-            client.start_daemon(port, deluge.configmanager.get_config_dir())
+            self.start_daemon(port, deluge.configmanager.get_config_dir())
             reactor.callLater(2.0, self.__update_list)
 
     def on_button_refresh_clicked(self, widget):

Modified: trunk/deluge/ui/client.py
===================================================================
--- trunk/deluge/ui/client.py   2010-01-17 22:18:45 UTC (rev 6097)
+++ trunk/deluge/ui/client.py   2010-01-18 02:36:03 UTC (rev 6098)
@@ -535,10 +535,15 @@
         """
         Starts a daemon process.
 
-        :param port: int, the port for the daemon to listen on
-        :param config: str, the path to the current config folder
+        :param port: the port for the daemon to listen on
+        :type port: int
+        :param config: the path to the current config folder
+        :type config: str
         :returns: True if started, False if not
+        :rtype: bool
 
+        :raises OSError: received from subprocess.call()
+        
         """
         try:
             if deluge.common.windows_check():
@@ -547,6 +552,9 @@
                 subprocess.call(["nohup", "deluged", "--port=%s" % port, 
"--config=%s" % config])
             else:
                 subprocess.call(["deluged", "--port=%s" % port, "--config=%s" 
% config])
+        except OSError, e:
+            log.exception(e)
+            raise e
         except Exception, e:
             log.error("Unable to start daemon!")
             log.exception(e)

Modified: trunk/deluge/ui/gtkui/connectionmanager.py
===================================================================
--- trunk/deluge/ui/gtkui/connectionmanager.py  2010-01-17 22:18:45 UTC (rev 
6097)
+++ trunk/deluge/ui/gtkui/connectionmanager.py  2010-01-18 02:36:03 UTC (rev 
6098)
@@ -49,6 +49,7 @@
 import deluge.ui.common
 from deluge.configmanager import ConfigManager
 from deluge.log import LOG as log
+import dialogs
 
 DEFAULT_HOST = "127.0.0.1"
 DEFAULT_PORT = 58846
@@ -396,6 +397,30 @@
         self.glade.get_widget("label_startdaemon").set_use_underline(
             True)
 
+    def start_daemon(self, port, config):
+        """
+        Attempts to start a daemon process and will show an ErrorDialog if 
unable
+        to.
+        """
+        try:
+            return client.start_daemon(port, config)
+        except OSError, e:
+            if e.errno == 2:
+                dialogs.ErrorDialog(
+                    _("Unable to start daemon!"),
+                    _("Deluge cannot find the 'deluged' executable, it is 
likely \
+that you forgot to install the deluged package or it's not in your 
PATH.")).run()
+            else:
+                raise e
+        except Exception, e:
+            import traceback
+            import sys
+            tb = sys.exc_info()
+            dialogs.ErrorDialog(
+                _("Unable to start daemon!"),
+                _("Please examine the details for more information."),
+                details=traceback.format_exc(tb[2])).run()
+
     # Signal handlers
     def __on_connected(self, connector, host_id):
         if self.gtkui_config["autoconnect"]:
@@ -423,7 +448,7 @@
         if status == _("Offline") and 
self.glade.get_widget("chk_autostart").get_active() and\
             host in ("127.0.0.1", "localhost"):
             # We need to start this localhost
-            client.start_daemon(port, deluge.configmanager.get_config_dir())
+            self.start_daemon(port, deluge.configmanager.get_config_dir())
 
             def on_connect_fail(result, try_counter):
                 log.error("Connection to host failed..")
@@ -504,7 +529,7 @@
             # There is nothing in the list, so lets create a localhost entry
             self.add_host(DEFAULT_HOST, DEFAULT_PORT)
             # ..and start the daemon.
-            client.start_daemon(DEFAULT_PORT, 
deluge.configmanager.get_config_dir())
+            self.start_daemon(DEFAULT_PORT, 
deluge.configmanager.get_config_dir())
             return
 
         paths = self.hostlist.get_selection().get_selected_rows()[1]
@@ -538,7 +563,7 @@
                 c.connect(host, port, user, password).addCallback(on_connect, 
c)
 
         elif status == _("Offline"):
-            client.start_daemon(port, deluge.configmanager.get_config_dir())
+            self.start_daemon(port, deluge.configmanager.get_config_dir())
             reactor.callLater(2.0, self.__update_list)
 
     def on_button_refresh_clicked(self, widget):


-- 
You received this message because you are subscribed to the Google Groups 
"deluge-commit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/deluge-commit?hl=en.


Reply via email to