generate-churning-bundle: fix script for python3 stable
authorPierre-Yves David <pierre-yves.david@octobus.net>
Sat, 18 Nov 2023 00:16:15 +0100
branchstable
changeset 51277 d7155949535e
parent 51265 85d96517e650
child 51278 6113221a1dea
child 51279 51021612aea7
generate-churning-bundle: fix script for python3 This script has apparently not run for a long time.
tests/artifacts/scripts/generate-churning-bundle.py
--- 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))