[elbe-devel] [PATCH v2 67/75] shellhelper: use f-strings

Daniel Braunwarth daniel at braunwarth.dev
Wed Nov 2 20:14:49 CET 2022


Signed-off-by: Daniel Braunwarth <daniel at braunwarth.dev>
---
 elbepack/shellhelper.py | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/elbepack/shellhelper.py b/elbepack/shellhelper.py
index f33f19b7e..f8ee0b58a 100644
--- a/elbepack/shellhelper.py
+++ b/elbepack/shellhelper.py
@@ -26,8 +26,7 @@ class CommandError(Exception):
         self.cmd = cmd
 
     def __str__(self):
-        return "Error: %d returned from Command %s" % (
-            self.returncode, self.cmd)
+        return f"Error: {self.returncode} returned from Command {self.cmd}"
 
 def system(cmd, allow_fail=False, env_add=None):
     """system() - Execute cmd in a shell.
@@ -281,8 +280,7 @@ def chroot(directory, cmd, env_add=None, **kwargs):
                "LC_ALL":"C"}
     if env_add:
         new_env.update(env_add)
-    chcmd = 'chroot %s %s' % (directory, cmd)
-    do(chcmd, env_add=new_env, **kwargs)
+    do(f"chroot {directory} {cmd}", env_add=new_env, **kwargs)
 
 def get_command_out(cmd, stdin=None, allow_fail=False, env_add=None):
     """get_command_out() - Like do() but returns stdout.
-- 
2.38.1



More information about the elbe-devel mailing list