← Back to team overview

clicompanion-devs team mailing list archive

[Merge] lp:~bdfhjk/clicompanion/fix-627622 into lp:clicompanion

 

Marek Bardoński has proposed merging lp:~bdfhjk/clicompanion/fix-627622 into lp:clicompanion.

Requested reviews:
  Duane Hinnen (duanedesign)
  CLI Companion Development Team (clicompanion-devs)

For more details, see:
https://code.launchpad.net/~bdfhjk/clicompanion/fix-627622/+merge/311873
-- 
Your team CLI Companion Development Team is requested to review the proposed merge of lp:~bdfhjk/clicompanion/fix-627622 into lp:clicompanion.
=== modified file 'plugins/LocalCommandList.py'
--- plugins/LocalCommandList.py	2016-03-30 09:46:32 +0000
+++ plugins/LocalCommandList.py	2016-11-26 11:02:27 +0000
@@ -27,6 +27,7 @@
 import collections
 import platform
 import shutil
+import subprocess
 
 try:
     import gtk
@@ -159,11 +160,18 @@
         desc = ''.join(model[lst_index][2])
         return cmd, ui, desc
 
+    def check_command(self, cmd):
+        try:
+            output = subprocess.check_output('type '+cmd[0], shell=True)
+        except:
+            self.show_warning_uninstalled_command(cmd)
+
     def add_command(self, cmd='', ui='', desc=''):
         add_cmd_win = AddCommandWindow(cmd, ui, desc)
         new_cmd = add_cmd_win.run()
         if not new_cmd:
             return
+        self.check_command(new_cmd)
         self.cmnds.append(*new_cmd)
         self.sync_cmnds()
 
@@ -178,6 +186,7 @@
             return
         index = self.cmnds.index(cmd, ui, desc)
         del self.cmnds[index]
+        self.check_command(edited_cmd)
         self.cmnds.insert(*edited_cmd, pos=index)
         self.sync_cmnds()
 
@@ -370,6 +379,18 @@
         context.finish(True, True, time)
         self.sync_cmnds()
 
+    def show_warning_uninstalled_command(self, cmd):
+        dlg = gtk.MessageDialog(
+                     None,
+                     gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
+                     gtk.MESSAGE_ERROR,
+                     gtk.BUTTONS_CLOSE,
+                     message_format=_('Warning!'))
+        dlg.format_secondary_text(_('The command you are adding is not installed in the system: ') + cmd[0] + \
+                                  _('\n\nTo install it, use the following command: \n\n apt-get install ') + cmd[0])
+        dlg.run()
+        dlg.destroy()
+
     def main(self):
         try:
             gtk.main()