From 757eb3a2249ca2aa7b0cd627c9ea884a2d9b1eac Mon Sep 17 00:00:00 2001 From: Aaron Bentley Date: Tue, 17 May 2005 13:29:15 +0000 Subject: [PATCH] Fixed bug handing missing $EDITOR --- .../values | 35 +++++++++++++++++++ .../values | 35 +++++++++++++++++++ becommands/comment.py | 6 +++- libbe/utility.py | 8 +++-- 4 files changed, 80 insertions(+), 4 deletions(-) create mode 100644 .be/bugs/7bfc591e-584a-476e-8e11-b548f1afcaa6/values create mode 100644 .be/bugs/ecc91b94-7f3f-44a7-af58-03191d327a7f/values diff --git a/.be/bugs/7bfc591e-584a-476e-8e11-b548f1afcaa6/values b/.be/bugs/7bfc591e-584a-476e-8e11-b548f1afcaa6/values new file mode 100644 index 0000000..974ca50 --- /dev/null +++ b/.be/bugs/7bfc591e-584a-476e-8e11-b548f1afcaa6/values @@ -0,0 +1,35 @@ + + + +creator=abentley + + + + + + +severity=minor + + + + + + +status=open + + + + + + +summary=no tests for --help, -h, help, etc. + + + + + + +time=Tue, 17 May 2005 13:27:18 +0000 + + + diff --git a/.be/bugs/ecc91b94-7f3f-44a7-af58-03191d327a7f/values b/.be/bugs/ecc91b94-7f3f-44a7-af58-03191d327a7f/values new file mode 100644 index 0000000..6faca58 --- /dev/null +++ b/.be/bugs/ecc91b94-7f3f-44a7-af58-03191d327a7f/values @@ -0,0 +1,35 @@ + + + +creator=abentley + + + + + + +severity=minor + + + + + + +status=open + + + + + + +summary=no tests for missing + + + + + + +time=Tue, 17 May 2005 13:27:33 +0000 + + + diff --git a/becommands/comment.py b/becommands/comment.py index 0207a6c..6a7998c 100644 --- a/becommands/comment.py +++ b/becommands/comment.py @@ -44,7 +44,11 @@ def execute(args): raise cmdutil.UsageError() bug = cmdutil.get_bug(args[0]) if len(args) == 1: - body = utility.editor_string() + try: + body = utility.editor_string() + except utility.CantFindEditor: + raise cmdutil.UserError( + "No comment supplied, and EDITOR not specified.") if body is None: raise cmdutil.UserError("No comment entered.") else: diff --git a/libbe/utility.py b/libbe/utility.py index 5a5cb40..a31d5d8 100644 --- a/libbe/utility.py +++ b/libbe/utility.py @@ -94,14 +94,16 @@ def str_to_time(str_time): def handy_time(time_val): return time.strftime("%a, %d %b %Y %H:%M", time.localtime(time_val)) +class CantFindEditor(Exception): + def __init__(self): + Exception.__init__(self, "Can't find editor to get string from") + def editor_string(): """Invokes the editor, and returns the user_produced text as a string""" try: editor = os.environ["EDITOR"] except KeyError: - raise cmdutil.UserError( - "No comment supplied, and EDITOR not specified.") - + raise CantFindEditor() fhandle, fname = tempfile.mkstemp() try: os.close(fhandle) -- 2.26.2