~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/mail_client.py

  • Committer: Alexander Belchenko
  • Date: 2008-02-27 18:52:57 UTC
  • mto: This revision was merged to the branch mainline in revision 3267.
  • Revision ID: bialix@ukr.net-20080227185257-5gor8qkadhw0ljvq
mail_client.py: provide new private method ExternalMailClient._get_compose_8bit_commandline to make bug #139318 testable (as Aaron requested).

Show diffs side-by-side

added added

removed removed

Lines of Context:
144
144
            the attachment type.
145
145
        """
146
146
        for name in self._get_client_commands():
147
 
            cmdline = [name]
148
 
            if sys.platform == 'win32':
149
 
                user_encoding = osutils.get_user_encoding()
150
 
                if to:
151
 
                    to = to.encode(user_encoding, 'replace')
152
 
                if subject:
153
 
                    subject = subject.encode(user_encoding, 'replace')
154
 
            cmdline.extend(self._get_compose_commandline(to, subject,
155
 
                                                         attach_path))
 
147
            cmdline = _get_compose_8bit_commandline(name, to, subject,
 
148
                attach_path)
156
149
            try:
157
150
                subprocess.call(cmdline)
158
151
            except OSError, e:
173
166
        """
174
167
        raise NotImplementedError
175
168
 
 
169
    def _get_compose_8bit_commandline(self, name, to, subject, attach_path):
 
170
        """Wrapper around _get_compose_commandline()
 
171
        to ensure that resulting command line is plain string.
 
172
 
 
173
        :param  name:   name of external mail client (first argument).
 
174
        """
 
175
        cmdline = [name]
 
176
        user_encoding = osutils.get_user_encoding()
 
177
        if to:
 
178
            to = to.encode(user_encoding, 'replace')
 
179
        if subject:
 
180
            subject = subject.encode(user_encoding, 'replace')
 
181
        cmdline.extend(self._get_compose_commandline(to, subject,
 
182
                                                     attach_path))
 
183
        return cmdline
 
184
 
176
185
 
177
186
class Evolution(ExternalMailClient):
178
187
    """Evolution mail client."""