File silent-editor-check.patch of Package python-cmd2

https://bitbucket.org/catherinedevlin/cmd2/issue/1/silent-editor-check

From 590a9dfd32fa729d05d474ac81bccc7eebf6b9bd Mon Sep 17 00:00:00 2001
From: Martin Magr <mmagr@redhat.com>
Date: Tue, 29 Jan 2013 13:54:15 +0100
Subject: [PATCH] Added vi as possible editor and made editor check silent.

Fixes: rhbz#889774
---
 cmd2.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/cmd2.py b/cmd2.py
index ba7fab8..85ad9c8 100755
--- a/cmd2.py
+++ b/cmd2.py
@@ -420,9 +420,14 @@ class Cmd(cmd.Cmd):
         if sys.platform[:3] == 'win':
             editor = 'notepad'
         else:
-            for editor in ['gedit', 'kate', 'vim', 'emacs', 'nano', 'pico']:
-                if subprocess.Popen(['which', editor], stdout=subprocess.PIPE).communicate()[0]:
+            for editor in ['gedit', 'kate', 'vim', 'vi', 'emacs', 'nano', 'pico']:
+                _proc = subprocess.Popen(['which', editor],
+                                         stdout=subprocess.PIPE,
+                                         stderr=subprocess.STDOUT)
+                if _proc.communicate()[0]:
                     break
+            else:
+                editor = None
 
     colorcodes =    {'bold':{True:'\x1b[1m',False:'\x1b[22m'},
                   'cyan':{True:'\x1b[36m',False:'\x1b[39m'},
-- 
1.7.11.7

openSUSE Build Service is sponsored by