This is an automated email from the ASF dual-hosted git repository.
lfrolov pushed a commit to branch DLAB-1594-2
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git
The following commit(s) were added to refs/heads/DLAB-1594-2 by this push:
new a0369f0 [DLAB-1594]: changed how lines are changed
a0369f0 is described below
commit a0369f097133be751788dbe108ac23bcb014f531
Author: leonidfrolov <[email protected]>
AuthorDate: Tue Aug 4 12:26:10 2020 +0300
[DLAB-1594]: changed how lines are changed
---
.../src/ssn/scripts/configure_ssn_node.py | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/infrastructure-provisioning/src/ssn/scripts/configure_ssn_node.py
b/infrastructure-provisioning/src/ssn/scripts/configure_ssn_node.py
index d6186e1..0683908 100644
--- a/infrastructure-provisioning/src/ssn/scripts/configure_ssn_node.py
+++ b/infrastructure-provisioning/src/ssn/scripts/configure_ssn_node.py
@@ -151,13 +151,16 @@ def run_certbot(domain_name, email=''):
def find_replace_line(file_path, searched_str, replacement_line):
try:
- with open(file_path, 'r') as file:
- lines = file.readlines()
- for line in lines:
- if searched_str in line:
- line = replacement_line
- with open(file_path, 'w') as file:
- file.writelines(lines)
+ lines = sudo('cat {}'.format(file_path)).split('\r\n')
+ #with open(file_path, 'r') as file:
+ #lines = file.readlines()
+ sudo('echo "" > {}'.format(file_path))
+ for line in lines:
+ if searched_str in line:
+ line = replacement_line
+ sudo('echo "{}" >> {}'.format, file_path)
+ #with open(file_path, 'w') as file:
+ #file.writelines(lines)
except Exception as err:
print('Failed to replace string: ' + str(err))
sys.exit(1)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]