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 ...@@ -11,12 +11,21 @@ import subprocess
import shutil import shutil
import os import os
import sys import sys
import urllib2
import getpass import getpass
import collections import collections
import itertools import itertools
import re import re
try:
import urllib.request as urllib_request
except ImportError:
import urllib2 as urllib_request
try:
input = raw_input
except NameError:
pass
try: try:
import keyring import keyring
except Exception: except Exception:
...@@ -27,7 +36,7 @@ PACKAGE_INDEX = 'https://pypi.python.org/pypi' ...@@ -27,7 +36,7 @@ PACKAGE_INDEX = 'https://pypi.python.org/pypi'
def set_versions(): def set_versions():
global VERSION global VERSION
version = raw_input("Release as version [%s]> " % VERSION) or VERSION version = input("Release as version [%s]> " % VERSION) or VERSION
if version != VERSION: if version != VERSION:
VERSION = bump_versions(version) VERSION = bump_versions(version)
...@@ -99,11 +108,11 @@ def add_milestone_and_version(version): ...@@ -99,11 +108,11 @@ def add_milestone_and_version(version):
for type in 'milestones', 'versions': for type in 'milestones', 'versions':
url = (base + '/1.0/repositories/{repo}/issues/{type}' url = (base + '/1.0/repositories/{repo}/issues/{type}'
.format(repo = get_repo_name(), type=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) data='name='+version)
try: try:
urllib2.urlopen(req) urllib_request.urlopen(req)
except urllib2.HTTPError as e: except urllib_request.HTTPError as e:
print(e.fp.read()) print(e.fp.read())
def bump_versions(target_ver): def bump_versions(target_ver):
...@@ -116,7 +125,10 @@ def bump_versions(target_ver): ...@@ -116,7 +125,10 @@ def bump_versions(target_ver):
def bump_version(filename, target_ver): def bump_version(filename, target_ver):
with open(filename, 'rb') as f: 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: with open(filename, 'wb') as f:
f.writelines(lines) 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