From aa155bef2c5129c8e5b138dadb625728be8e8e1f Mon Sep 17 00:00:00 2001 From: David Spickett Date: Thu, 25 Feb 2021 14:30:09 +0000 Subject: bot-status.py: Use shutil.move instead of os.rename os.rename fails if the source and destination are on different file systems. For instance my machine has /tmp and /work/ on different file systems. https://docs.python.org/3/library/os.html#os.rename shutil.move handles this for you. https: //docs.python.org/3/library/shutil.html#shutil.move Change-Id: I6cd6442413bb4a3ed5c6007a18fef327bfbc71c7 --- monitor/bot-status.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/monitor/bot-status.py b/monitor/bot-status.py index 40630e5..cf136f6 100755 --- a/monitor/bot-status.py +++ b/monitor/bot-status.py @@ -14,6 +14,7 @@ import argparse import json import tempfile import logging +import shutil from datetime import datetime, timedelta # The requests allows HTTP keep-alive which re-uses the same TCP connection # to download multiple files. @@ -198,7 +199,7 @@ def bot_status(config_file, output_file): # Move temp to main (atomic change) temp.close() - os.rename(temp.name, sys.argv[2]) + shutil.move(temp.name, sys.argv[2]) if __name__ == "__main__": -- cgit v1.2.3