Commit edb6e8c5 authored by Gavin Mak's avatar Gavin Mak Committed by LUCI CQ

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/+/3016032Reviewed-by: 's avatarJosip Sokcevic <sokcevic@google.com>
Commit-Queue: Gavin Mak <gavinmak@google.com>
parent ff5a2866
......@@ -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,19 +18,24 @@ 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
......@@ -170,7 +175,7 @@ def call(*args, **kwargs): # pragma: no cover
stdin_data = kwargs.pop('stdin_data', None)
if stdin_data:
kwargs['stdin'] = subprocess.PIPE
out = cStringIO.StringIO()
out = StringIO()
new_env = kwargs.get('env', {})
env = os.environ.copy()
env.update(new_env)
......@@ -455,7 +460,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)
......@@ -598,7 +603,7 @@ def _maybe_break_locks(checkout_path, tries=3):
print('FAILED to break lock: %s: %s' % (to_break, ex))
raise
for _ in xrange(tries):
for _ in range(tries):
try:
attempt()
return
......
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