blob: e097ebf97674fcf4dbb01d6a84aac452f56812f0 (
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
55
56
57
58
59
60
61
62
63
64
|
===================
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.
XXX Test the interactive operation of qfile
Pretty printing
===============
By default, the ``qfile`` command pretty prints the contents of a queue pickle
file to standard output.
::
>>> from mailman.commands.cli_qfile import QFile
>>> command = QFile()
>>> class FakeArgs:
... interactive = False
... doprint = True
... qfile = []
Let's say Mailman shunted a message file.
::
>>> msg = message_from_string("""\
... From: aperson@example.com
... To: test@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')
>>> FakeArgs.qfile = [qfile]
>>> command.process(FakeArgs)
[----- start pickle -----]
<----- start object 1 ----->
From: aperson@example.com
To: test@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.
>>> FakeArgs.doprint = False
>>> command.process(FakeArgs)
|