[gevice] Fixed bug #583599



commit 84d2d75a457a3766998548535efe56e4ddcfbd7a
Author: Alejandro Valdes Jimenez <avaldes gnome org>
Date:   Thu Nov 12 16:49:03 2009 -0300

    Fixed bug #583599

 ChangeLog       |    6 +++++
 src/Makefile.am |    3 +-
 src/gevice.py   |   63 ++++++++++++++++++++++++++++++++++++++++++++++++++----
 3 files changed, 66 insertions(+), 6 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index ebdacd0..4a0307c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-11-12  Alejandro Valdes Jimenez  <avaldes gnome org>
+
+	* src/Makefile.am:
+	* src/gevice.py:
+	Fixed bug #583599
+
 2009-08-15  Alejandro Valdes Jimenez  <avaldes gnome org>
 
 	* src/geviceexport.py: modify SQL.
diff --git a/src/Makefile.am b/src/Makefile.am
index 51edcee..fa86b25 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -17,7 +17,8 @@ app_PYTHON = \
 	gevicevte.py \
 	gevicedatabase.py \
 	geviceexport.py \
-	gevicemaintainer.py 
+	gevicemaintainer.py \
+	geviceping.py
 
 nodist_app_PYTHON = config.py
 
diff --git a/src/gevice.py b/src/gevice.py
index ad159d6..be0f110 100755
--- a/src/gevice.py
+++ b/src/gevice.py
@@ -27,6 +27,7 @@ import gnome
 import gtk.glade
 import psycopg2
 import gobject
+import pynotify
 
 import config
 import gevicefind
@@ -38,6 +39,7 @@ import gevicemodel
 import gevicedatabase
 import geviceexport
 import gevicemaintainer
+import geviceping
 
 import gettext
 gettext.textdomain(config.PACKAGE)
@@ -85,6 +87,8 @@ UI = '''<ui>
       <menuitem action="Connect"/>
       <menuitem action="Expand"/>
       <menuitem action="Decrease"/>
+      <separator/>
+      <menuitem action="Monitoring"/>
     </menu>
     <menu action="HelpMenu">
       <menuitem action="About"/>
@@ -122,6 +126,14 @@ class Gevice:
         self.connected_to_database = False
         self.context_id = None
         self.modelusers = gtk.ListStore(gobject.TYPE_STRING)
+        
+        self.statusicon = gtk.StatusIcon()
+        self.statusicon.set_from_stock(gtk.STOCK_DIALOG_WARNING)
+        self.statusicon.set_tooltip("Esta es una advertencia")
+        self.statusicon.set_visible(False)
+        self.statusicon.set_blinking(True)        
+        self.statusicon.connect ("activate",self.on_statusicon_activate)
+        self.msgmonitor = ""
 
         # get model for devices
         self.gmodel = gevicemodel.GeviceModel(self)
@@ -192,8 +204,9 @@ class Gevice:
 
         self.actiongroup_window.add_toggle_actions([
             ('Tree', None, _('Tree'),None, _('Show tree'), self.on_toggle_tree, True),
-            ('Terminal', None, _('Terminal'),None, _('Show terminal'), self.on_toggle_terminal, True)
-            ])
+            ('Terminal', None, _('Terminal'),None, _('Show terminal'), self.on_toggle_terminal, True),
+            ('Monitoring', None, _('Monitoring'),None, _('Activate monitoring'), self.on_toggle_monitoring, False)
+	])
 
         self.actiongroup_window.add_radio_actions([
             ('ssh', None, _('ssh'),None, _('Use ssh protocol'), 0),
@@ -290,6 +303,17 @@ class Gevice:
         self.window_main.show_all()
         return
 
+    def on_statusicon_activate(gevice, statusicon):
+        statusicon.set_visible(False)
+        dialog = gtk.Dialog(config.PACKAGE,None,gtk.DIALOG_DESTROY_WITH_PARENT,(gtk.STOCK_OK,gtk.RESPONSE_ACCEPT))
+        dialog.vbox.set_spacing(15)
+        dialog.vbox.pack_start(gtk.Label(gevice.msgmonitor))
+        dialog.show_all()
+        response = dialog.run ()
+        dialog.destroy()
+        print gevice.msgmonitor
+        
+
     def set_listusers_on_combobox (self):
         self.modelusers.clear()
         for user in self.gpref.listusers:
@@ -588,6 +612,34 @@ class Gevice:
         else:
             gevice.vboxterminal.hide ()
 
+    def on_toggle_monitoring (gevice,action):
+        if (action.get_active() == True):
+            pinglist = []
+            gevice.gmodel.treestore.foreach(gevice.get_ips,pinglist)
+            
+            report = ("No response","Partial Response","Alive")
+            
+            gevice.msgmonitor = ""
+            for pingle in pinglist:
+                pingle.join()
+                gevice.msgmonitor = gevice.msgmonitor +  _("Status from: ") + str(pingle.ip) + _(" is ") + report[pingle.status] + " \n"
+            
+            gevice.statusicon.set_visible(True)
+            ###n = pynotify.Notification("EL2009",msg ,uri)
+            ###n = pynotify.Notification(config.PACKAGE,msg)
+            ###n.set_urgency(pynotify.URGENCY_CRITICAL)
+            ###n.set_timeout(1000) #10000 -> 10 seg
+            ###n.show()
+        else:
+            # disable monitoring
+            pass
+
+    def get_ips(self,model,path,iter,pinglist):
+        data = model.get(iter,config.COLUMN_NAME_DEV,config.COLUMN_IP_DEV,config.COLUMN_SERIAL_DEV)
+        current = geviceping.GevicePing(data[1])
+        pinglist.append(current)
+        current.start()
+
     def create_about_dialog (self):
         authors = ('Alejandro Valdes Jimenez [avaldes gnome org]','')
         translator_credits = ('Alejandro Valdes Jimenez [avaldes gnome org]')
@@ -628,6 +680,7 @@ class Gevice:
     
 
 if __name__ == "__main__":
-	gnome.init(config.PACKAGE,config.VERSION)	
-	gevice = Gevice()	
-	gevice.main()
+    gnome.init(config.PACKAGE,config.VERSION)
+    pynotify.init(config.PACKAGE)
+    gevice = Gevice()
+    gevice.main()



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