Adopt to Python 3
authorJochen Sprickerhof <git@jochen.sprickerhof.de>
Sun, 31 Jan 2021 15:22:55 +0000 (16:22 +0100)
committerGuido Günther <agx@sigxcpu.org>
Mon, 1 Feb 2021 08:01:27 +0000 (09:01 +0100)
manage.py

index 3eb8c39687b4503647586567211d18b93fccbb83..57a56c76473697caa382fb95fc7dbabfa69cc983 100755 (executable)
--- 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 <markus.lehtonen@linux.intel.com>
@@ -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