From f6228e15833477a8a766b6d298fe485237384ccb Mon Sep 17 00:00:00 2001 From: Gavin Mak Date: Mon, 12 Jul 2021 21:15:18 +0000 Subject: [PATCH] Revert "Add python3 support to bot_update recipe module" This reverts commit edb6e8c51f975e893edb793e3afbbf80f6f3cbbf. Reason for revert: missing some py3 changes Original change's description: > Add python3 support to bot_update recipe module > > Bug: 1227140 > Change-Id: Id4938c966da54957f84f59d0aef0c68c381ad5f6 > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3016032 > Reviewed-by: Josip Sokcevic > Commit-Queue: Gavin Mak Bug: 1227140 Change-Id: If0852908b112ff6bdd4152189c7cb198eebd2c22 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3022309 Auto-Submit: Gavin Mak Commit-Queue: Rubber Stamper Bot-Commit: Rubber Stamper --- .../bot_update/resources/bot_update.py | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/recipes/recipe_modules/bot_update/resources/bot_update.py b/recipes/recipe_modules/bot_update/resources/bot_update.py index 54e60ac1f..94e27f741 100755 --- a/recipes/recipe_modules/bot_update/resources/bot_update.py +++ b/recipes/recipe_modules/bot_update/resources/bot_update.py @@ -5,9 +5,9 @@ # TODO(hinoka): Use logging. -from __future__ import division from __future__ import print_function +import cStringIO import codecs from contextlib import contextmanager import copy @@ -18,24 +18,19 @@ import json import optparse import os import pprint +import random import re import subprocess import sys import tempfile import threading import time +import urllib2 +import urlparse import uuid import os.path as path -# TODO(crbug.com/1227140): Clean up when py2 is no longer supported. -try: - from cStringIO import StringIO - import urlparse -except ImportError: # pragma: no cover - from io import StringIO - import urllib.parse as urlparse - # How many bytes at a time to read from pipes. BUF_SIZE = 256 @@ -175,7 +170,7 @@ def call(*args, **kwargs): # pragma: no cover stdin_data = kwargs.pop('stdin_data', None) if stdin_data: kwargs['stdin'] = subprocess.PIPE - out = StringIO() + out = cStringIO.StringIO() new_env = kwargs.get('env', {}) env = os.environ.copy() env.update(new_env) @@ -460,7 +455,7 @@ def create_manifest(): for path, info in json.load(f).items() if info['rev'] is not None } - except (ValueError, SubprocessFailed): + except ValueError, SubprocessFailed: return {} finally: os.remove(fname) @@ -603,7 +598,7 @@ def _maybe_break_locks(checkout_path, tries=3): print('FAILED to break lock: %s: %s' % (to_break, ex)) raise - for _ in range(tries): + for _ in xrange(tries): try: attempt() return