changeset 51277:d7155949535e stable

generate-churning-bundle: fix script for python3 This script has apparently not run for a long time.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sat, 18 Nov 2023 00:16:15 +0100
parents 85d96517e650
children 6113221a1dea 51021612aea7
files tests/artifacts/scripts/generate-churning-bundle.py
diffstat 1 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/tests/artifacts/scripts/generate-churning-bundle.py	Thu Dec 21 01:45:43 2023 +0100
+++ b/tests/artifacts/scripts/generate-churning-bundle.py	Sat Nov 18 00:16:15 2023 +0100
@@ -46,7 +46,7 @@
 
 def nextcontent(previous_content):
     """utility to produce a new file content from the previous one"""
-    return hashlib.md5(previous_content).hexdigest()
+    return hashlib.md5(previous_content).hexdigest().encode('ascii')
 
 
 def filecontent(iteridx, oldcontent):
@@ -57,9 +57,9 @@
 
     # initial call
     if iteridx is None:
-        current = ''
+        current = b''
     else:
-        current = str(iteridx)
+        current = b"%d" % iteridx
 
     for idx in range(NB_LINES):
         do_change_line = True
@@ -67,7 +67,7 @@
             do_change_line = not ((idx - iteridx) % OTHER_CHANGES)
 
         if do_change_line:
-            to_write = current + '\n'
+            to_write = current + b'\n'
             current = nextcontent(current)
         else:
             to_write = oldcontent[idx]
@@ -127,7 +127,7 @@
             data = bundle.read()
             digest = hashlib.md5(data).hexdigest()
         with open(target + '.md5', 'wb') as md5file:
-            md5file.write(digest + '\n')
+            md5file.write(digest.encode('ascii') + b'\n')
         if sys.stdout.isatty():
             print('bundle generated at "%s" md5: %s' % (target, digest))