From d0c506a65d194b822f3e68cc8cb8db9a129e59dc Mon Sep 17 00:00:00 2001
From: Martin Wilck <mwilck@suse.com>
Date: Thu, 28 May 2026 11:10:55 +0200
Subject: [PATCH 1/2] hplip: replace f-strings with str.format() for old Python
 compatibility

---
 base/CdmWifi.py   |  2 +-
 base/os_utils.py  | 10 +++++-----
 ui4/scandialog.py | 12 ++++++------
 ui5/scandialog.py | 12 ++++++------
 4 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/base/CdmWifi.py b/base/CdmWifi.py
index bd817b1..8fd1641 100755
--- a/base/CdmWifi.py
+++ b/base/CdmWifi.py
@@ -95,7 +95,7 @@ def getCDMToken_pushbutton(dev):
         part4 = ''.join(random.choices(string.digits, k=4))
         part5 = ''.join(random.choices(string.digits, k=10))
         last_two_letters = ''.join(random.choices(string.ascii_lowercase, k=2))
-        random_session_id = f"{part1}-{part2}-{part3}-{part4}-{part5}{last_two_letters}"
+        random_session_id = "{0}-{1}-{2}-{3}-{4}{5}".format(part1, part2, part3, part4, part5, last_two_letters)
         log.debug("Generated random session ID: %s" % random_session_id)
 
         # Prepare and send the pushbutton request
diff --git a/base/os_utils.py b/base/os_utils.py
index 82a8b42..99ab12f 100644
--- a/base/os_utils.py
+++ b/base/os_utils.py
@@ -40,20 +40,20 @@ def execute(cmd):
             process = subprocess.Popen(args,stdout=subprocess.PIPE, stderr=subprocess.PIPE)
             process.wait()
             stdout, stderr = process.communicate()
-            log.debug(f"Command executed: {cmd}\n{stdout.decode()}") 
+            log.debug("Command executed: {0}\n{1}".format(cmd, stdout.decode()))
             if process.returncode != 0:
-                error_message = f"Command failed with return code {process.returncode}: {cmd}\n{stderr.decode()}"
+                error_message = "Command failed with return code {0}: {1}\n{2}".format(process.returncode, cmd, stderr.decode())
                 log.error(error_message)
             return process.returncode
         except subprocess.CalledProcessError as e:
-            error_message = f"Command failed with return code {e.returncode}: {cmd}\n{e.stderr.decode()}"
+            error_message = "Command failed with return code {0}: {1}\n{2}".format(e.returncode, cmd, e.stderr.decode())
             log.error(error_message)
             return e.returncode
         except Exception as e:
-            log.error(f"Error executing command: {cmd}\n{str(e)}")
+            log.error("Error executing command: {0}\n{1}".format(cmd, str(e)))
             return 127
     else:
-        log.error(f"Command not found: {cmd}\n")
+        log.error("Command not found: {0}\n".format(cmd))
         return 127
 
 
diff --git a/ui4/scandialog.py b/ui4/scandialog.py
index b2b1025..d924464 100644
--- a/ui4/scandialog.py
+++ b/ui4/scandialog.py
@@ -640,7 +640,7 @@ class Ui_HpScan(object):
         cmd = cmd + ' --' + 'uiscan'
         self.pushButton_Scan.setEnabled(False)
         QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
-        log.debug(f"running scan command - {cmd}")
+        log.debug("running scan command - {0}".format(cmd))
         status = utils.run(cmd)
         QApplication.restoreOverrideCursor()
 
@@ -706,7 +706,7 @@ class Ui_HpScan(object):
 
         mid = len(png_files) // 2
         png_duplex_list = [x for pair in zip(png_files[:mid], png_files[-1:mid-1:-1]) for x in pair]
-        log.debug(f"png duplex file list = {png_duplex_list}")
+        log.debug("png duplex file list = {0}".format(png_duplex_list))
             
         # Create a PDF canvas
         c = canvas.Canvas(output_pdf, pagesize=letter)
