From 147526b0a89cf93b34886b672bc25a3283ff4222 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Wed, 15 Apr 2020 17:06:07 +1200 Subject: [PATCH] zcutil/make-release.py: Fix to run with Python 3 --- zcutil/make-release.py | 15 +++++++++++---- zcutil/release-notes.py | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/zcutil/make-release.py b/zcutil/make-release.py index 5ca552402..285539ca5 100755 --- a/zcutil/make-release.py +++ b/zcutil/make-release.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python2 +#! /usr/bin/env python3 import os import re @@ -9,7 +9,7 @@ import subprocess import traceback import unittest import random -from cStringIO import StringIO +from io import StringIO from functools import wraps @@ -403,7 +403,7 @@ def initialize_logging(): def sh_out(*args): logging.debug('Run (out): %r', args) - return subprocess.check_output(args) + return subprocess.check_output(args).decode() def sh_log(*args): @@ -417,7 +417,7 @@ def sh_log(*args): logging.debug('Run (log PID %r): %r', p.pid, args) for line in p.stdout: - logging.debug('> %s', line.rstrip()) + logging.debug('> %s', line.decode().rstrip()) status = p.wait() if status != 0: raise SystemExit('Nonzero exit status: {!r}'.format(status)) @@ -443,6 +443,7 @@ def sh_progress(markers, *args): pbar.update(marker) logging.debug('Run (log PID %r): %r', p.pid, args) for line in p.stdout: + line = line.decode() logging.debug('> %s', line.rstrip()) for idx, val in enumerate(markers[marker:]): if val in line: @@ -557,6 +558,12 @@ class Version (object): self.hotfix, ) + def __lt__(self, other): + return self._sort_tup() < other._sort_tup() + + def __eq__(self, other): + return self._sort_tup() == other._sort_tup() + class PathPatcher (object): def __init__(self, path): diff --git a/zcutil/release-notes.py b/zcutil/release-notes.py index 0fa9d1095..8456005dd 100755 --- a/zcutil/release-notes.py +++ b/zcutil/release-notes.py @@ -110,7 +110,7 @@ def generate_release_note(version, prev, clear): latest_tag = subprocess.Popen(['git describe --abbrev=0'], shell=True, stdout=subprocess.PIPE).communicate()[0].strip() print("Previous release tag: ", latest_tag) notes = subprocess.Popen(['git shortlog --no-merges {0}..HEAD'.format(latest_tag)], shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE).communicate()[0] - lines = notes.split('\n') + lines = notes.decode().split('\n') lines = [alias_authors_in_release_notes(line) for line in lines] temp_release_note = os.path.join(doc_dir, 'release-notes.md') with open(temp_release_note, 'r') as f: