deskbar-applet r2172 - in branches/gnome-2-22: . deskbar/handlers



Author: sebp
Date: Fri May 23 11:25:18 2008
New Revision: 2172
URL: http://svn.gnome.org/viewvc/deskbar-applet?rev=2172&view=rev

Log:
Use subprocess module instead of os.popen.
Catch OSError when retrieving version (fixes bug #533842)

Modified:
   branches/gnome-2-22/ChangeLog
   branches/gnome-2-22/deskbar/handlers/tomboy.py

Modified: branches/gnome-2-22/deskbar/handlers/tomboy.py
==============================================================================
--- branches/gnome-2-22/deskbar/handlers/tomboy.py	(original)
+++ branches/gnome-2-22/deskbar/handlers/tomboy.py	Fri May 23 11:25:18 2008
@@ -1,4 +1,3 @@
-import os
 import re
 import dbus
 from dbus.mainloop.glib import DBusGMainLoop
@@ -11,6 +10,7 @@
 import gtk
 from gettext import gettext as _
 import logging
+import subprocess
 
 LOGGER = logging.getLogger(__name__)
 
@@ -242,9 +242,14 @@
 # If we use DBus, it will wake up Tomboy even if 
 # this module isn't enabled.
 def get_tomboy_version():
-    command = os.popen("tomboy --version")
-    read = command.read()
-    command.close()
+    try:
+        command = subprocess.Popen("tomboy --version", shell=True,
+                                   stdout=subprocess.PIPE).stdout
+        read = command.read()
+        command.close()
+    except OSError, e:
+        LOGGER.exception(e)
+        return '0.0.0'
     
     line_regexp = re.compile( 'Version (\d+?)\.(\d+?)\.(\d+?)', re.IGNORECASE )
     results_list = line_regexp.findall( read )



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]