aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Spickett <david.spickett@linaro.org>2021-02-25 14:30:09 +0000
committerDavid Spickett <david.spickett@linaro.org>2021-02-25 14:38:10 +0000
commitaa155bef2c5129c8e5b138dadb625728be8e8e1f (patch)
tree90b272900535d64c7771787c7aebd3d8fdb1312a
parent91688ff7ab0fe9b821db37809175639e0abc943a (diff)
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/<this repo> 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
-rwxr-xr-xmonitor/bot-status.py3
1 files changed, 2 insertions, 1 deletions
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__":