From f699f5fe313fb00ff48eeeef660900a85b9e2e98 Mon Sep 17 00:00:00 2001 From: 2e20 <2e20@riseup.net> Date: Mon, 7 Oct 2024 02:57:27 +0200 Subject: [PATCH] remove irrelevant os.path.exists() checks --- matrix-synapse/deploy.py | 72 ++++++++++++++-------------------------- 1 file changed, 25 insertions(+), 47 deletions(-) diff --git a/matrix-synapse/deploy.py b/matrix-synapse/deploy.py index 77e10a5..977083d 100644 --- a/matrix-synapse/deploy.py +++ b/matrix-synapse/deploy.py @@ -2,8 +2,6 @@ from pyinfra import host from pyinfra.operations import apt, server, files from pyinfra.facts.server import LinuxName -import os - files_path = "files/matrix-synapse/" ## don't exexute on a local mashine @@ -95,15 +93,11 @@ if host.name != "@local": ## copy doas config doas_conf_path = files_path +"doas.conf" - exi = os.path.exists(doas_conf_path) - if exi == True: - files.put( - name="copy doas config", - src=doas_conf_path, - dest="/etc/doas.conf", - ) - else: - print("file: \"" +doas_conf_path +"\" dosn't exists") + files.put( + name="copy doas config", + src=doas_conf_path, + dest="/etc/doas.conf", + ) ## generate synapse config server.shell( @@ -135,39 +129,27 @@ if host.name != "@local": ## copy synapse config homeserver_py_path = files_path +"homeserver.yaml" - exi = os.path.exists(homeserver_py_path) - if exi == True: - files.put( - name="copy synapse config", - src=homeserver_py_path, - dest="/var/synapse/homeserver.yaml", - ) - else: - print("file: \"" +homeserver_py_path +"\" dosn't exists") + files.put( + name="copy synapse config", + src=homeserver_py_path, + dest="/var/synapse/homeserver.yaml", + ) ## copy logging config log_conf_path = files_path + "chat.heizhaus.org.log.config" - exi = os.path.exists(log_conf_path) - if exi == True: - files.put( - name="copy logging config", - src=log_conf_path, - dest="/var/synapse/chat.heizhaus.org.log.config", - ) - else: - print("file: \"" +log_conf_path +"\" dosn't exists") + files.put( + name="copy logging config", + src=log_conf_path, + dest="/var/synapse/chat.heizhaus.org.log.config", + ) ## add synapse commands to PATH dotprofile_path = files_path +"dotprofile" - exi = os.path.exists(dotprofile_path) - if exi == True: - files.put( - name="add synapse commands to PATH", - src=dotprofile_path, - dest="/root/.profile", - ) - else: - print("file: \"" +dotprofile_path +"\" dosn't exists") + files.put( + name="add synapse commands to PATH", + src=dotprofile_path, + dest="/root/.profile", + ) ## change owner for /var/synapse # user_name = "_synapse" @@ -204,12 +186,8 @@ if host.name != "@local": ## add synapse backup script backup_sh_path = files_path +"borgbackup.sh" - exi = os.path.exists(backup_sh_path) - if exi == True: - files.put( - name="add synapse backup script", - src=backup_sh_path, - dest="/etc/daily.d/borgbackup.sh" - ) - else: - print("file: \"" +backup_sh_path +"\" dosn't exists") + files.put( + name="add synapse backup script", + src=backup_sh_path, + dest="/etc/daily.d/borgbackup.sh" + )