Skip to content

Commit 68d44cb

Browse files
authored
Merge pull request #73 from QualiSystemsLab/bug/fix_readonly_delete_error_and_autotagging_s3
update hcl parser version
2 parents 9ff3507 + 28c38d1 commit 68d44cb

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

package/cloudshell/iac/terraform/services/local_dir_service.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,26 @@
88
from cloudshell.iac.terraform.services.sandox_data import SandboxDataHandler
99

1010

11+
def handle_remove_readonly(func, path, exc_info):
12+
"""
13+
Error handler for ``shutil.rmtree``.
14+
15+
If the error is due to an access error (read only file)
16+
it attempts to add write permission and then retries.
17+
18+
If the error is for another reason it re-raises the error.
19+
20+
Usage : ``shutil.rmtree(path, onerror=onerror)``
21+
"""
22+
import stat
23+
# Is the error an access error?
24+
if not os.access(path, os.W_OK):
25+
os.chmod(path, stat.S_IWUSR)
26+
func(path)
27+
else:
28+
raise
29+
30+
1131
class LocalDir:
1232
@staticmethod
1333
def delete_local_temp_dir(sandbox_data_handler: SandboxDataHandler, tf_working_dir: str):
@@ -20,7 +40,7 @@ def delete_local_temp_dir(sandbox_data_handler: SandboxDataHandler, tf_working_d
2040
tmp_folder_found = True
2141
tf_path = Path(tf_path.parent.absolute())
2242
tf_path_str = str(tf_path)
23-
shutil.rmtree(tf_path_str)
43+
shutil.rmtree(tf_path_str, onerror=handle_remove_readonly)
2444
sandbox_data_handler.set_tf_working_dir("")
2545

2646
@staticmethod

package/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ cloudshell-shell-core==5.0.5
22
requests==2.25.1
33
cloudshell-automation-api==2021.1.0.181140
44
retry==0.9.2
5-
python-hcl2==2.0.1
5+
python-hcl2==3.0.5

package/version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.2.2
1+
1.2.3

0 commit comments

Comments
 (0)