Commit 38af6239 authored by Jason R. Coombs's avatar Jason R. Coombs

Update release script to run under Python 3

parent b0abfb1c
......@@ -11,12 +11,21 @@ import subprocess
import shutil
import os
import sys
import urllib2
import getpass
import collections
import itertools
import re
try:
import urllib.request as urllib_request
except ImportError:
import urllib2 as urllib_request
try:
input = raw_input
except NameError:
pass
try:
import keyring
except Exception:
......@@ -27,7 +36,7 @@ PACKAGE_INDEX = 'https://pypi.python.org/pypi'
def set_versions():
global VERSION
version = raw_input("Release as version [%s]> " % VERSION) or VERSION
version = input("Release as version [%s]> " % VERSION) or VERSION
if version != VERSION:
VERSION = bump_versions(version)
......@@ -99,11 +108,11 @@ def add_milestone_and_version(version):
for type in 'milestones', 'versions':
url = (base + '/1.0/repositories/{repo}/issues/{type}'
.format(repo = get_repo_name(), type=type))
req = urllib2.Request(url = url, headers = headers,
req = urllib_request.Request(url = url, headers = headers,
data='name='+version)
try:
urllib2.urlopen(req)
except urllib2.HTTPError as e:
urllib_request.urlopen(req)
except urllib_request.HTTPError as e:
print(e.fp.read())
def bump_versions(target_ver):
......@@ -116,7 +125,10 @@ def bump_versions(target_ver):
def bump_version(filename, target_ver):
with open(filename, 'rb') as f:
lines = [line.replace(VERSION, target_ver) for line in f]
lines = [
line.replace(VERSION.encode('ascii'), target_ver.encode('ascii'))
for line in f
]
with open(filename, 'wb') as f:
f.writelines(lines)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment