Skip to content

Commit c984351

Browse files
futurize build/scripts
commit_hash:41fb885eb1e03094e65521671349e66f4225321b
1 parent 1339bbd commit c984351

31 files changed

+134
-138
lines changed

build/scripts/build_catboost.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
import sys
23
import os
34
import shutil
@@ -45,7 +46,7 @@ def run(self, cbmodel, cbname, cb_cpp_path):
4546
class BuildCb(BuildCbBase):
4647
def run(self, argv):
4748
if len(argv) < 5:
48-
print >> sys.stderr, "BuildCb.Run(<ARCADIA_ROOT> <archiver> <mninfo> <mnname> <cppOutput> [params...])"
49+
print("BuildCb.Run(<ARCADIA_ROOT> <archiver> <mninfo> <mnname> <cppOutput> [params...])", file=sys.stderr)
4950
sys.exit(1)
5051

5152
self.SrcRoot = argv[0]
@@ -64,7 +65,7 @@ def build_cb_f(argv):
6465

6566
if __name__ == '__main__':
6667
if len(sys.argv) < 2:
67-
print >> sys.stderr, "Usage: build_cb.py <funcName> <args...>"
68+
print("Usage: build_cb.py <funcName> <args...>", file=sys.stderr)
6869
sys.exit(1)
6970

7071
if sys.argv[2:]:

build/scripts/clang_tidy.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
import argparse
23
import json
34
import os

build/scripts/collect_java_srcs.py

Lines changed: 0 additions & 51 deletions
This file was deleted.

build/scripts/compile_cuda.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
import sys
23
import subprocess
34
import os
@@ -60,7 +61,7 @@ def main():
6061

6162
executable = command[0]
6263
if not os.path.exists(executable):
63-
print >> sys.stderr, '{} not found'.format(executable)
64+
print('{} not found'.format(executable), file=sys.stderr)
6465
sys.exit(1)
6566

6667
if is_clang(command):

build/scripts/configure_file.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env python2.7
22

3+
from __future__ import print_function
34
import sys
45
import os.path
56
import re

build/scripts/coverage-info.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
import argparse
23
import os
34
import sys
@@ -72,12 +73,12 @@ def print_stat(da, fnda, teamcity_stat_output):
7273
func_total = len(fnda.values())
7374
func_coverage = 100.0 * func_hit / func_total if func_total else 0
7475

75-
print >> sys.stderr, '[[imp]]Lines[[rst]] {: >16} {: >16} {: >16.1f}%'.format(
76+
print('[[imp]]Lines[[rst]] {: >16} {: >16} {: >16.1f}%'.format(
7677
lines_hit, lines_total, lines_coverage
77-
)
78-
print >> sys.stderr, '[[imp]]Functions[[rst]] {: >16} {: >16} {: >16.1f}%'.format(
78+
), file=sys.stderr)
79+
print('[[imp]]Functions[[rst]] {: >16} {: >16} {: >16.1f}%'.format(
7980
func_hit, func_total, func_coverage
80-
)
81+
), file=sys.stderr)
8182

8283
if teamcity_stat_output:
8384
with open(teamcity_stat_output, 'w') as tc_file:
@@ -119,7 +120,7 @@ def combine_info_files(lcov, files, out_file):
119120
for trace in chunk:
120121
assert os.path.exists(trace), "Trace file does not exist: {} (cwd={})".format(trace, os.getcwd())
121122
combine_cmd += ["-a", os.path.abspath(trace)]
122-
print >> sys.stderr, '## lcov', ' '.join(combine_cmd[1:])
123+
print('## lcov', ' '.join(combine_cmd[1:]), file=sys.stderr)
123124
out_file_tmp = "combined.tmp"
124125
with open(out_file_tmp, "w") as stdout:
125126
subprocess.check_call(combine_cmd, stdout=stdout)
@@ -157,7 +158,7 @@ def update_stat_global(src_file, line, fnda, da):
157158

158159

159160
def gen_info_global(cmd, cov_info, probe_path, update_stat, lcov_args):
160-
print >> sys.stderr, '## geninfo', ' '.join(cmd)
161+
print('## geninfo', ' '.join(cmd), file=sys.stderr)
161162
subprocess.check_call(cmd)
162163
if recast(cov_info + '.tmp', cov_info, probe_path, update_stat):
163164
lcov_args.append(cov_info)
@@ -297,7 +298,7 @@ def gen_info(cmd, cov_info):
297298
output_dir,
298299
output_trace,
299300
]
300-
print >> sys.stderr, '## genhtml', ' '.join(cmd)
301+
print('## genhtml', ' '.join(cmd), file=sys.stderr)
301302
subprocess.check_call(cmd)
302303
if lcov_cobertura:
303304
gen_cobertura(lcov_cobertura, gcov_report, output_trace)

build/scripts/create_jcoverage_report.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
import argparse
23
import tarfile
34
import zipfile
@@ -77,12 +78,12 @@ def main(
7778
else:
7879
continue
7980

80-
entry.filename = entry.filename.encode('utf-8')
81+
entry.filename = entry.filename
8182
jf.extract(entry, dest)
8283
timer.step("Jar files extracted")
8384

8485
if not agent_disposition:
85-
print >> sys.stderr, 'Can\'t find jacoco agent. Will not generate html report for java coverage.'
86+
print('Can\'t find jacoco agent. Will not generate html report for java coverage.', file=sys.stderr)
8687

8788
if tar_output:
8889
report_dir = 'java.report.temp'

build/scripts/custom_link_green_mysql.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
import os
23
import shutil
34
import subprocess
@@ -91,7 +92,7 @@ def get_tool(name):
9192
name = os.path.basename(sys.argv[0])
9293
command = ' '.join(args)
9394
message = '{name} failed: {error}\nCommand line: {command}'
94-
print >> sys.stderr, message.format(**locals())
95+
print(message.format(**locals()), file=sys.stderr)
9596

9697

9798
if __name__ == '__main__':

build/scripts/decimal_md5.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33

4+
from __future__ import print_function
45
import hashlib
56
import struct
67
import sys
@@ -20,9 +21,9 @@ def ensure_paths_exist(paths):
2021
if not os.path.exists(path)
2122
)
2223
if bad_paths:
23-
print >> sys.stderr, "decimal_md5 inputs do not exist:"
24+
print("decimal_md5 inputs do not exist:", file=sys.stderr)
2425
for path in bad_paths:
25-
print >> sys.stderr, path
26+
print(path, file=sys.stderr)
2627
sys.exit(1)
2728

2829

build/scripts/error.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,17 @@ def is_temporary_error(exc):
6363
logger.debug("Getaddrinfo exception: %s", exc)
6464
return True
6565

66-
import urllib2
66+
try:
67+
import urllib2
68+
import httplib
69+
except ImportError:
70+
import urllib.request as urllib2
71+
import http.client as httplib
6772

6873
if isinstance(exc, urllib2.HTTPError) and exc.code in (429,):
6974
logger.debug("urllib2.HTTPError: %s", exc)
7075
return True
7176

72-
import httplib
73-
7477
if isinstance(exc, httplib.IncompleteRead):
7578
logger.debug("IncompleteRead exception: %s", exc)
7679
return True

0 commit comments

Comments
 (0)