From f49897c3be3b052e9500446a8ff5402d0eed93bd Mon Sep 17 00:00:00 2001 From: Patrick Lodder Date: Sat, 4 Dec 2021 11:20:22 -0400 Subject: [PATCH 1/2] lint: fix pylint suggestions C0114: Missing module docstring (missing-module-docstring) fixed by adding the docstring C0116: Missing function or method docstring fixed by adding the docstring to main() W1514: Using open without explicitly specifying an encoding fixed by specifying the manpage encoding as UTF-8 W1510: Using subprocess.run without explicitly set `check` fixed by adding check=True argument R1722: Consider using sys.exit() fixed by separating print from exit, and using sys.exit(1) --- 1.14.5/bullseye/entrypoint.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/1.14.5/bullseye/entrypoint.py b/1.14.5/bullseye/entrypoint.py index fbd440d..33962ee 100755 --- a/1.14.5/bullseye/entrypoint.py +++ b/1.14.5/bullseye/entrypoint.py @@ -1,5 +1,7 @@ #!/usr/bin/env python3 - +""" + Docker entrypoint for Dogecoin Core +""" import argparse import os import pwd @@ -23,7 +25,8 @@ def execute(executable, args): executable_path = shutil.which(executable) if executable_path is None: - exit(f"{sys.argv[0]}: {executable} not found.") + print(f"{sys.argv[0]}: {executable} not found.") + sys.exit(1) #Prepare execve args & launch container command execve_args = [executable_path] + args @@ -47,7 +50,7 @@ def executable_options(executable): man_folder = "/usr/share/man/man1" man_file = os.path.join(man_folder, f"{executable}.1") - with open(man_file, "r") as man_filestream: + with open(man_file, "r", encoding="utf-8") as man_filestream: man_content = man_filestream.read() # Regex to match single option entry in man(1) page @@ -77,7 +80,7 @@ def create_datadir(): os.makedirs(datadir, exist_ok=True) user = os.environ["USER"] - subprocess.run(["chown", "-R", f"{user}:{user}", datadir]) + subprocess.run(["chown", "-R", f"{user}:{user}", datadir], check=True) def convert_env(executable): """ @@ -131,6 +134,9 @@ def run_executable(executable, executable_args): execute(executable, executable_args) def main(): + """ + Main routine + """ if sys.argv[1].startswith("-"): executable = "dogecoind" else: From 068c137fb7ce9ba07a9d3155f9ae9b6e945cbe76 Mon Sep 17 00:00:00 2001 From: Patrick Lodder Date: Sat, 4 Dec 2021 18:50:18 -0400 Subject: [PATCH 2/2] Print error to stderr Co-authored-by: AbcSxyZ <34010605+AbcSxyZ@users.noreply.github.com> --- 1.14.5/bullseye/entrypoint.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1.14.5/bullseye/entrypoint.py b/1.14.5/bullseye/entrypoint.py index 33962ee..4266f8e 100755 --- a/1.14.5/bullseye/entrypoint.py +++ b/1.14.5/bullseye/entrypoint.py @@ -25,7 +25,7 @@ def execute(executable, args): executable_path = shutil.which(executable) if executable_path is None: - print(f"{sys.argv[0]}: {executable} not found.") + print(f"{sys.argv[0]}: {executable} not found.", file=sys.stderr) sys.exit(1) #Prepare execve args & launch container command