1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 import base64
21 import common
22 import cPickle
23 import cStringIO
24 import MimeWriter
25 import os
26 import posix
27 import qm
28 import quopri
29 import select
30 import signal
31 import string
32 import sys
33 import traceback
34
35
36
37
38
39 if sys.platform[:5] == "linux":
40
41
42 default_shell = ["/bin/bash", "-norc", "-noprofile"]
43 else:
44
45 default_shell = ["/bin/sh"]
46
47
48
49
50
51
53 """An exception raised in response to a signal."""
54
56 """Create a new signal exception.
57
58 'signal_number' -- The signal number."""
59
60
61 message = "Signal %d" % signal_number
62
63 signal_name = get_signal_name(signal_number)
64 if signal_name is not None:
65 message = message + " (%s)" % signal_name
66
67 common.QMException.__init__(self, message)
68
69 self.__signal_number = signal_number
70
71
73 """Return the number of the signal that caused this exception."""
74
75 return self.__signal_number
76
77
78
79
80
81
82
84 """Open a browser window and point it at 'url'.
85
86 The browser is run in a separate, independent process."""
87
88
89 url = string.replace(url, "'", "%27")
90
91 browser = common.rc.Get("browser", "mozilla", "common")
92
93 os.system("%s '%s' &" % (browser, url))
94
95
97 """Return the name for signal 'signal_number'.
98
99 returns -- The signal's name, or 'None'."""
100
101
102
103 for attribute_name in dir(signal):
104 if len(attribute_name) > 3 \
105 and attribute_name[:3] == "SIG" \
106 and getattr(signal, attribute_name) == signal_number:
107 return attribute_name
108
109 return None
110
111
113 """Install a handler to translate a signal into an exception.
114
115 The signal handler raises a 'SignalException' exception in
116 response to a signal."""
117
118 signal.signal(signal_number, _signal_handler)
119
120
122 """Generic signal handler that raises an exception."""
123
124 raise SignalException(signal_number)
125
126
128 """Return the name of this computer."""
129
130 return posix.uname()[1]
131
132
133
134
135
137 """Perform module initialization."""
138
139
140 for s in (signal.SIGALRM,
141 signal.SIGHUP,
142 signal.SIGTERM,
143 signal.SIGUSR1,
144 signal.SIGUSR2):
145 install_signal_handler(s)
146
147 _initialize()
148
149
150
151
152
153
154
155