diff options
author | v-korovin <v-korovin@yandex-team.com> | 2024-09-26 10:35:27 +0300 |
---|---|---|
committer | v-korovin <v-korovin@yandex-team.com> | 2024-09-26 10:44:46 +0300 |
commit | c9843510b39357d5510030691beecfab56e3bd17 (patch) | |
tree | 990009b83044e936303dec6b770033b46f59c6fc | |
parent | 1339bbde1687911362cf2a244869e30003508986 (diff) | |
download | ydb-c9843510b39357d5510030691beecfab56e3bd17.tar.gz |
futurize build/scripts
commit_hash:41fb885eb1e03094e65521671349e66f4225321b
31 files changed, 134 insertions, 138 deletions
diff --git a/build/scripts/build_catboost.py b/build/scripts/build_catboost.py index 81d4e795a0..6455bb59bb 100755 --- a/build/scripts/build_catboost.py +++ b/build/scripts/build_catboost.py @@ -1,3 +1,4 @@ +from __future__ import print_function import sys import os import shutil @@ -45,7 +46,7 @@ class BuildCbBase(object): class BuildCb(BuildCbBase): def run(self, argv): if len(argv) < 5: - print >> sys.stderr, "BuildCb.Run(<ARCADIA_ROOT> <archiver> <mninfo> <mnname> <cppOutput> [params...])" + print("BuildCb.Run(<ARCADIA_ROOT> <archiver> <mninfo> <mnname> <cppOutput> [params...])", file=sys.stderr) sys.exit(1) self.SrcRoot = argv[0] @@ -64,7 +65,7 @@ def build_cb_f(argv): if __name__ == '__main__': if len(sys.argv) < 2: - print >> sys.stderr, "Usage: build_cb.py <funcName> <args...>" + print("Usage: build_cb.py <funcName> <args...>", file=sys.stderr) sys.exit(1) if sys.argv[2:]: diff --git a/build/scripts/clang_tidy.py b/build/scripts/clang_tidy.py index bbb223b206..c7636b8bf2 100644 --- a/build/scripts/clang_tidy.py +++ b/build/scripts/clang_tidy.py @@ -1,3 +1,4 @@ +from __future__ import print_function import argparse import json import os diff --git a/build/scripts/collect_java_srcs.py b/build/scripts/collect_java_srcs.py deleted file mode 100644 index f361f271d1..0000000000 --- a/build/scripts/collect_java_srcs.py +++ /dev/null @@ -1,51 +0,0 @@ -import os -import sys -import contextlib -import tarfile -import zipfile - - -if __name__ == '__main__': - build_root = sys.argv[1] - root = os.path.normpath(sys.argv[2]) - dest = os.path.normpath(sys.argv[3]) - srcs = sys.argv[4:] - - for src in srcs: - src = os.path.normpath(src) - if src.endswith('.java') or src.endswith('.kt'): - src_rel_path = os.path.relpath(src, root) - - if os.path.join(root, src_rel_path) == src: - # Inside root - dst = os.path.join(dest, src_rel_path) - - else: - # Outside root - print('External src file "{}" is outside of srcdir {}, ignore'.format( - os.path.relpath(src, build_root), - os.path.relpath(root, build_root), - ) - continue - - if os.path.exists(dst): - print >> sys.stderr, 'Duplicate external src file {}, choice is undefined'.format( - os.path.relpath(dst, root) - ) - - else: - destdir = os.path.dirname(dst) - if destdir and not os.path.exists(destdir): - os.makedirs(destdir) - os.rename(src, dst) - - elif src.endswith('.jsr'): - with contextlib.closing(tarfile.open(src, 'r')) as tf: - tf.extractall(dst) - - elif src.endswith('-sources.jar'): - with zipfile.ZipFile(src) as zf: - zf.extractall(dst) - - else: - print >> sys.stderr, 'Unrecognized file type', os.path.relpath(src, build_root) diff --git a/build/scripts/compile_cuda.py b/build/scripts/compile_cuda.py index 9660300069..8e08d17ad2 100644 --- a/build/scripts/compile_cuda.py +++ b/build/scripts/compile_cuda.py @@ -1,3 +1,4 @@ +from __future__ import print_function import sys import subprocess import os @@ -60,7 +61,7 @@ def main(): executable = command[0] if not os.path.exists(executable): - print >> sys.stderr, '{} not found'.format(executable) + print('{} not found'.format(executable), file=sys.stderr) sys.exit(1) if is_clang(command): diff --git a/build/scripts/configure_file.py b/build/scripts/configure_file.py index 5ab7467391..257593dc9b 100755 --- a/build/scripts/configure_file.py +++ b/build/scripts/configure_file.py @@ -1,5 +1,6 @@ #!/usr/bin/env python2.7 +from __future__ import print_function import sys import os.path import re diff --git a/build/scripts/coverage-info.py b/build/scripts/coverage-info.py index ddc5f275f8..114e8f4b03 100644 --- a/build/scripts/coverage-info.py +++ b/build/scripts/coverage-info.py @@ -1,3 +1,4 @@ +from __future__ import print_function import argparse import os import sys @@ -72,12 +73,12 @@ def print_stat(da, fnda, teamcity_stat_output): func_total = len(fnda.values()) func_coverage = 100.0 * func_hit / func_total if func_total else 0 - print >> sys.stderr, '[[imp]]Lines[[rst]] {: >16} {: >16} {: >16.1f}%'.format( + print('[[imp]]Lines[[rst]] {: >16} {: >16} {: >16.1f}%'.format( lines_hit, lines_total, lines_coverage - ) - print >> sys.stderr, '[[imp]]Functions[[rst]] {: >16} {: >16} {: >16.1f}%'.format( + ), file=sys.stderr) + print('[[imp]]Functions[[rst]] {: >16} {: >16} {: >16.1f}%'.format( func_hit, func_total, func_coverage - ) + ), file=sys.stderr) if teamcity_stat_output: with open(teamcity_stat_output, 'w') as tc_file: @@ -119,7 +120,7 @@ def combine_info_files(lcov, files, out_file): for trace in chunk: assert os.path.exists(trace), "Trace file does not exist: {} (cwd={})".format(trace, os.getcwd()) combine_cmd += ["-a", os.path.abspath(trace)] - print >> sys.stderr, '## lcov', ' '.join(combine_cmd[1:]) + print('## lcov', ' '.join(combine_cmd[1:]), file=sys.stderr) out_file_tmp = "combined.tmp" with open(out_file_tmp, "w") as stdout: subprocess.check_call(combine_cmd, stdout=stdout) @@ -157,7 +158,7 @@ def update_stat_global(src_file, line, fnda, da): def gen_info_global(cmd, cov_info, probe_path, update_stat, lcov_args): - print >> sys.stderr, '## geninfo', ' '.join(cmd) + print('## geninfo', ' '.join(cmd), file=sys.stderr) subprocess.check_call(cmd) if recast(cov_info + '.tmp', cov_info, probe_path, update_stat): lcov_args.append(cov_info) @@ -297,7 +298,7 @@ def main( output_dir, output_trace, ] - print >> sys.stderr, '## genhtml', ' '.join(cmd) + print('## genhtml', ' '.join(cmd), file=sys.stderr) subprocess.check_call(cmd) if lcov_cobertura: gen_cobertura(lcov_cobertura, gcov_report, output_trace) diff --git a/build/scripts/create_jcoverage_report.py b/build/scripts/create_jcoverage_report.py index f24827d8ae..0dd75bb0a8 100644 --- a/build/scripts/create_jcoverage_report.py +++ b/build/scripts/create_jcoverage_report.py @@ -1,3 +1,4 @@ +from __future__ import print_function import argparse import tarfile import zipfile @@ -77,12 +78,12 @@ def main( else: continue - entry.filename = entry.filename.encode('utf-8') + entry.filename = entry.filename jf.extract(entry, dest) timer.step("Jar files extracted") if not agent_disposition: - print >> sys.stderr, 'Can\'t find jacoco agent. Will not generate html report for java coverage.' + print('Can\'t find jacoco agent. Will not generate html report for java coverage.', file=sys.stderr) if tar_output: report_dir = 'java.report.temp' diff --git a/build/scripts/custom_link_green_mysql.py b/build/scripts/custom_link_green_mysql.py index f754135b8f..1ebff0adf7 100644 --- a/build/scripts/custom_link_green_mysql.py +++ b/build/scripts/custom_link_green_mysql.py @@ -1,3 +1,4 @@ +from __future__ import print_function import os import shutil import subprocess @@ -91,7 +92,7 @@ def main(): name = os.path.basename(sys.argv[0]) command = ' '.join(args) message = '{name} failed: {error}\nCommand line: {command}' - print >> sys.stderr, message.format(**locals()) + print(message.format(**locals()), file=sys.stderr) if __name__ == '__main__': diff --git a/build/scripts/decimal_md5.py b/build/scripts/decimal_md5.py index 684d39e767..2a125cca60 100644 --- a/build/scripts/decimal_md5.py +++ b/build/scripts/decimal_md5.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- +from __future__ import print_function import hashlib import struct import sys @@ -20,9 +21,9 @@ def ensure_paths_exist(paths): if not os.path.exists(path) ) if bad_paths: - print >> sys.stderr, "decimal_md5 inputs do not exist:" + print("decimal_md5 inputs do not exist:", file=sys.stderr) for path in bad_paths: - print >> sys.stderr, path + print(path, file=sys.stderr) sys.exit(1) diff --git a/build/scripts/error.py b/build/scripts/error.py index 9911ee7cc1..0681e48679 100644 --- a/build/scripts/error.py +++ b/build/scripts/error.py @@ -63,14 +63,17 @@ def is_temporary_error(exc): logger.debug("Getaddrinfo exception: %s", exc) return True - import urllib2 + try: + import urllib2 + import httplib + except ImportError: + import urllib.request as urllib2 + import http.client as httplib if isinstance(exc, urllib2.HTTPError) and exc.code in (429,): logger.debug("urllib2.HTTPError: %s", exc) return True - import httplib - if isinstance(exc, httplib.IncompleteRead): logger.debug("IncompleteRead exception: %s", exc) return True diff --git a/build/scripts/f2c.py b/build/scripts/f2c.py index 878580e4d4..fc1c1d0f8a 100644 --- a/build/scripts/f2c.py +++ b/build/scripts/f2c.py @@ -1,3 +1,4 @@ +from __future__ import print_function import sys import subprocess import argparse @@ -49,11 +50,11 @@ if __name__ == '__main__': ret = p.wait() if ret: - print >> sys.stderr, 'f2c failed: %s, %s' % (stderr, ret) + print('f2c failed: %s, %s' % (stderr, ret), file=sys.stderr) sys.exit(ret) if 'Error' in stderr: - print >> sys.stderr, stderr + print(stderr, file=sys.stderr) with open(args.output, 'w') as f: f.write(header) diff --git a/build/scripts/fetch_from.py b/build/scripts/fetch_from.py index ca3e7b3684..bd27d75d8e 100755 --- a/build/scripts/fetch_from.py +++ b/build/scripts/fetch_from.py @@ -1,3 +1,5 @@ +from __future__ import print_function + import datetime as dt import errno import hashlib @@ -11,7 +13,15 @@ import socket import string import sys import tarfile -import urllib2 + +try: + # Python 2 + import urllib2 as urllib_request + from urllib2 import HTTPError, URLError +except (ImportError, ModuleNotFoundError): + # Python 3 + import urllib.request as urllib_request + from urllib.error import HTTPError, URLError import retry @@ -122,12 +132,12 @@ def setup_logging(args, base_name): def is_temporary(e): def is_broken(e): - return isinstance(e, urllib2.HTTPError) and e.code in (410, 404) + return isinstance(e, HTTPError) and e.code in (410, 404) if is_broken(e): return False - if isinstance(e, (BadChecksumFetchError, IncompleteFetchError, urllib2.URLError, socket.error)): + if isinstance(e, (BadChecksumFetchError, IncompleteFetchError, URLError, socket.error)): return True import error @@ -147,7 +157,7 @@ def report_to_snowden(value): 'value': json.dumps(value), } - urllib2.urlopen( + urllib_request.urlopen( 'https://back-snowden.qloud.yandex-team.ru/report/add', json.dumps( [ @@ -198,8 +208,8 @@ def git_like_hash_with_size(filepath): file_size += len(block) sha.update(block) - sha.update('\0') - sha.update(str(file_size)) + sha.update(b'\0') + sha.update(str(file_size).encode('utf-8')) return sha.hexdigest(), file_size @@ -213,9 +223,9 @@ def size_printer(display_name, size): now = dt.datetime.now() if last_stamp[0] + dt.timedelta(seconds=10) < now: if size: - print >> sys.stderr, "##status##{} - [[imp]]{:.1f}%[[rst]]".format( + print("##status##{} - [[imp]]{:.1f}%[[rst]]".format( display_name, 100.0 * sz[0] / size if size else 0 - ) + ), file=sys.stderr) last_stamp[0] = now return printer @@ -225,9 +235,9 @@ def fetch_url(url, unpack, resource_file_name, expected_md5=None, expected_sha1= logging.info('Downloading from url %s name %s and expected md5 %s', url, resource_file_name, expected_md5) tmp_file_name = uniq_string_generator() - request = urllib2.Request(url, headers={'User-Agent': make_user_agent()}) - req = retry.retry_func(lambda: urllib2.urlopen(request, timeout=30), tries=tries, delay=5, backoff=1.57079) - logging.debug('Headers: %s', req.headers.headers) + request = urllib_request.Request(url, headers={'User-Agent': make_user_agent()}) + req = retry.retry_func(lambda: urllib_request.urlopen(request, timeout=30), tries=tries, delay=5, backoff=1.57079) + logging.debug('Headers: %s', req.headers) expected_file_size = int(req.headers.get('Content-Length', 0)) real_md5 = hashlib.md5() real_sha1 = hashlib.sha1() @@ -244,8 +254,8 @@ def fetch_url(url, unpack, resource_file_name, expected_md5=None, expected_sha1= real_md5 = real_md5.hexdigest() real_file_size = os.path.getsize(tmp_file_name) - real_sha1.update('\0') - real_sha1.update(str(real_file_size)) + real_sha1.update(b'\0') + real_sha1.update(str(real_file_size).encode('utf-8')) real_sha1 = real_sha1.hexdigest() if unpack: diff --git a/build/scripts/fetch_from_archive.py b/build/scripts/fetch_from_archive.py index e7bbe23362..3214b78dc8 100644 --- a/build/scripts/fetch_from_archive.py +++ b/build/scripts/fetch_from_archive.py @@ -1,3 +1,4 @@ +from __future__ import print_function import os import sys import logging @@ -30,7 +31,7 @@ if __name__ == '__main__': main(args) except Exception as e: logging.exception(e) - print >> sys.stderr, open(args.abs_log_path).read() + print(open(args.abs_log_path).read(), file=sys.stderr) sys.stderr.flush() import error diff --git a/build/scripts/fetch_from_mds.py b/build/scripts/fetch_from_mds.py index 3fd264ebb1..559cf8350d 100644 --- a/build/scripts/fetch_from_mds.py +++ b/build/scripts/fetch_from_mds.py @@ -1,3 +1,6 @@ +from __future__ import print_function +from __future__ import print_function + import os import sys import logging @@ -43,7 +46,7 @@ if __name__ == '__main__': main(args) except Exception as e: logging.exception(e) - print >> sys.stderr, open(args.abs_log_path).read() + print(open(args.abs_log_path).read(), file=sys.stderr) sys.stderr.flush() import error diff --git a/build/scripts/fetch_from_npm.py b/build/scripts/fetch_from_npm.py index 3941b59d43..d8f0c41f26 100644 --- a/build/scripts/fetch_from_npm.py +++ b/build/scripts/fetch_from_npm.py @@ -1,3 +1,5 @@ +from __future__ import print_function +from future.utils import raise_ import os import sys import time @@ -66,7 +68,7 @@ def fetch(tarball_url, sky_id, integrity, integrity_algorithm, file_name, tries= time.sleep(i) if exc_info: - raise exc_info[0], exc_info[1], exc_info[2] + raise_(exc_info[0], exc_info[1], exc_info[2]) return fetched_file @@ -104,7 +106,7 @@ if __name__ == "__main__": main(args) except Exception as e: logging.exception(e) - print >>sys.stderr, open(args.abs_log_path).read() + print(open(args.abs_log_path).read(), file=sys.stderr) sys.stderr.flush() import error diff --git a/build/scripts/fetch_from_sandbox.py b/build/scripts/fetch_from_sandbox.py index 6af180b4b0..a8f0fc5997 100755 --- a/build/scripts/fetch_from_sandbox.py +++ b/build/scripts/fetch_from_sandbox.py @@ -1,3 +1,4 @@ +from __future__ import print_function import itertools import json import logging @@ -210,7 +211,10 @@ def fetch(resource_id, custom_fetcher): time.sleep(i) else: if exc_info: - raise exc_info[0], exc_info[1], exc_info[2] + if sys.version_info[0] == 2: + raise exc_info[0], exc_info[1], exc_info[2] + else: + raise exc_info[1].with_traceback(exc_info[2]) else: raise Exception("No available protocol and/or server to fetch resource") @@ -265,7 +269,7 @@ if __name__ == '__main__': main(args) except Exception as e: logging.exception(e) - print >>sys.stderr, open(args.abs_log_path).read() + print(open(args.abs_log_path).read(), file=sys.stderr) sys.stderr.flush() import error diff --git a/build/scripts/gen_java_codenav_entry.py b/build/scripts/gen_java_codenav_entry.py index 2959dc4843..0429fc5398 100644 --- a/build/scripts/gen_java_codenav_entry.py +++ b/build/scripts/gen_java_codenav_entry.py @@ -1,3 +1,4 @@ +from __future__ import print_function import argparse import datetime import os @@ -20,23 +21,23 @@ def just_do_it(java, kythe, kythe_to_proto, out_name, binding_only, kindexes): open(temp_out_name, 'w').close() start = datetime.datetime.now() for kindex in kindex_inputs: - print >> sys.stderr, '[INFO] Processing:', kindex + print('[INFO] Processing:', kindex, file=sys.stderr) indexer_start = datetime.datetime.now() p = subprocess.Popen( [java, '-jar', os.path.join(kythe, 'indexers/java_indexer.jar'), kindex], stdout=subprocess.PIPE ) indexer_out, _ = p.communicate() - print >> sys.stderr, '[INFO] Indexer execution time:', ( + print('[INFO] Indexer execution time:', ( datetime.datetime.now() - indexer_start - ).total_seconds(), 'seconds' + ).total_seconds(), 'seconds', file=sys.stderr) if p.returncode: raise Exception('java_indexer failed with exit code {}'.format(p.returncode)) dedup_start = datetime.datetime.now() p = subprocess.Popen([os.path.join(kythe, 'tools/dedup_stream')], stdin=subprocess.PIPE, stdout=subprocess.PIPE) dedup_out, _ = p.communicate(indexer_out) - print >> sys.stderr, '[INFO] Dedup execution time:', ( + print('[INFO] Dedup execution time:', ( datetime.datetime.now() - dedup_start - ).total_seconds(), 'seconds' + ).total_seconds(), 'seconds', file=sys.stderr) if p.returncode: raise Exception('dedup_stream failed with exit code {}'.format(p.returncode)) entrystream_start = datetime.datetime.now() @@ -48,18 +49,18 @@ def just_do_it(java, kythe, kythe_to_proto, out_name, binding_only, kindexes): p.communicate(dedup_out) if p.returncode: raise Exception('entrystream failed with exit code {}'.format(p.returncode)) - print >> sys.stderr, '[INFO] Entrystream execution time:', ( + print('[INFO] Entrystream execution time:', ( datetime.datetime.now() - entrystream_start - ).total_seconds(), 'seconds' + ).total_seconds(), 'seconds', file=sys.stderr) preprocess_start = datetime.datetime.now() subprocess.check_call( [kythe_to_proto, '--preprocess-entry', '--entries', temp_out_name, '--out', out_name] + (['--only-binding-data'] if binding_only else []) ) - print >> sys.stderr, '[INFO] Preprocessing execution time:', ( + print('[INFO] Preprocessing execution time:', ( datetime.datetime.now() - preprocess_start - ).total_seconds(), 'seconds' - print >> sys.stderr, '[INFO] Total execution time:', (datetime.datetime.now() - start).total_seconds(), 'seconds' + ).total_seconds(), 'seconds', file=sys.stderr) + print('[INFO] Total execution time:', (datetime.datetime.now() - start).total_seconds(), 'seconds', file=sys.stderr) if __name__ == '__main__': diff --git a/build/scripts/gen_py3_reg.py b/build/scripts/gen_py3_reg.py index ff6bf0de56..ee6c6baf9b 100644 --- a/build/scripts/gen_py3_reg.py +++ b/build/scripts/gen_py3_reg.py @@ -1,3 +1,4 @@ +from __future__ import print_function import sys template = ''' @@ -24,8 +25,8 @@ def mangle(name): if __name__ == '__main__': if len(sys.argv) != 3: - print >> sys.stderr, 'Usage: <path/to/gen_py_reg.py> <python_module_name> <output_file>' - print >> sys.stderr, 'Passed: ' + ' '.join(sys.argv) + print('Usage: <path/to/gen_py_reg.py> <python_module_name> <output_file>', file=sys.stderr) + print('Passed: ' + ' '.join(sys.argv), file=sys.stderr) sys.exit(1) with open(sys.argv[2], 'w') as f: diff --git a/build/scripts/gen_py_reg.py b/build/scripts/gen_py_reg.py index 0f38dfffe3..be52418964 100644 --- a/build/scripts/gen_py_reg.py +++ b/build/scripts/gen_py_reg.py @@ -1,3 +1,4 @@ +from __future__ import print_function import sys template = ''' @@ -22,8 +23,8 @@ def mangle(name): if __name__ == '__main__': if len(sys.argv) != 3: - print >> sys.stderr, 'Usage: <path/to/gen_py_reg.py> <python_module_name> <output_file>' - print >> sys.stderr, 'Passed: ' + ' '.join(sys.argv) + print('Usage: <path/to/gen_py_reg.py> <python_module_name> <output_file>', file=sys.stderr) + print('Passed: ' + ' '.join(sys.argv), file=sys.stderr) sys.exit(1) with open(sys.argv[2], 'w') as f: diff --git a/build/scripts/ios_wrapper.py b/build/scripts/ios_wrapper.py index eeb0a78d26..f8bdcce0a2 100644 --- a/build/scripts/ios_wrapper.py +++ b/build/scripts/ios_wrapper.py @@ -1,3 +1,4 @@ +from __future__ import print_function import errno import json import os @@ -49,13 +50,13 @@ def just_do_it(args): elif i.endswith('.strings_tar'): strings.append(i) else: - print >> sys.stderr, 'Unknown input:', i, 'ignoring' + print('Unknown input:', i, 'ignoring', file=sys.stderr) if not plists: raise Exception("Can't find plist files") if not plists[0].endswith('.plist'): - print >> sys.stderr, "Main plist file can be defined incorretly" + print("Main plist file can be defined incorretly", file=sys.stderr) if not storyboards: - print >> sys.stderr, "Storyboards list are empty" + print("Storyboards list are empty", file=sys.stderr) if len(signs) > 1: raise Exception("Too many .xcent files") app_dir = os.path.join(module_dir, app_name + '.app') diff --git a/build/scripts/link_dyn_lib.py b/build/scripts/link_dyn_lib.py index 72937544b6..3e62f4c407 100644 --- a/build/scripts/link_dyn_lib.py +++ b/build/scripts/link_dyn_lib.py @@ -1,3 +1,4 @@ +from __future__ import print_function import sys import os import subprocess @@ -264,8 +265,8 @@ if __name__ == '__main__': thinlto_cache.postprocess(opts) if proc.returncode: - print >> sys.stderr, 'linker has failed with retcode:', proc.returncode - print >> sys.stderr, 'linker command:', shlex_join(cmd) + print('linker has failed with retcode:', proc.returncode, file=sys.stderr) + print('linker command:', shlex_join(cmd), file=sys.stderr) sys.exit(proc.returncode) if opts.fix_elf: @@ -274,8 +275,8 @@ if __name__ == '__main__': proc.communicate() if proc.returncode: - print >> sys.stderr, 'fix_elf has failed with retcode:', proc.returncode - print >> sys.stderr, 'fix_elf command:', shlex_join(cmd) + print('fix_elf has failed with retcode:', proc.returncode, file=sys.stderr) + print('fix_elf command:', shlex_join(cmd), file=sys.stderr) sys.exit(proc.returncode) if opts.soname and opts.soname != opts.target: diff --git a/build/scripts/list.py b/build/scripts/list.py index 7c3b2ae695..5c8390c52c 100644 --- a/build/scripts/list.py +++ b/build/scripts/list.py @@ -1,4 +1,5 @@ -import sys
-
-if __name__ == "__main__":
- print(' '.join(sys.argv[1:]))
+from __future__ import print_function +import sys + +if __name__ == "__main__": + print(' '.join(sys.argv[1:])) diff --git a/build/scripts/mkver.py b/build/scripts/mkver.py index 7bdbb88514..2101032770 100755 --- a/build/scripts/mkver.py +++ b/build/scripts/mkver.py @@ -1,3 +1,4 @@ +from __future__ import print_function import sys if __name__ == '__main__': diff --git a/build/scripts/pack_ios.py b/build/scripts/pack_ios.py index 350220be7b..3ecd18f188 100644 --- a/build/scripts/pack_ios.py +++ b/build/scripts/pack_ios.py @@ -1,3 +1,4 @@ +from __future__ import print_function import argparse import os import shutil @@ -15,7 +16,7 @@ def just_do_it(): args = parser.parse_args() app_tar = [p for p in args.peers if p.endswith('.ios.interface')] if not app_tar: - print >> sys.stderr, 'No one IOS_INTERFACE module found' + print('No one IOS_INTERFACE module found', file=sys.stderr) shutil.copyfile(args.binary, os.path.join(args.temp_dir, 'bin')) if os.path.exists(args.target): os.remove(args.target) @@ -27,7 +28,7 @@ def just_do_it(): if len(app_tar) > 1: app_tar = [p for p in args.peers if not p.endswith('.default.ios.interface')] if len(app_tar) > 1: - print >> sys.stderr, 'Many IOS_INTERFACE modules found, {} will be used'.format(app_tar[-1]) + print('Many IOS_INTERFACE modules found, {} will be used'.format(app_tar[-1]), file=sys.stderr) app_tar = app_tar[-1] with tarfile.open(app_tar) as tf: tf.extractall(args.temp_dir) diff --git a/build/scripts/pack_jcoverage_resources.py b/build/scripts/pack_jcoverage_resources.py index 5881d90153..6ed3b1320d 100644 --- a/build/scripts/pack_jcoverage_resources.py +++ b/build/scripts/pack_jcoverage_resources.py @@ -1,3 +1,4 @@ +from __future__ import print_function import sys import tarfile import os @@ -11,7 +12,7 @@ def main(args): res = subprocess.call(args[args.index('-end') + 1 :]) if not os.path.exists(report_file): - print >> sys.stderr, 'Can\'t find jacoco exec file' + print('Can\'t find jacoco exec file', file=sys.stderr) return res with tarfile.open(output_file, 'w') as outf: diff --git a/build/scripts/python_yndexer.py b/build/scripts/python_yndexer.py index 3180665387..276ed20a27 100644 --- a/build/scripts/python_yndexer.py +++ b/build/scripts/python_yndexer.py @@ -1,3 +1,4 @@ +from __future__ import print_function import os import sys import threading @@ -49,5 +50,5 @@ if __name__ == '__main__': result = process.wait(timeout=timeout) if result != 0: - print >> sys.stderr, 'Yndexing process finished with code', result + print('Yndexing process finished with code', result, file=sys.stderr) touch(output_file) diff --git a/build/scripts/run_ios_simulator.py b/build/scripts/run_ios_simulator.py index b69ef81ccb..576ef9cee3 100644 --- a/build/scripts/run_ios_simulator.py +++ b/build/scripts/run_ios_simulator.py @@ -1,3 +1,4 @@ +from __future__ import print_function import argparse import json import os @@ -55,7 +56,7 @@ def action_spawn(simctl, profiles, device_dir, name, args): def action_kill(simctl, profiles, device_dir, name): device = filter(lambda x: x["name"] == name, get_all_devices(simctl, profiles, device_dir)) if not device: - print >> sys.stderr, "Device named {} not found; do nothing".format(name) + print("Device named {} not found; do nothing".format(name), file=sys.stderr) return if len(device) > 1: raise Exception("Can't remove: too many devices named {}:\n{}".format(name, '\n'.join(i for i in device))) diff --git a/build/scripts/run_msvc_wine.py b/build/scripts/run_msvc_wine.py index 38ffa1ffb0..3a498d7388 100644 --- a/build/scripts/run_msvc_wine.py +++ b/build/scripts/run_msvc_wine.py @@ -1,3 +1,4 @@ +from __future__ import print_function import sys import os import re @@ -41,7 +42,7 @@ def run_subprocess_with_timeout(timeout, args): stdout, stderr = p.communicate(timeout=timeout) return p, stdout, stderr except subprocess.TimeoutExpired as e: - print >> sys.stderr, 'timeout running {0}, error {1}, delay {2} seconds'.format(args, str(e), delay) + print('timeout running {0}, error {1}, delay {2} seconds'.format(args, str(e), delay), file=sys.stderr) if p is not None: try: p.kill() @@ -93,7 +94,7 @@ def call_wine_cmd_once(wine, cmd, env, mode): error = e if error is not None: - print >> sys.stderr, 'Output {} already exists and we have failed to remove it: {}'.format(output, error) + print('Output {} already exists and we have failed to remove it: {}'.format(output, error), file=sys.stderr) # print >>sys.stderr, cmd, env, wine @@ -164,7 +165,7 @@ def call_wine_cmd_once(wine, cmd, env, mode): stdout_and_stderr = '\n'.join(filter_lines()).strip() if stdout_and_stderr: - print >> sys.stderr, stdout_and_stderr + print(stdout_and_stderr, file=sys.stderr) return return_code @@ -175,7 +176,7 @@ def prepare_vc(fr, to): to_p = os.path.join(to, p) if not os.path.exists(to_p): - print >> sys.stderr, 'install %s -> %s' % (fr_p, to_p) + print('install %s -> %s' % (fr_p, to_p), file=sys.stderr) os.link(fr_p, to_p) @@ -196,7 +197,7 @@ def run_slave(): try: return call_wine_cmd_once([wine], args['cmd'], args['env'], args['mode']) except Exception as e: - print >> sys.stderr, '%s, will retry in %s' % (str(e), tout) + print('%s, will retry in %s' % (str(e), tout), file=sys.stderr) time.sleep(tout) tout = min(2 * tout, 4) @@ -508,7 +509,7 @@ def run_main(): return if mode == 'cxx': log = colorize(log) - print >> sys.stderr, log + print(log, file=sys.stderr) tout = 200 @@ -517,26 +518,26 @@ def run_main(): if rc in (-signal.SIGALRM, signal.SIGALRM): print_err_log(out) - print >> sys.stderr, '##append_tag##time out' + print('##append_tag##time out', file=sys.stderr) elif out and ' stack overflow ' in out: - print >> sys.stderr, '##append_tag##stack overflow' + print('##append_tag##stack overflow', file=sys.stderr) elif out and 'recvmsg: Connection reset by peer' in out: - print >> sys.stderr, '##append_tag##wine gone' + print('##append_tag##wine gone', file=sys.stderr) elif out and 'D8037' in out: - print >> sys.stderr, '##append_tag##repair wine' + print('##append_tag##repair wine', file=sys.stderr) try: os.unlink(os.path.join(os.environ['WINEPREFIX'], '.update-timestamp')) except Exception as e: - print >> sys.stderr, e + print(e, file=sys.stderr) else: print_err_log(out) # non-zero return code - bad, return it immediately if rc: - print >> sys.stderr, '##win_cmd##' + ' '.join(cmd) - print >> sys.stderr, '##args##' + ' '.join(free_args) + print('##win_cmd##' + ' '.join(cmd), file=sys.stderr) + print('##args##' + ' '.join(free_args), file=sys.stderr) return rc # check for output existence(if we expect it!) and real length @@ -545,7 +546,7 @@ def run_main(): return 0 else: # retry! - print >> sys.stderr, '##append_tag##no output' + print('##append_tag##no output', file=sys.stderr) else: return 0 @@ -575,7 +576,7 @@ def main(): except KeyboardInterrupt: sys.exit(4) except Exception as e: - print >> sys.stderr, str(e) + print(str(e), file=sys.stderr) sys.exit(3) diff --git a/build/scripts/symlink.py b/build/scripts/symlink.py index 9636bf3929..a19891df40 100755 --- a/build/scripts/symlink.py +++ b/build/scripts/symlink.py @@ -1,5 +1,6 @@ #!/usr/bin/env python +from __future__ import print_function import sys import os import platform @@ -8,7 +9,7 @@ from subprocess import call def symlink(): if len(sys.argv) < 3: - print >> sys.stderr, "Usage: symlink.py <source> <target>" + print("Usage: symlink.py <source> <target>", file=sys.stderr) sys.exit(1) source = sys.argv[1] diff --git a/build/scripts/with_crash_on_timeout.py b/build/scripts/with_crash_on_timeout.py index bde864ed29..915ed51c51 100644 --- a/build/scripts/with_crash_on_timeout.py +++ b/build/scripts/with_crash_on_timeout.py @@ -1,3 +1,4 @@ +from __future__ import print_function # TODO prettyboy remove after ya-bin release import os @@ -13,7 +14,7 @@ def main(args): with open(meta_path) as f: meta_info = json.loads(f.read()) if meta_info["exit_code"] == timeout_code: - print >> sys.stderr, meta_info["project"], 'crashed by timeout, use --test-disable-timeout option' + print(meta_info["project"], 'crashed by timeout, use --test-disable-timeout option', file=sys.stderr) return 1 return 0 diff --git a/build/scripts/yndexer.py b/build/scripts/yndexer.py index c8127de711..4e766e0fc8 100644 --- a/build/scripts/yndexer.py +++ b/build/scripts/yndexer.py @@ -1,3 +1,4 @@ +from __future__ import print_function import sys import subprocess import threading @@ -86,5 +87,5 @@ if __name__ == '__main__': result = process.wait(timeout=timeout) if result != 0: - print >> sys.stderr, 'Yndexing process finished with code', result + print('Yndexing process finished with code', result, file=sys.stderr) touch(output_file) |