Skip to content

Commit

Permalink
tools/git-sync-deps works with either python
Browse files Browse the repository at this point in the history
Bug: skia:9079
Change-Id: Id172efad6bbfaeb1d1f6bc00bcda622588f0a924
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/263355
Reviewed-by: Joe Gregorio <[email protected]>
Commit-Queue: Joe Gregorio <[email protected]>
Auto-Submit: Hal Canary <[email protected]>
  • Loading branch information
HalCanary authored and Skia Commit-Bot committed Jan 10, 2020
1 parent 504032e commit 70a4fd2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
8 changes: 6 additions & 2 deletions bin/fetch-gn
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import os
import shutil
import stat
import sys
import urllib2

if sys.version_info[0] < 3:
from urllib2 import urlopen
else:
from urllib.request import urlopen

os.chdir(os.path.join(os.path.dirname(__file__), os.pardir))

Expand All @@ -29,7 +33,7 @@ def sha1_of_file(path):

if sha1_of_file(dst) != sha1:
with open(dst, 'wb') as f:
f.write(urllib2.urlopen('https://chromium-gn.storage-download.googleapis.com/' + sha1).read())
f.write(urlopen('https://chromium-gn.storage-download.googleapis.com/' + sha1).read())

os.chmod(dst, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR |
stat.S_IRGRP | stat.S_IXGRP |
Expand Down
9 changes: 5 additions & 4 deletions tools/git-sync-deps
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def is_git_toplevel(git, directory):
try:
toplevel = subprocess.check_output(
[git, 'rev-parse', '--show-toplevel'], cwd=directory).strip()
return os.path.realpath(directory) == os.path.realpath(toplevel)
return os.path.realpath(directory) == os.path.realpath(toplevel.decode())
except subprocess.CalledProcessError:
return False

Expand Down Expand Up @@ -172,7 +172,8 @@ def git_checkout_to_directory(git, repo, commithash, directory, verbose):

def parse_file_to_dict(path):
dictionary = {}
execfile(path, dictionary)
with open(path) as f:
exec(f.read(), dictionary)
return dictionary


Expand Down Expand Up @@ -214,9 +215,9 @@ def git_sync_deps(deps_file_path, command_line_os_requests, verbose):
raise Exception('%r is parent of %r' % (other_dir, directory))
list_of_arg_lists = []
for directory in sorted(dependencies):
if not isinstance(dependencies[directory], basestring):
if not isinstance(dependencies[directory], str):
if verbose:
print 'Skipping "%s".' % directory
sys.stdout.write( 'Skipping "%s".\n' % directory)
continue
if '@' in dependencies[directory]:
repo, commithash = dependencies[directory].split('@', 1)
Expand Down

0 comments on commit 70a4fd2

Please sign in to comment.