~xnox/ubuntu-dev-tools/py3k

« back to all changes in this revision

Viewing changes to ubuntutools/requestsync/mail.py

  • Committer: Dimitri John Ledkov
  • Date: 2014-12-19 22:37:04 UTC
  • mfrom: (1421.1.33 ubuntu-dev-tools)
  • Revision ID: dimitri.j.ledkov@intel.com-20141219223704-bi23kp10gcfl6wht
Port ubuntutools module to python3.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
#   Please see the /usr/share/common-licenses/GPL-2 file for the full text
21
21
#   of the GNU General Public License license.
22
22
 
 
23
from __future__ import print_function
 
24
 
23
25
import os
24
26
import re
25
27
import sys
27
29
import socket
28
30
import tempfile
29
31
 
 
32
if sys.version_info[0] >= 3:
 
33
    basestring = str
 
34
    unicode = str    
 
35
 
30
36
from debian.changelog import Changelog, Version
31
37
from distro_info import DebianDistroInfo, DistroDataOutdated
32
38
 
51
57
        debian_info = DebianDistroInfo()
52
58
        try:
53
59
            release = debian_info.codename(release, default=release)
54
 
        except DistroDataOutdated, e:
 
60
        except DistroDataOutdated as e:
55
61
            Logger.warn(e)
56
62
 
57
63
    lines = list(rmadison(distro, name, suite=release, arch='source'))
86
92
    '''
87
93
    Point the user to the URL to manually check for duplicate bug reports.
88
94
    '''
89
 
    print ('Please check on '
90
 
           'https://bugs.launchpad.net/ubuntu/+source/%s/+bugs\n'
91
 
           'for duplicate sync requests before continuing.' % srcpkg)
 
95
    print('Please check on '
 
96
          'https://bugs.launchpad.net/ubuntu/+source/%s/+bugs\n'
 
97
          'for duplicate sync requests before continuing.' % srcpkg)
92
98
    confirmation_prompt()
93
99
 
94
100
def get_ubuntu_delta_changelog(srcpkg):
164
170
 
165
171
%s''' % (myemailaddr, to, bugtitle, signed_report)
166
172
 
167
 
    print 'The final report is:\n%s' % mail
 
173
    print('The final report is:\n%s' % mail)
168
174
    confirmation_prompt()
169
175
 
170
176
    # save mail in temporary file
184
190
                          mailserver_port)
185
191
            s = smtplib.SMTP(mailserver_host, mailserver_port)
186
192
            break
187
 
        except socket.error, s:
 
193
        except socket.error as s:
188
194
            Logger.error('Could not connect to %s:%s: %s (%i)',
189
195
                         mailserver_host, mailserver_port, s[1], s[0])
190
196
            return
191
 
        except smtplib.SMTPConnectError, s:
 
197
        except smtplib.SMTPConnectError as s:
192
198
            Logger.error('Could not connect to %s:%s: %s (%i)',
193
199
                         mailserver_host, mailserver_port, s[1], s[0])
194
200
            if s.smtp_code == 421:
215
221
            os.remove(backup.name)
216
222
            Logger.normal('Sync request mailed.')
217
223
            break
218
 
        except smtplib.SMTPRecipientsRefused, smtperror:
 
224
        except smtplib.SMTPRecipientsRefused as smtperror:
219
225
            smtp_code, smtp_message = smtperror.recipients[to]
220
226
            Logger.error('Error while sending: %i, %s', smtp_code, smtp_message)
221
227
            if smtp_code == 450:
223
229
                          '[Enter] to retry. Press [Ctrl-C] to abort now.')
224
230
            else:
225
231
                return
226
 
        except smtplib.SMTPResponseException, e:
 
232
        except smtplib.SMTPResponseException as e:
227
233
            Logger.error('Error while sending: %i, %s',
228
234
                         e.smtp_code, e.smtp_error)
229
235
            return