1. PyPA
  2. Python Packaging Authority Projects
  3. setuptools

Commits

Jason R. Coombs  committed 02f52af

Use requests for updating milestone and version

  • Participants
  • Parent commits 6c5bcc7
  • Branches default

Comments (0)

Files changed (1)

File release.py

View file
 import itertools
 import re
 
-try:
-	import urllib.request as urllib_request
-except ImportError:
-	import urllib2 as urllib_request
+import requests
 
 try:
 	input = raw_input
 	"""
 	Get the repo name from the hgrc default path.
 	"""
-	default = subprocess.check_output('hg paths default').strip()
+	default = subprocess.check_output('hg paths default').strip().decode('utf-8')
 	parts = default.split('/')
 	if parts[-1] == '':
 		parts.pop()
 	return Credential(username, password)
 
 def add_milestone_and_version(version):
-	auth = 'Basic ' + ':'.join(get_mercurial_creds()).encode('base64').strip()
-	headers = {
-		'Authorization': auth,
-	}
 	base = 'https://api.bitbucket.org'
 	for type in 'milestones', 'versions':
 		url = (base + '/1.0/repositories/{repo}/issues/{type}'
 			.format(repo = get_repo_name(), type=type))
-		req = urllib_request.Request(url = url, headers = headers,
-			data='name='+version)
-		try:
-			urllib_request.urlopen(req)
-		except urllib_request.HTTPError as e:
-			print(e.fp.read())
+		resp = requests.post(url=url,
+			data='name='+version, auth=get_mercurial_creds())
+		resp.raise_for_status()
 
 def bump_versions(target_ver):
 	for filename in files_with_versions: