Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(287)

Side by Side Diff: Lib/distutils/command/upload.py

Issue 21722: teach distutils "upload" to exit with code != 0 when error occurs
Patch Set: Created 5 years, 11 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | Lib/distutils/tests/test_upload.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 """distutils.command.upload 1 """distutils.command.upload
2 2
3 Implements the Distutils 'upload' subcommand (upload package to PyPI).""" 3 Implements the Distutils 'upload' subcommand (upload package to PyPI)."""
4 import os 4 import os
5 import socket 5 import socket
6 import platform 6 import platform
7 from urllib2 import urlopen, Request, HTTPError 7 from urllib2 import urlopen, Request, HTTPError
8 from base64 import standard_b64encode 8 from base64 import standard_b64encode
9 import urlparse 9 import urlparse
10 import cStringIO as StringIO 10 import cStringIO as StringIO
11 from hashlib import md5 11 from hashlib import md5
12 12
13 from distutils.errors import DistutilsOptionError 13 from distutils.errors import DistutilsError, DistutilsOptionError
14 from distutils.core import PyPIRCCommand 14 from distutils.core import PyPIRCCommand
15 from distutils.spawn import spawn 15 from distutils.spawn import spawn
16 from distutils import log 16 from distutils import log
17 17
18 class upload(PyPIRCCommand): 18 class upload(PyPIRCCommand):
19 19
20 description = "upload binary package to PyPI" 20 description = "upload binary package to PyPI"
21 21
22 user_options = PyPIRCCommand.user_options + [ 22 user_options = PyPIRCCommand.user_options + [
23 ('sign', 's', 23 ('sign', 's',
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 # send the data 174 # send the data
175 try: 175 try:
176 result = urlopen(request) 176 result = urlopen(request)
177 status = result.getcode() 177 status = result.getcode()
178 reason = result.msg 178 reason = result.msg
179 if self.show_response: 179 if self.show_response:
180 msg = '\n'.join(('-' * 75, result.read(), '-' * 75)) 180 msg = '\n'.join(('-' * 75, result.read(), '-' * 75))
181 self.announce(msg, log.INFO) 181 self.announce(msg, log.INFO)
182 except socket.error, e: 182 except socket.error, e:
183 self.announce(str(e), log.ERROR) 183 self.announce(str(e), log.ERROR)
184 return 184 raise
185 except HTTPError, e: 185 except HTTPError, e:
186 status = e.code 186 status = e.code
187 reason = e.msg 187 reason = e.msg
188 188
189 if status == 200: 189 if status == 200:
190 self.announce('Server response (%s): %s' % (status, reason), 190 self.announce('Server response (%s): %s' % (status, reason),
191 log.INFO) 191 log.INFO)
192 else: 192 else:
193 self.announce('Upload failed (%s): %s' % (status, reason), 193 msg = 'Upload failed (%s): %s' % (status, reason)
194 log.ERROR) 194 self.announce(msg, log.ERROR)
195 raise DistutilsError(msg)
OLDNEW
« no previous file with comments | « no previous file | Lib/distutils/tests/test_upload.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+