From: Jochen Sprickerhof Date: Sun, 31 Jan 2021 15:22:55 +0000 (+0100) Subject: Adopt to Python 3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d4864b85a1f4279aa42e8800189b520f7f722352;p=tools%2Fgit-buildpackage-rpm-testdata.git Adopt to Python 3 --- diff --git a/manage.py b/manage.py index 3eb8c39..57a56c7 100755 --- a/manage.py +++ b/manage.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # vim:fileencoding=utf-8:et:ts=4:sw=4:sts=4 # # Copyright (C) 2015 Intel Corporation @@ -20,7 +20,7 @@ """Script for managing test package repositories and unittest data""" import argparse -import ConfigParser +import configparser import json import logging import os @@ -55,9 +55,9 @@ def run_cmd(cmd, opts=None, capture_stdout=False, capture_stderr=False, LOG.debug("Running command: '%s'", ' '.join(args)) popen = subprocess.Popen(args, stdin=stdin, stdout=stdout, stderr=stderr, env=env) - stdout, stderr = popen.communicate(input_data) - ret_out = stdout.splitlines() if stdout else stdout - ret_err = stderr.splitlines() if stderr else stderr + stdout, stderr = popen.communicate(input_data.encode() if input_data else None) + ret_out = stdout.decode().splitlines() if stdout else stdout + ret_err = stderr.decode().splitlines() if stderr else stderr return (popen.returncode, ret_out, ret_err) @@ -240,7 +240,7 @@ def cmd_build(args): raise Exception("No repositories found, run 'import' in order to " "initialize test package repositories for building") # Read build config - config = ConfigParser.RawConfigParser() + config = configparser.RawConfigParser() config.read('build.conf') for repodir in repos: @@ -351,7 +351,7 @@ def import_repo(datadir, repodir, force): # Create child mapping of commit history commits = defaultdict(list) - for sha1, info in manifest['commits'].iteritems(): + for sha1, info in manifest['commits'].items(): if 'parents' not in info: commits['root'].append(sha1) else: @@ -367,7 +367,7 @@ def import_repo(datadir, repodir, force): import_commit_history('root') # Re-create tags - for sha1, tag in manifest['tags'].iteritems(): + for sha1, tag in manifest['tags'].items(): signature_data = "object %s\ntype %s\ntag %s\ntagger %s\n\n%s\n" % ( tag['object'], tag['type'], tag['tag'], tag['tagger'], tag['message']) @@ -377,7 +377,7 @@ def import_repo(datadir, repodir, force): (new_sha1, sha1) # Re-create refs - for ref, sha1 in manifest['refs'].iteritems(): + for ref, sha1 in manifest['refs'].items(): git_cmd('update-ref', [ref, sha1], True) # Forcefully set HEAD