[python-cmd2] suppress warnings about missing editors when $EDITOR not set

Pádraig Brady pbrady at fedoraproject.org
Tue Jul 30 15:44:15 UTC 2013


commit aa39f527f90ab05ad185b9e03971cb4e014e4e68
Author: Pádraig Brady <P at draigBrady.com>
Date:   Tue Jul 30 16:42:34 2013 +0100

    suppress warnings about missing editors when $EDITOR not set

 python-cmd2.spec          |    7 ++++++-
 silent-editor-check.patch |   36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+), 1 deletions(-)
---
diff --git a/python-cmd2.spec b/python-cmd2.spec
index 2d3b7a3..5734c03 100644
--- a/python-cmd2.spec
+++ b/python-cmd2.spec
@@ -6,13 +6,14 @@
 
 Name:             python-cmd2
 Version:          0.6.4
-Release:          5%{?dist}
+Release:          7%{?dist}
 Summary:          Extra features for standard library's cmd module
 
 Group:            Development/Libraries
 License:          MIT
 URL:              http://pypi.python.org/pypi/cmd2
 Source0:          http://pypi.python.org/packages/source/c/%{modname}/%{modname}-%{version}.tar.gz
+Patch0:           silent-editor-check.patch
 
 BuildArch:        noarch
 
@@ -86,6 +87,7 @@ See docs at http://packages.python.org/cmd2/
 
 %prep
 %setup -q -n %{modname}-%{version}
+%patch0 -p1
 
 chmod -x README.txt
 dos2unix README.txt
@@ -134,6 +136,9 @@ popd
 
 
 %changelog
+* Tue Jul 30 2013 Pádraig Brady <pbrady at redhat.com> - 0.6.4-7
+- Suppress warnings about missing editors when $EDITOR not set
+
 * Thu Feb 14 2013 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 0.6.4-5
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild
 
diff --git a/silent-editor-check.patch b/silent-editor-check.patch
new file mode 100644
index 0000000..eb2f94e
--- /dev/null
+++ b/silent-editor-check.patch
@@ -0,0 +1,36 @@
+https://bitbucket.org/catherinedevlin/cmd2/issue/1/silent-editor-check
+
+From 590a9dfd32fa729d05d474ac81bccc7eebf6b9bd Mon Sep 17 00:00:00 2001
+From: Martin Magr <mmagr at 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
+


More information about the scm-commits mailing list