summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--alot/message.py12
-rw-r--r--alot/widgets.py12
2 files changed, 18 insertions, 6 deletions
diff --git a/alot/message.py b/alot/message.py
index 553755c9..311c784a 100644
--- a/alot/message.py
+++ b/alot/message.py
@@ -67,10 +67,16 @@ class Message(object):
def get_email(self):
"""returns :class:`email.Message` for this message"""
+ path = self.get_filename()
+ warning = "Subject: Caution!\n"\
+ "Message file is no longer accessible:\n%s" % path
if not self._email:
- f_mail = open(self.get_filename())
- self._email = email.message_from_file(f_mail)
- f_mail.close()
+ try:
+ f_mail = open(path)
+ self._email = email.message_from_file(f_mail)
+ f_mail.close()
+ except IOError:
+ self._email = email.message_from_string(warning)
return self._email
def get_date(self):
diff --git a/alot/widgets.py b/alot/widgets.py
index 6f5ed0e5..7a8e7479 100644
--- a/alot/widgets.py
+++ b/alot/widgets.py
@@ -349,9 +349,12 @@ class MessageWidget(urwid.WidgetWrap):
hw = self._get_header_widget()
aw = self._get_attachment_widget()
bw = self._get_body_widget()
- self.displayed_list = [self.sumline, hw, bw]
+ self.displayed_list = [self.sumline]
+ if hw:
+ self.displayed_list.append(hw)
if aw:
- self.displayed_list.insert(2, aw)
+ self.displayed_list.append(aw)
+ self.displayed_list.append(bw)
else:
self.displayed_list = [self.sumline]
self.pile = urwid.Pile(self.displayed_list)
@@ -381,10 +384,13 @@ class MessageWidget(urwid.WidgetWrap):
def _get_header_widget(self, force_update=False):
"""creates/returns the widget that displays the mail header"""
+ if not self.displayed_headers:
+ return None
if not self.headerw or force_update:
mail = self.message.get_email()
- #build lines
+ # normalize values if only filtered list is shown
norm = not (self.displayed_headers == self.all_headers)
+ #build lines
lines = []
for k in self.displayed_headers:
v = mail.get(k)