perfetto: switch to os.replace instead of os.rename for tools

On Windows, os.rename throws an error instead of overwriting the
destination. Use os.replace instead.

Fixes: https://github.com/google/perfetto/issues/338
Change-Id: I479a20eded1fbc0e293231f6fb7f7d1cb2307dd0
diff --git a/python/perfetto/prebuilts/perfetto_prebuilts.py b/python/perfetto/prebuilts/perfetto_prebuilts.py
index 051d0b6..087a337 100644
--- a/python/perfetto/prebuilts/perfetto_prebuilts.py
+++ b/python/perfetto/prebuilts/perfetto_prebuilts.py
@@ -81,7 +81,7 @@
       raise Exception('Checksum mismatch for %s (actual: %s, expected: %s)' %
                       (url, actual_sha256, sha256))
     os.chmod(tmp_path, 0o755)
-    os.rename(tmp_path, bin_path)
+    os.replace(tmp_path, bin_path)
     with open(sha256_path, 'w') as f:
       f.write(sha256)
   return bin_path
diff --git a/python/perfetto/trace_processor/trace_processor.descriptor b/python/perfetto/trace_processor/trace_processor.descriptor
index 5a2329c..b2b0cd2 100644
--- a/python/perfetto/trace_processor/trace_processor.descriptor
+++ b/python/perfetto/trace_processor/trace_processor.descriptor
Binary files differ
diff --git a/tools/cpu_profile b/tools/cpu_profile
index 42969c3..b34b8b3 100755
--- a/tools/cpu_profile
+++ b/tools/cpu_profile
@@ -254,7 +254,7 @@
       raise Exception('Checksum mismatch for %s (actual: %s, expected: %s)' %
                       (url, actual_sha256, sha256))
     os.chmod(tmp_path, 0o755)
-    os.rename(tmp_path, bin_path)
+    os.replace(tmp_path, bin_path)
     with open(sha256_path, 'w') as f:
       f.write(sha256)
   return bin_path
diff --git a/tools/heap_profile b/tools/heap_profile
index df638a5..ece07de 100755
--- a/tools/heap_profile
+++ b/tools/heap_profile
@@ -251,7 +251,7 @@
       raise Exception('Checksum mismatch for %s (actual: %s, expected: %s)' %
                       (url, actual_sha256, sha256))
     os.chmod(tmp_path, 0o755)
-    os.rename(tmp_path, bin_path)
+    os.replace(tmp_path, bin_path)
     with open(sha256_path, 'w') as f:
       f.write(sha256)
   return bin_path
diff --git a/tools/record_android_trace b/tools/record_android_trace
index c6182fc..d7fc7ee 100755
--- a/tools/record_android_trace
+++ b/tools/record_android_trace
@@ -236,7 +236,7 @@
       raise Exception('Checksum mismatch for %s (actual: %s, expected: %s)' %
                       (url, actual_sha256, sha256))
     os.chmod(tmp_path, 0o755)
-    os.rename(tmp_path, bin_path)
+    os.replace(tmp_path, bin_path)
     with open(sha256_path, 'w') as f:
       f.write(sha256)
   return bin_path
diff --git a/tools/trace_processor b/tools/trace_processor
index 712b1d8..7d940c5 100755
--- a/tools/trace_processor
+++ b/tools/trace_processor
@@ -247,7 +247,7 @@
       raise Exception('Checksum mismatch for %s (actual: %s, expected: %s)' %
                       (url, actual_sha256, sha256))
     os.chmod(tmp_path, 0o755)
-    os.rename(tmp_path, bin_path)
+    os.replace(tmp_path, bin_path)
     with open(sha256_path, 'w') as f:
       f.write(sha256)
   return bin_path
diff --git a/tools/tracebox b/tools/tracebox
index c989248..eb6a184 100755
--- a/tools/tracebox
+++ b/tools/tracebox
@@ -233,7 +233,7 @@
       raise Exception('Checksum mismatch for %s (actual: %s, expected: %s)' %
                       (url, actual_sha256, sha256))
     os.chmod(tmp_path, 0o755)
-    os.rename(tmp_path, bin_path)
+    os.replace(tmp_path, bin_path)
     with open(sha256_path, 'w') as f:
       f.write(sha256)
   return bin_path
diff --git a/tools/traceconv b/tools/traceconv
index ef58c0b..c0b2f0a 100755
--- a/tools/traceconv
+++ b/tools/traceconv
@@ -247,7 +247,7 @@
       raise Exception('Checksum mismatch for %s (actual: %s, expected: %s)' %
                       (url, actual_sha256, sha256))
     os.chmod(tmp_path, 0o755)
-    os.rename(tmp_path, bin_path)
+    os.replace(tmp_path, bin_path)
     with open(sha256_path, 'w') as f:
       f.write(sha256)
   return bin_path