diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-11-28 22:11:23 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-11-28 22:11:23 +0100 |
commit | 47f865223466ed620a769023b128870f4517d044 (patch) | |
tree | 29e156cd0be586eb2d3aa69a62ff12a76f59fbca | |
parent | Replace login system with flask-login. (diff) | |
download | mu4web-47f865223466ed620a769023b128870f4517d044.tar.gz mu4web-47f865223466ed620a769023b128870f4517d044.tar.xz |
Fix search page.
-rw-r--r-- | main.py | 5 | ||||
-rw-r--r-- | mu.py | 17 |
2 files changed, 16 insertions, 6 deletions
@@ -4,6 +4,7 @@ from urllib.parse import urlencode import password from password import Passwords import os +from datetime import datetime from flask_login import ( LoginManager, login_required, @@ -79,6 +80,10 @@ style: HTML = lambda: """ margin: 0; } + tr:nth-child(2n) { + background-color: lightblue; + } + """ @@ -53,6 +53,9 @@ class MuError(Exception): def __repr__(self): return f'MuError({self.returncode}, "{self.msg}")' + def __str__(self): + return repr(self) + Sortfield = Union[Literal['cc'], Literal['c'], @@ -98,14 +101,16 @@ def mu_search(query, sortfield: Optional[Sortfield] = 'subject', reverse: bool = raise ValueError('Query required for mu_search') cmdline = ['mu', 'find', '--format=xml', - query, - '--sortfield', sortfield] + query] + if sortfield: + cmdline.extend(['--sortfield', sortfield]) if reverse: cmdline.append('--reverse') - cmd = subprocess.Popen(cmdline, stdout=subprocess.PIPE) - dom = xml.dom.minidom.parse(cmd.stdout) - if returncode := cmd.wait(): - raise MuError(returncode) + print(cmdline) + cmd = subprocess.run(cmdline, capture_output=True) + if cmd.returncode != 0: + raise MuError(cmd.returncode) + dom = xml.dom.minidom.parseString(cmd.stdout.decode('UTF-8')) message_list = [] messages = dom.childNodes[0] |