Coverage for distro_tracker/mail/management/commands/tracker_dispatch.py: 100%
16 statements
« prev ^ index » next coverage.py v6.5.0, created at 2025-01-12 09:15 +0000
« prev ^ index » next coverage.py v6.5.0, created at 2025-01-12 09:15 +0000
1# Copyright 2013 The Distro Tracker Developers
2# See the COPYRIGHT file at the top-level directory of this distribution and
3# at https://deb.li/DTAuthors
4#
5# This file is part of Distro Tracker. It is subject to the license terms
6# in the LICENSE file found in the top-level directory of this
7# distribution and at https://deb.li/DTLicense. No part of Distro Tracker,
8# including this file, may be copied, modified, propagated, or distributed
9# except according to the terms contained in the LICENSE file.
10"""
11Implements the management command which invokes the dispatch functionality.
12"""
13import io
14import sys
16from django.core.management.base import BaseCommand
18from distro_tracker.core.utils.email_messages import message_from_bytes
19from distro_tracker.mail.processor import MailProcessor
22class Command(BaseCommand):
23 """
24 A Django management command used to invoke the dispatch functionality.
26 The received message is expected as input on stdin.
27 """
28 input_file = sys.stdin
30 def handle(self, *args, **kwargs):
31 # Get the binary buffer behind the text one
32 try:
33 self.input_file = self.input_file.detach()
34 except io.UnsupportedOperation:
35 pass
36 msg = message_from_bytes(self.input_file.read())
37 handler = MailProcessor(msg)
38 handler.process()