@@ -735,7 +735,7 @@ class Ui_HpScan(object):
 
         # Save the PDF
         c.save()
-        log.debug(f"PDF saved as {output_pdf}")
+        log.debug("PDF saved as {0}".format(output_pdf))
         for png_file in png_duplex_list:
             os.unlink(png_file)
             log.debug("cleanup png files")
@@ -1679,7 +1679,7 @@ class Ui_HpScan(object):
 
         # Process each device
         for device in self.devicelist:
-           log.debug(f"device discovered - {device}")
+           log.debug("device discovered - {0}".format(device))
            if combined_pattern.search(device):
                 self.comboBox_Device_URI.addItem(device)
                 self.comboBox_Device_URI.setItemText(i, _translate('HpScan', device,None))
@@ -1710,7 +1710,7 @@ class SetupDialog():
         #device = ''
         sane.init()
         sane_devices = sane.getDevices()
-        log.debug(f"sane devices = {sane_devices}")
+        log.debug("sane devices = {0}".format(sane_devices))
         # Process each device
         for (device, mfg, mdl, t) in sane_devices:
             if combined_pattern.search(device):
@@ -1721,7 +1721,7 @@ class SetupDialog():
                     devicelist[device] = [mdl, int(brx) + 1, int(bry) + 1]
                     scanDevice.closeScan()
                 except Exception as e:
-                    log.debug(f"Error processing device {device}: {e}")
+                    log.debug("Error processing device {0}: {1}".format(device, e))
 
         sane.deInit()
         #print (devicelist)
diff --git a/ui5/scandialog.py b/ui5/scandialog.py
index 0abbb72..6d68447 100644
--- a/ui5/scandialog.py
+++ b/ui5/scandialog.py
@@ -625,7 +625,7 @@ class Ui_HpScan(object):
 
         self.pushButton_Scan.setEnabled(False)
         QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
-        log.debug(f"running scan command - {cmd}")
+        log.debug("running scan command - {0}".format(cmd))
         status = utils.run(cmd)
         QApplication.restoreOverrideCursor()
 
@@ -690,7 +690,7 @@ class Ui_HpScan(object):
 
         mid = len(png_files) // 2
         png_duplex_list = [x for pair in zip(png_files[:mid], png_files[-1:mid-1:-1]) for x in pair]
-        log.debug(f"png duplex file list = {png_duplex_list}")
+        log.debug("png duplex file list = {0}".format(png_duplex_list))
             
         # Create a PDF canvas
         c = canvas.Canvas(output_pdf, pagesize=letter)
@@ -719,7 +719,7 @@ class Ui_HpScan(object):
 
         # Save the PDF
         c.save()
-        log.debug(f"PDF saved as {output_pdf}")
+        log.debug("PDF saved as {0}".format(output_pdf))
         for png_file in png_duplex_list:
             os.unlink(png_file)
             log.debug("cleanup png files")
@@ -1661,7 +1661,7 @@ class Ui_HpScan(object):
 
         # Process each device
         for device in self.devicelist:
-           log.debug(f"device discovered - {device}")
+           log.debug("device discovered - {0}".format(device))
            if combined_pattern.search(device):
                 self.comboBox_Device_URI.addItem(device)
                 self.comboBox_Device_URI.setItemText(i, _translate('HpScan', device,None))
@@ -1692,7 +1692,7 @@ class SetupDialog():
         #device = ''
         sane.init()
         sane_devices = sane.getDevices()
-        log.debug(f"sane devices = {sane_devices}")
+        log.debug("sane devices = {0}".format(sane_devices))
         # Process each device
         for (device, mfg, mdl, t) in sane_devices:
             if combined_pattern.search(device):
@@ -1703,7 +1703,7 @@ class SetupDialog():
                     devicelist[device] = [mdl, int(brx) + 1, int(bry) + 1]
                     scanDevice.closeScan()
                 except Exception as e:
-                    log.debug(f"Error processing device {device}: {e}")
+                    log.debug("Error processing device {0}: {1}".format(device, e))
 
         sane.deInit()
         #print (devicelist)
-- 
2.54.0

