summaryrefslogtreecommitdiff
path: root/src/mailman/commands/docs/qfile.rst
blob: 4b0d887b77f75a5a435ae40a9ff61b6ab65c4b93 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
===================
Dumping queue files
===================

The ``qfile`` command dumps the contents of a queue pickle file.  This is
especially useful when you have shunt files you want to inspect.


Pretty printing
===============

By default, the ``qfile`` command pretty prints the contents of a queue pickle
file to standard output.
::

    >>> command = cli('mailman.commands.cli_qfile.qfile')

Let's say Mailman shunted a message file.
::

    >>> msg = message_from_string("""\
    ... From: aperson@example.com
    ... To: ant@example.com
    ... Subject: Uh oh
    ...
    ... I borkeded Mailman.
    ... """)

    >>> shuntq = config.switchboards['shunt']
    >>> basename = shuntq.enqueue(msg, foo=7, bar='baz', bad='yes')

Once we've figured out the file name of the shunted message, we can print it.
::

    >>> from os.path import join
    >>> qfile = join(shuntq.queue_directory, basename + '.pck')

    >>> command('mailman qfile ' + qfile)
    [----- start pickle -----]
    <----- start object 1 ----->
    From: aperson@example.com
    To: ant@example.com
    Subject: Uh oh
    <BLANKLINE>
    I borkeded Mailman.
    <BLANKLINE>
    <----- start object 2 ----->
    {'_parsemsg': False, 'bad': 'yes', 'bar': 'baz', 'foo': 7, 'version': 3}
    [----- end pickle -----]

Maybe we don't want to print the contents of the file though, in case we want
to enter the interactive prompt.

    >>> command('mailman qfile --no-print ' + qfile)