From 53bcbfa2312900daa67fa0d6f010893d6bbbe0f8 Mon Sep 17 00:00:00 2001 From: rusty-snake <41237666+rusty-snake@users.noreply.github.com> Date: Sat, 13 Feb 2021 20:49:26 +0100 Subject: sort.py: Better error message --- contrib/sort.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'contrib') diff --git a/contrib/sort.py b/contrib/sort.py index 54b2cbaa6..921343162 100755 --- a/contrib/sort.py +++ b/contrib/sort.py @@ -120,8 +120,8 @@ def main(args): except PermissionError: print(f"[ Error ] Can't read/write `{filename}'") exit_code = 1 - except: - print(f"[ Error ] An error occurred while processing `{filename}'") + except Exception as err: + print(f"[ Error ] An error occurred while processing `{filename}': {err}") exit_code = 1 return exit_code -- cgit v1.2.3-54-g00ecf From 455f75a7f45bf431b3f99493b4cb460f21407f74 Mon Sep 17 00:00:00 2001 From: rusty-snake <41237666+rusty-snake@users.noreply.github.com> Date: Sat, 13 Feb 2021 20:52:37 +0100 Subject: sort.py: Print the fixed line when running in a CI --- contrib/sort.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'contrib') diff --git a/contrib/sort.py b/contrib/sort.py index 921343162..ad5e063ac 100755 --- a/contrib/sort.py +++ b/contrib/sort.py @@ -24,6 +24,7 @@ Exit-Codes: # Requirements: # python >= 3.6 +from os import getenv from sys import argv @@ -80,7 +81,7 @@ def fix_profile(filename): lines = profile.read().split("\n") was_fixed = False fixed_profile = [] - for line in lines: + for lineno, line in enumerate(lines): if line[:12] in ("private-bin ", "private-etc ", "private-lib "): fixed_line = f"{line[:12]}{sort_alphabetical(line[12:])}" elif line[:13] in ("seccomp.drop ", "seccomp.keep "): @@ -95,6 +96,8 @@ def fix_profile(filename): fixed_line = line if fixed_line != line: was_fixed = True + if getenv("CI"): + print(f"{filename}:{lineno + 1}:{fixed_line}") fixed_profile.append(fixed_line) if was_fixed: profile.seek(0) -- cgit v1.2.3-54-g00ecf From a203caa710151374ffe5a33ba6b850d592b9ccc7 Mon Sep 17 00:00:00 2001 From: rusty-snake <41237666+rusty-snake@users.noreply.github.com> Date: Sun, 14 Feb 2021 08:56:45 +0100 Subject: sort.py: Print how many profiles are checked --- contrib/sort.py | 1 + 1 file changed, 1 insertion(+) (limited to 'contrib') diff --git a/contrib/sort.py b/contrib/sort.py index ad5e063ac..b1f8d350c 100755 --- a/contrib/sort.py +++ b/contrib/sort.py @@ -111,6 +111,7 @@ def fix_profile(filename): def main(args): exit_code = 0 + print(f"sort.py: checking {len(args)} {'profiles' if len(args) != 1 else 'profile'} ...") for filename in args: try: if exit_code not in (1, 101): -- cgit v1.2.3-54-g00ecf From e9ec31ac922f07ae4ced23fc11c4097509959889 Mon Sep 17 00:00:00 2001 From: rusty-snake <41237666+rusty-snake@users.noreply.github.com> Date: Sun, 14 Feb 2021 09:02:06 +0100 Subject: sort.py: Always show the fix in a diff like format --- contrib/sort.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'contrib') diff --git a/contrib/sort.py b/contrib/sort.py index b1f8d350c..babc0ba55 100755 --- a/contrib/sort.py +++ b/contrib/sort.py @@ -24,7 +24,6 @@ Exit-Codes: # Requirements: # python >= 3.6 -from os import getenv from sys import argv @@ -96,8 +95,10 @@ def fix_profile(filename): fixed_line = line if fixed_line != line: was_fixed = True - if getenv("CI"): - print(f"{filename}:{lineno + 1}:{fixed_line}") + print( + f"{filename}:{lineno + 1}:-{line}\n" + f"{filename}:{lineno + 1}:+{fixed_line}" + ) fixed_profile.append(fixed_line) if was_fixed: profile.seek(0) -- cgit v1.2.3-54-g00ecf From f1121cf4417f504198bae0395e1d4e43adc8239f Mon Sep 17 00:00:00 2001 From: rusty-snake <41237666+rusty-snake@users.noreply.github.com> Date: Mon, 15 Feb 2021 09:38:56 +0000 Subject: sort.py: Remove whitespace in status output Co-authored-by: Kelvin M. Klann --- contrib/sort.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'contrib') diff --git a/contrib/sort.py b/contrib/sort.py index babc0ba55..f6903d393 100755 --- a/contrib/sort.py +++ b/contrib/sort.py @@ -112,7 +112,7 @@ def fix_profile(filename): def main(args): exit_code = 0 - print(f"sort.py: checking {len(args)} {'profiles' if len(args) != 1 else 'profile'} ...") + print(f"sort.py: checking {len(args)} {'profiles' if len(args) != 1 else 'profile'}...") for filename in args: try: if exit_code not in (1, 101): -- cgit v1.2.3-54-g00ecf