From 2b06abea0836c3e6b566e06bcd3a4a74a40897be 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 5a180aee..2cc7be18 100755 --- a/jrnl.py +++ b/jrnl.py @@ -396,12 +396,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: