From 713228ae95ca761762785b81a5d23db658cc717f Mon Sep 17 00:00:00 2001
From: Michael Vrable <vrable@cs.hmc.edu>
Date: Thu, 4 Apr 2024 21:35:07 -0700
Subject: [PATCH] Update some Python scripts to reference `python3` instead of
 `python`.

Python 2 is no longer supported upstream, so we really should default to
running Python 3 for all code here.  Update most scripts to reference that.

Most code should have already been converted to be compatible with Python 3
and no further changes were made here, except for one fix needed in
`tests/digest_tree`.  Note: Changes have not yet been much tested, so there
could possibly be bugs.

A few scripts in `contrib/` are not updated as these would need some extra
work; leave that for the future.

Python 2 compatibility code could probably be removed (the `six` module and
`__future__` imports), but also leave that for future work to keep this
commit small.
---
 cumulus-store                      | 2 +-
 cumulus-sync                       | 2 +-
 cumulus-util                       | 2 +-
 python/cumulus/rebuild_database.py | 2 +-
 python/cumulus/util_test.py        | 2 +-
 tests/digest_tree                  | 6 +++---
 tests/run-test                     | 2 +-
 7 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/cumulus-store b/cumulus-store
index 93a10d7..a22b68c 100755
--- a/cumulus-store
+++ b/cumulus-store
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
 #
 # Cumulus: Efficient Filesystem Backup to the Cloud
 # Copyright (C) 2008, 2010 The Cumulus Developers
diff --git a/cumulus-sync b/cumulus-sync
index 9f31a29..995e764 100755
--- a/cumulus-sync
+++ b/cumulus-sync
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
 #
 # Cumulus: Efficient Filesystem Backup to the Cloud
 # Copyright (C) 2008 The Cumulus Developers
diff --git a/cumulus-util b/cumulus-util
index 7233f8d..3dc4139 100755
--- a/cumulus-util
+++ b/cumulus-util
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
 #
 # Cumulus: Efficient Filesystem Backup to the Cloud
 # Copyright (C) 2012 The Cumulus Developers
diff --git a/python/cumulus/rebuild_database.py b/python/cumulus/rebuild_database.py
index 4ab580f..c8514c0 100755
--- a/python/cumulus/rebuild_database.py
+++ b/python/cumulus/rebuild_database.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
 #
 # Cumulus: Efficient Filesystem Backup to the Cloud
 # Copyright (C) 2013 The Cumulus Developers
diff --git a/python/cumulus/util_test.py b/python/cumulus/util_test.py
index e3c9059..b090338 100644
--- a/python/cumulus/util_test.py
+++ b/python/cumulus/util_test.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
 # coding: utf-8
 #
 # Cumulus: Efficient Filesystem Backup to the Cloud
diff --git a/tests/digest_tree b/tests/digest_tree
index 5882581..56e482d 100755
--- a/tests/digest_tree
+++ b/tests/digest_tree
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
 #
 # Cumulus: Efficient Filesystem Backup to the Cloud
 # Copyright (C) 2012 The Cumulus Developers
@@ -39,7 +39,7 @@ def stat_file(path):
     if stat.S_ISREG(st.st_mode):
         digest = hashlib.sha256()
         BUF_SIZE = 1 << 16
-        f = open(path, "r")
+        f = open(path, "rb")
         while True:
             buf = f.read(BUF_SIZE)
             if not buf: break
@@ -64,4 +64,4 @@ if __name__ == "__main__":
         root = "."
     os.chdir(root)
     for file in dump_tree("."):
-        print " ".join(map(str, file))
+        print(" ".join(map(str, file)))
diff --git a/tests/run-test b/tests/run-test
index 843585a..4b83903 100755
--- a/tests/run-test
+++ b/tests/run-test
@@ -35,7 +35,7 @@ TMP_DIR="$(readlink -f "$(mktemp -d cumulus-tests.XXXXXX)")"
 VALGRIND="valgrind --tool=memcheck --leak-check=full --log-file=$TMP_DIR/valgrind.log"
 
 # Python interpreter to test with.
-PYTHON="${PYTHON:-python2}"
+PYTHON="${PYTHON:-python3}"
 
 log_action() {
     echo
-- 
2.20.1