Skip to content

Commit d841584

Browse files
committed
fix keyerror
1 parent 051523b commit d841584

File tree

2 files changed

+20
-32
lines changed

2 files changed

+20
-32
lines changed

oclp_r/sys_patch/sys_patch.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ def _execute_patchset(self, required_patches: dict):
393393
destination_folder_path = str(self.mount_location) + remove_patch_directory
394394
else:
395395
destination_folder_path = str(self.mount_location_data) + remove_patch_directory
396-
remove_file(destination_folder_path, remove_patch_file,self.trans)
396+
remove_file(destination_folder_path, remove_patch_file)
397397

398398

399399
for method_install in [PatchType.OVERWRITE_SYSTEM_VOLUME, PatchType.OVERWRITE_DATA_VOLUME, PatchType.MERGE_SYSTEM_VOLUME, PatchType.MERGE_DATA_VOLUME]:
@@ -432,7 +432,7 @@ def _execute_patchset(self, required_patches: dict):
432432

433433
destination_folder_path = updated_destination_folder_path
434434
self.trans_ul=translate_language.TranslateLanguage(global_constants=self.constants).utilities()
435-
install_new_file(source_folder_path, destination_folder_path, install_file, method_install,self.trans_ul)
435+
install_new_file(source_folder_path, destination_folder_path, install_file, method_install)
436436

437437
if PatchType.EXECUTE in required_patches[patch]:
438438
for process in required_patches[patch][PatchType.EXECUTE]:

oclp_r/sys_patch/utilities/files.py

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111

1212
from ...volume import generate_copy_arguments
1313
from ...support import subprocess_wrapper
14+
from ...support.translate_language import TranslateLanguage_sys_patch
15+
trans=TranslateLanguage_sys_patch().utilities()
1416

15-
16-
def install_new_file(source_folder: Path, destination_folder: Path, file_name: str, method: PatchType, trans: dict = None) -> None:
17+
def install_new_file(source_folder: Path, destination_folder: Path, file_name: str, method: PatchType) -> None:
1718
"""
1819
Installs a new file to the destination folder
1920
@@ -30,48 +31,36 @@ def install_new_file(source_folder: Path, destination_folder: Path, file_name: s
3031
file_name_str = str(file_name)
3132

3233
if not Path(destination_folder).exists():
33-
if trans:
34-
logging.info(trans[" - Skipping {file_name}, cannot locate {source_folder}"].format(file_name=file_name, source_folder=source_folder))
35-
else:
36-
logging.info(f" - Skipping {file_name}, cannot locate {source_folder}")
34+
35+
logging.info(trans[" - Skipping {file_name}, cannot locate {source_folder}"].format(file_name=file_name, source_folder=source_folder))
3736
return
3837

3938
if method in [PatchType.MERGE_SYSTEM_VOLUME, PatchType.MERGE_DATA_VOLUME]:
4039
# merge with rsync
41-
if trans:
42-
logging.info(trans[" - Installing: {file_name}"].format(file_name=file_name))
43-
else:
44-
logging.info(f" - Installing: {file_name}")
40+
41+
logging.info(trans[" - Installing: {file_name}"].format(file_name=file_name))
4542
subprocess_wrapper.run_as_root(["/usr/bin/rsync", "-r", "-i", "-a", f"{source_folder}/{file_name}", f"{destination_folder}/"], stdout=subprocess.PIPE)
4643
fix_permissions(destination_folder + "/" + file_name)
4744
elif Path(source_folder + "/" + file_name_str).is_dir():
4845
# Applicable for .kext, .app, .plugin, .bundle, all of which are directories
4946
if Path(destination_folder + "/" + file_name).exists():
50-
if trans:
51-
logging.info(trans[" - Found existing {file_name}, overwriting..."].format(file_name=file_name))
52-
else:
53-
logging.info(f" - Found existing {file_name}, overwriting...")
47+
48+
logging.info(trans[" - Found existing {file_name}, overwriting..."].format(file_name=file_name))
49+
5450
subprocess_wrapper.run_as_root_and_verify(["/bin/rm", "-R", f"{destination_folder}/{file_name}"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
5551
else:
56-
if trans:
57-
logging.info(trans[" - Installing: {file_name}"].format(file_name=file_name))
58-
else:
59-
logging.info(f" - Installing: {file_name}")
52+
53+
logging.info(trans[" - Installing: {file_name}"].format(file_name=file_name))
54+
6055
subprocess_wrapper.run_as_root_and_verify(generate_copy_arguments(f"{source_folder}/{file_name}", destination_folder), stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
6156
fix_permissions(destination_folder + "/" + file_name)
6257
else:
6358
# Assume it's an individual file, replace as normal
6459
if Path(destination_folder + "/" + file_name).exists():
65-
if trans:
66-
logging.info(trans[" - Found existing {file_name}, overwriting..."].format(file_name=file_name))
67-
else:
68-
logging.info(f" - Found existing {file_name}, overwriting...")
60+
logging.info(trans[" - Found existing {file_name}, overwriting..."].format(file_name=file_name))
6961
subprocess_wrapper.run_as_root_and_verify(["/bin/rm", f"{destination_folder}/{file_name}"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
7062
else:
71-
if trans:
72-
logging.info(trans[" - Installing: {file_name}"].format(file_name=file_name))
73-
else:
74-
logging.info(f" - Installing: {file_name}")
63+
logging.info(trans[" - Installing: {file_name}"].format(file_name=file_name))
7564
subprocess_wrapper.run_as_root_and_verify(generate_copy_arguments(f"{source_folder}/{file_name}", destination_folder), stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
7665
fix_permissions(destination_folder + "/" + file_name)
7766

@@ -86,10 +75,9 @@ def remove_file(destination_folder: Path, file_name: str, trans: dict = None) ->
8675
"""
8776

8877
if Path(destination_folder + "/" + file_name).exists():
89-
if trans:
90-
logging.info(trans[" - Removing: {file_name}"].format(file_name=file_name))
91-
else:
92-
logging.info(f" - Removing: {file_name}")
78+
79+
logging.info(trans[" - Removing: {file_name}"].format(file_name=file_name))
80+
9381
if Path(destination_folder + "/" + file_name).is_dir():
9482
subprocess_wrapper.run_as_root_and_verify(["/bin/rm", "-R", f"{destination_folder}/{file_name}"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
9583
else:

0 commit comments

Comments
 (0)