The MHonArc archiver must set stdin=PIPE when calling the subprocess. Given
[mailman.git] / src / mailman / archiving / tests / fake_mhonarc.py
blob12e60337f71e5fe4bac06526698828c2508888f4
1 # Copyright (C) 2015 by the Free Software Foundation, Inc.
3 # This file is part of GNU Mailman.
5 # GNU Mailman is free software: you can redistribute it and/or modify it under
6 # the terms of the GNU General Public License as published by the Free
7 # Software Foundation, either version 3 of the License, or (at your option)
8 # any later version.
10 # GNU Mailman is distributed in the hope that it will be useful, but WITHOUT
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 # more details.
15 # You should have received a copy of the GNU General Public License along with
16 # GNU Mailman. If not, see <http://www.gnu.org/licenses/>.
18 """A fake MHonArc process that reads stdin and writes stdout."""
20 import sys
22 from email import message_from_string
25 def main():
26 text = sys.stdin.read()
27 msg = message_from_string(text)
28 output_file = sys.argv[1]
29 with open(output_file, 'w', encoding='utf-8') as fp:
30 print(msg['message-id'], file=fp)
31 print(msg['message-id-hash'], file=fp)
34 if __name__ == '__main__':
35 main()