Reformat python files checked by pylint (part 1/2).
After recently changing .pylintrc (see [1]) we discovered that the presubmit check always checks all the python files when just one python file gets updated. This CL moves all these files one step closer to what the linter wants. Autogenerated with: # Added all the files under pylint control to ~/Desktop/to-reformat cat ~/Desktop/to-reformat | xargs sed -i '1i\\' git cl format --python --full This is part 1 out of 2. The second part will fix function names and will not be automated. [1] - https://webrtc-review.googlesource.com/c/src/+/186664 No-Presubmit: True Bug: webrtc:12114 Change-Id: Idfec4d759f209a2090440d0af2413a1ddc01b841 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/190980 Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Cr-Commit-Position: refs/heads/master@{#32530}
This commit is contained in:
committed by
Commit Bot
parent
d3a3e9ef36
commit
8cc6695652
@ -6,7 +6,6 @@
|
||||
# tree. An additional intellectual property rights grant can be found
|
||||
# in the file PATENTS. All contributing project authors may
|
||||
# be found in the AUTHORS file in the root of the source tree.
|
||||
|
||||
"""Utilities for all our deps-management stuff."""
|
||||
|
||||
from __future__ import absolute_import
|
||||
@ -23,36 +22,37 @@ import zipfile
|
||||
|
||||
|
||||
def RunSubprocessWithRetry(cmd):
|
||||
"""Invokes the subprocess and backs off exponentially on fail."""
|
||||
for i in range(5):
|
||||
try:
|
||||
subprocess.check_call(cmd)
|
||||
return
|
||||
except subprocess.CalledProcessError as exception:
|
||||
backoff = pow(2, i)
|
||||
print('Got %s, retrying in %d seconds...' % (exception, backoff))
|
||||
time.sleep(backoff)
|
||||
"""Invokes the subprocess and backs off exponentially on fail."""
|
||||
for i in range(5):
|
||||
try:
|
||||
subprocess.check_call(cmd)
|
||||
return
|
||||
except subprocess.CalledProcessError as exception:
|
||||
backoff = pow(2, i)
|
||||
print('Got %s, retrying in %d seconds...' % (exception, backoff))
|
||||
time.sleep(backoff)
|
||||
|
||||
print('Giving up.')
|
||||
raise exception
|
||||
print('Giving up.')
|
||||
raise exception
|
||||
|
||||
|
||||
def DownloadFilesFromGoogleStorage(path, auto_platform=True):
|
||||
print('Downloading files in %s...' % path)
|
||||
print('Downloading files in %s...' % path)
|
||||
|
||||
extension = 'bat' if 'win32' in sys.platform else 'py'
|
||||
cmd = ['download_from_google_storage.%s' % extension,
|
||||
'--bucket=chromium-webrtc-resources',
|
||||
'--directory', path]
|
||||
if auto_platform:
|
||||
cmd += ['--auto_platform', '--recursive']
|
||||
subprocess.check_call(cmd)
|
||||
extension = 'bat' if 'win32' in sys.platform else 'py'
|
||||
cmd = [
|
||||
'download_from_google_storage.%s' % extension,
|
||||
'--bucket=chromium-webrtc-resources', '--directory', path
|
||||
]
|
||||
if auto_platform:
|
||||
cmd += ['--auto_platform', '--recursive']
|
||||
subprocess.check_call(cmd)
|
||||
|
||||
|
||||
# Code partially copied from
|
||||
# https://cs.chromium.org#chromium/build/scripts/common/chromium_utils.py
|
||||
def RemoveDirectory(*path):
|
||||
"""Recursively removes a directory, even if it's marked read-only.
|
||||
"""Recursively removes a directory, even if it's marked read-only.
|
||||
|
||||
Remove the directory located at *path, if it exists.
|
||||
|
||||
@ -67,62 +67,63 @@ def RemoveDirectory(*path):
|
||||
bit and try again, so we do that too. It's hand-waving, but sometimes it
|
||||
works. :/
|
||||
"""
|
||||
file_path = os.path.join(*path)
|
||||
print('Deleting `{}`.'.format(file_path))
|
||||
if not os.path.exists(file_path):
|
||||
print('`{}` does not exist.'.format(file_path))
|
||||
return
|
||||
file_path = os.path.join(*path)
|
||||
print('Deleting `{}`.'.format(file_path))
|
||||
if not os.path.exists(file_path):
|
||||
print('`{}` does not exist.'.format(file_path))
|
||||
return
|
||||
|
||||
if sys.platform == 'win32':
|
||||
# Give up and use cmd.exe's rd command.
|
||||
file_path = os.path.normcase(file_path)
|
||||
for _ in range(3):
|
||||
print('RemoveDirectory running %s' % (' '.join(
|
||||
['cmd.exe', '/c', 'rd', '/q', '/s', file_path])))
|
||||
if not subprocess.call(['cmd.exe', '/c', 'rd', '/q', '/s', file_path]):
|
||||
break
|
||||
print(' Failed')
|
||||
time.sleep(3)
|
||||
return
|
||||
else:
|
||||
shutil.rmtree(file_path, ignore_errors=True)
|
||||
if sys.platform == 'win32':
|
||||
# Give up and use cmd.exe's rd command.
|
||||
file_path = os.path.normcase(file_path)
|
||||
for _ in range(3):
|
||||
print('RemoveDirectory running %s' %
|
||||
(' '.join(['cmd.exe', '/c', 'rd', '/q', '/s', file_path])))
|
||||
if not subprocess.call(
|
||||
['cmd.exe', '/c', 'rd', '/q', '/s', file_path]):
|
||||
break
|
||||
print(' Failed')
|
||||
time.sleep(3)
|
||||
return
|
||||
else:
|
||||
shutil.rmtree(file_path, ignore_errors=True)
|
||||
|
||||
|
||||
def UnpackArchiveTo(archive_path, output_dir):
|
||||
extension = os.path.splitext(archive_path)[1]
|
||||
if extension == '.zip':
|
||||
_UnzipArchiveTo(archive_path, output_dir)
|
||||
else:
|
||||
_UntarArchiveTo(archive_path, output_dir)
|
||||
extension = os.path.splitext(archive_path)[1]
|
||||
if extension == '.zip':
|
||||
_UnzipArchiveTo(archive_path, output_dir)
|
||||
else:
|
||||
_UntarArchiveTo(archive_path, output_dir)
|
||||
|
||||
|
||||
def _UnzipArchiveTo(archive_path, output_dir):
|
||||
print('Unzipping {} in {}.'.format(archive_path, output_dir))
|
||||
zip_file = zipfile.ZipFile(archive_path)
|
||||
try:
|
||||
zip_file.extractall(output_dir)
|
||||
finally:
|
||||
zip_file.close()
|
||||
print('Unzipping {} in {}.'.format(archive_path, output_dir))
|
||||
zip_file = zipfile.ZipFile(archive_path)
|
||||
try:
|
||||
zip_file.extractall(output_dir)
|
||||
finally:
|
||||
zip_file.close()
|
||||
|
||||
|
||||
def _UntarArchiveTo(archive_path, output_dir):
|
||||
print('Untarring {} in {}.'.format(archive_path, output_dir))
|
||||
tar_file = tarfile.open(archive_path, 'r:gz')
|
||||
try:
|
||||
tar_file.extractall(output_dir)
|
||||
finally:
|
||||
tar_file.close()
|
||||
print('Untarring {} in {}.'.format(archive_path, output_dir))
|
||||
tar_file = tarfile.open(archive_path, 'r:gz')
|
||||
try:
|
||||
tar_file.extractall(output_dir)
|
||||
finally:
|
||||
tar_file.close()
|
||||
|
||||
|
||||
def GetPlatform():
|
||||
if sys.platform.startswith('win'):
|
||||
return 'win'
|
||||
if sys.platform.startswith('linux'):
|
||||
return 'linux'
|
||||
if sys.platform.startswith('darwin'):
|
||||
return 'mac'
|
||||
raise Exception("Can't run on platform %s." % sys.platform)
|
||||
if sys.platform.startswith('win'):
|
||||
return 'win'
|
||||
if sys.platform.startswith('linux'):
|
||||
return 'linux'
|
||||
if sys.platform.startswith('darwin'):
|
||||
return 'mac'
|
||||
raise Exception("Can't run on platform %s." % sys.platform)
|
||||
|
||||
|
||||
def GetExecutableExtension():
|
||||
return '.exe' if GetPlatform() == 'win' else ''
|
||||
return '.exe' if GetPlatform() == 'win' else ''
|
||||
|
||||
Reference in New Issue
Block a user