This is an automated email from the ASF dual-hosted git repository. nicknezis pushed a commit to branch nicknezis/bazel-2 in repository https://gitbox.apache.org/repos/asf/incubator-heron.git
commit 885aea03f38907eb631fa6a6022d0a7a1864ed09 Author: Nicholas Nezis <[email protected]> AuthorDate: Tue Apr 7 03:36:30 2020 -0400 Replaces os.rename that doesn't work across device --- heron/executor/src/python/heron_executor.py | 3 ++- integration_test/src/python/local_test_runner/test_template.py | 5 +++-- tools/rules/pex/wrapper/pex_wrapper.py | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/heron/executor/src/python/heron_executor.py b/heron/executor/src/python/heron_executor.py index db8dff0..674c3fc 100755 --- a/heron/executor/src/python/heron_executor.py +++ b/heron/executor/src/python/heron_executor.py @@ -27,6 +27,7 @@ import functools import json import os import random +import shutil import signal import string import subprocess @@ -129,7 +130,7 @@ def atomic_write_file(path, content): os.fsync(f.fileno()) # Rename the tmp file - os.rename(tmp_file, path) + shutil.move(tmp_file, path) def log_pid_for_process(process_name, pid): filename = get_process_pid_filename(process_name) diff --git a/integration_test/src/python/local_test_runner/test_template.py b/integration_test/src/python/local_test_runner/test_template.py index 3ad5fa5..c779f01 100644 --- a/integration_test/src/python/local_test_runner/test_template.py +++ b/integration_test/src/python/local_test_runner/test_template.py @@ -26,10 +26,11 @@ import json import logging import os import time -from urllib.request import urlopen +import shutil import signal import subprocess from collections import namedtuple +from urllib.request import urlopen from ..common import status @@ -152,7 +153,7 @@ class TestTemplate(object): # move to read file. This guarantees contents will be put into the file the # spout is reading from atomically # which increases the determinism - os.rename('temp.txt', self.params['readFile']) + shutil.move('temp.txt', self.params['readFile']) def _check_results(self): """ get actual and expected result. diff --git a/tools/rules/pex/wrapper/pex_wrapper.py b/tools/rules/pex/wrapper/pex_wrapper.py index d93bf98..edd9ca8 100644 --- a/tools/rules/pex/wrapper/pex_wrapper.py +++ b/tools/rules/pex/wrapper/pex_wrapper.py @@ -21,6 +21,7 @@ from pex.variables import ENV import json import os +import shutil import sys @@ -115,7 +116,7 @@ def main(): tmp_name = poptions.pex_name + '~' safe_delete(tmp_name) pex_builder.build(tmp_name) - os.rename(tmp_name, poptions.pex_name) + shutil.move(tmp_name, poptions.pex_name) if __name__ == '__main__':
