From f5cd3c62341a6d26dc6c4f11d8fae707347f1766 Mon Sep 17 00:00:00 2001 From: Marcel Schwarz Date: Mon, 30 Dec 2019 01:00:47 +0100 Subject: [PATCH] Add programs list, implement subprocess to start apt, error handling --- modules/command-line tools/cmd_tools.py | 15 ++++++++++++++- modules/command-line tools/programs.json | 8 ++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 modules/command-line tools/programs.json diff --git a/modules/command-line tools/cmd_tools.py b/modules/command-line tools/cmd_tools.py index a0a8320..1cf319c 100644 --- a/modules/command-line tools/cmd_tools.py +++ b/modules/command-line tools/cmd_tools.py @@ -1,6 +1,19 @@ +import json +import subprocess + from AbstractModule import AbstractModule class CmdToolsModule(AbstractModule): def run(self): - print("Commandline Tools") + print("Try to install basic Command-line tools") + + with open("modules/command-line tools/programs.json") as config_file: + programms_list = json.load(config_file) + + out = subprocess.run(["apt", "install"] + programms_list, shell=True, capture_output=True) + if len(out.stderr) > 0: + print(out.stderr.decode()) + print("Install might be not complete, please check output above.") + else: + print("Installed successful.") diff --git a/modules/command-line tools/programs.json b/modules/command-line tools/programs.json new file mode 100644 index 0000000..d5a8228 --- /dev/null +++ b/modules/command-line tools/programs.json @@ -0,0 +1,8 @@ +[ + "bleachbit", + "nano", + "xrdp", + "htop", + "bash-completion", + "dialog" +] \ No newline at end of file