public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
* [PATCH] repro-build-test.py: Fix flake8 issues
@ 2023-01-07 11:58 venkata.pyla
  2023-01-07 16:11 ` Henning Schild
  2023-03-30  7:13 ` Uladzimir Bely
  0 siblings, 2 replies; 4+ messages in thread
From: venkata.pyla @ 2023-01-07 11:58 UTC (permalink / raw)
  To: isar-users
  Cc: venkata pyla, amikan, jan.kiszka, henning.schild,
	kazuhiro3.hayashi, dinesh.kumar

From: venkata pyla <venkata.pyla@toshiba-tsip.com>

It fixes following flake8 errors

F401 'glob' imported but unused
F401 'os' imported but unused
F401 're' imported but unused
F401 'tempfile' imported but unused
F401 'time' imported but unused
F401 'cibuilder.isar_root' imported but unused
E302 expected 2 blank lines, found 1
E501 line too long (97 > 79 characters)
E501 line too long (106 > 79 characters)
E203 whitespace before ','
E231 missing whitespace after ','
E501 line too long (91 > 79 characters)
E501 line too long (89 > 79 characters)
E501 line too long (84 > 79 characters)
E128 continuation line under-indented for visual indent
E128 continuation line under-indented for visual indent
E128 continuation line under-indented for visual indent
E203 whitespace before ','
E128 continuation line under-indented for visual indent
E251 unexpected spaces around keyword / parameter equals
E251 unexpected spaces around keyword / parameter equals

black: converts single quote strings to double quotes

Signed-off-by: venkata pyla <venkata.pyla@toshiba-tsip.com>
---
 testsuite/repro-build-test.py | 64 ++++++++++++++++++++---------------
 1 file changed, 36 insertions(+), 28 deletions(-)

diff --git a/testsuite/repro-build-test.py b/testsuite/repro-build-test.py
index e89becf..5d92e2c 100755
--- a/testsuite/repro-build-test.py
+++ b/testsuite/repro-build-test.py
@@ -1,14 +1,9 @@
 #!/usr/bin/env python3
 
-import glob
-import os
-import re
-import tempfile
-import time
-
-from cibuilder import CIBuilder, isar_root
+from cibuilder import CIBuilder
 from avocado.utils import process
 
+
 class ReproBuild(CIBuilder):
 
     """
@@ -16,29 +11,38 @@ class ReproBuild(CIBuilder):
 
     :avocado: tags=repro-build
     """
+
     def test_repro_build(self):
-        target = self.params.get('build_target', default='mc:qemuamd64-bullseye:isar-image-base')
-        source_date_epoch = self.params.get('source_date_epoch', default=self.git_last_commit_timestamp())
+        target = self.params.get(
+            "build_target", default="mc:qemuamd64-bullseye:isar-image-base"
+        )
+        source_date_epoch = self.params.get(
+            "source_date_epoch", default=self.git_last_commit_timestamp()
+        )
         self.init()
-        self.build_repro_image(target, source_date_epoch, 'image1.tar.gz')
-        self.build_repro_image(target, source_date_epoch, 'image2.tar.gz')
-        self.compare_repro_image('image1.tar.gz', 'image2.tar.gz')
+        self.build_repro_image(target, source_date_epoch, "image1.tar.gz")
+        self.build_repro_image(target, source_date_epoch, "image2.tar.gz")
+        self.compare_repro_image("image1.tar.gz", "image2.tar.gz")
 
     def git_last_commit_timestamp(self):
-        return process.run('git log -1 --pretty=%ct').stdout
+        return process.run("git log -1 --pretty=%ct").stdout.decode().strip()
 
     def get_image_path(self, target_name):
         image_dir = "tmp/deploy/images"
-        target_params = target_name.split(':')
-        machine = target_params[1].split('-')[0]
-        distro = 'debian-' + target_params[1].split('-')[1]
+        target_params = target_name.split(":")
+        machine = target_params[1].split("-")[0]
+        distro = "debian-" + target_params[1].split("-")[1]
         image_type = target_params[2]
-        return f'{image_dir}/{machine}/{image_type}-{distro}-{machine}.tar.gz'
+        return f"{image_dir}/{machine}/{image_type}-{distro}-{machine}.tar.gz"
 
-    def build_repro_image(self, target, source_date_epoch=None ,image_name='image.tar.gz'):
+    def build_repro_image(
+        self, target, source_date_epoch=None, image_name="image.tar.gz"
+    ):
 
         if not source_date_epoch:
-            self.error("Reproducible build should configure with source_date_epoch time")
+            self.error(
+             "Reproducible build should configure with source_date_epoch time"
+            )
 
         # clean artifacts before build
         self.clean()
@@ -54,15 +58,19 @@ class ReproBuild(CIBuilder):
         self.move_in_build_dir(image_path, image_name)
 
     def clean(self):
-        self.delete_from_build_dir('tmp')
-        self.delete_from_build_dir('sstate-cache')
+        self.delete_from_build_dir("tmp")
+        self.delete_from_build_dir("sstate-cache")
 
     def compare_repro_image(self, image1, image2):
-        self.log.info("Compare artifacts image1: " + image1 + ", image2: " + image2)
-        result = process.run('diffoscope '
-                        '--text ' + self.build_dir + '/diffoscope-output.txt'
-                        ' ' + self.build_dir + '/' + image1 +
-                        ' ' + self.build_dir + '/' + image2 ,
-                        ignore_status = True)
+        self.log.info(
+            "Compare artifacts image1: " + image1 + ", image2: " + image2
+        )
+        result = process.run(
+            "diffoscope "
+            "--text " + self.build_dir + "/diffoscope-output.txt"
+            " " + self.build_dir + "/" + image1 +
+            " " + self.build_dir + "/" + image2,
+            ignore_status=True,
+        )
         if result.exit_status > 0:
-            self.fail(f'Images {image1} and {image2} are not reproducible')
+            self.fail(f"Images {image1} and {image2} are not reproducible")
-- 
2.20.1



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-03-30  7:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-07 11:58 [PATCH] repro-build-test.py: Fix flake8 issues venkata.pyla
2023-01-07 16:11 ` Henning Schild
2023-01-09  7:21   ` Venkata.Pyla
2023-03-30  7:13 ` Uladzimir Bely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox