From 1b8ad23a198bc92148e9ab5c3e514befa839a71a Mon Sep 17 00:00:00 2001 From: Stephan Gabler Date: Thu, 26 Apr 2012 09:58:46 +0200 Subject: [PATCH] don't crash if editor file was not saved (treat it as read mode) close #12 --- jrnl.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/jrnl.py b/jrnl.py index fc7216a7..e13d4b95 100755 --- a/jrnl.py +++ b/jrnl.py @@ -404,12 +404,16 @@ if __name__ == "__main__": if config['editor']: tmpfile = os.path.join(tempfile.gettempdir(), "jrnl") subprocess.call(config['editor'].split() + [tmpfile]) - with open(tmpfile) as f: - raw = f.read() - os.remove(tmpfile) - + if os.path.exists(tmpfile): + with open(tmpfile) as f: + raw = f.read() + os.remove(tmpfile) + else: + print('nothing saved to file') + raw = '' else: raw = raw_input("Compose Entry: ") + if raw: args.text = [raw] else: