From 3f6bfbaa69f22107f5419ff42572f1b50aa6cb10 Mon Sep 17 00:00:00 2001 From: ramishra Date: Thu, 11 Feb 2021 10:25:31 +0530 Subject: [PATCH] Allow writing byte strings with safe_write Heat files map keeps file contents as byte string in some cases (i.e. shell scripts). Decode them before writing to archive. Closes-Bug: #1915368 Change-Id: I3af14190ebb9d7efbb063299037bd51e38eccd83 --- tripleoclient/utils.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tripleoclient/utils.py b/tripleoclient/utils.py index b63042e51..504ff02fa 100644 --- a/tripleoclient/utils.py +++ b/tripleoclient/utils.py @@ -2402,6 +2402,11 @@ def safe_write(path, data): path ) + try: + data = data.decode('utf-8', 'ignore') + except (UnicodeDecodeError, AttributeError): + pass + try: with os.fdopen(os.open(path, os.O_CREAT | os.O_TRUNC | os.O_WRONLY, 0o666),