From b2ddc526873e3e9f45c0b4e68aade81583eddfec Mon Sep 17 00:00:00 2001 From: Wolfgang Fahl Date: Mon, 1 May 2023 17:26:15 +0200 Subject: [PATCH] tries fixing issues with plantuml installation --- profiwiki/__init__.py | 2 +- profiwiki/docker.py | 30 +++++++++++++++++++++++------- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/profiwiki/__init__.py b/profiwiki/__init__.py index d39c9c1..bb9eb74 100644 --- a/profiwiki/__init__.py +++ b/profiwiki/__init__.py @@ -1 +1 @@ -__version__="0.1.5" \ No newline at end of file +__version__="0.1.6" \ No newline at end of file diff --git a/profiwiki/docker.py b/profiwiki/docker.py index 7157866..71781ac 100644 --- a/profiwiki/docker.py +++ b/profiwiki/docker.py @@ -62,11 +62,30 @@ def install_plantuml(self): """ install plantuml to this container """ + script="""#!/bin/bash +# install plantuml +# WF 2023-05-01 +apt-get update +apt-get install -y plantuml +""" # https://gabrieldemarmiesse.github.io/python-on-whales/docker_objects/containers/ - self.dc.container.execute(["apt-get","update"],tty=True) - self.dc.container.execute(["apt-get","install","-y","plantuml"],tty=True) + script_path="/root/install_plantuml.sh" + self.install_and_run_script(script, script_path) pass + def install_and_run_script(self,script:str,script_path:str): + """ + install and run the given script + + Args: + script(str): the source code of the script + script_path(str): the path to copy the script to and then execute + """ + self.upload(script,script_path) + # make executable + self.dc.container.execute(["chmod","+x",script_path]) + self.dc.container.execute([script_path],tty=True) + def install_fontawesome(self): """ install fontawesome to this container @@ -98,14 +117,11 @@ def install_fontawesome(self): a2enconf font-awesome """ script_path="/root/install_fontawesome" - self.upload(script,"/root/install_fontawesome") - # make executable - self.dc.container.execute(["chmod","+x",script_path]) - self.dc.container.execute([script_path],tty=True) + self.install_and_run_script(script, script_path) try: self.dc.container.execute(["service","apache2","restart"]) except DockerException as e: # we expect a SIGTERM if not e.return_code==143: raise e - pass + pass \ No newline at end of file