Skip to content

Commit

Permalink
get x86 from server arch arg, install both if x86
Browse files Browse the repository at this point in the history
  • Loading branch information
rerpha committed Dec 16, 2024
1 parent f1a76d1 commit c916506
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 43 deletions.
8 changes: 7 additions & 1 deletion installation_and_upgrade/IBEX_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import re
import sys

import ibex_install_utils.default_args
import semantic_version
from ibex_install_utils.exceptions import ErrorInTask, UserStop
from ibex_install_utils.file_utils import FileUtils
Expand Down Expand Up @@ -108,7 +109,10 @@ def _get_latest_existing_dir_path(release_dir, component):
)
parser.add_argument("--kits_icp_dir", default=None, help="Directory of kits/ICP")
parser.add_argument(
"--server_arch", default="x64", choices=["x64", "x86"], help="Server build architecture."
"--server_arch",
default=ibex_install_utils.default_args.SERVER_ARCH,
choices=["x64", "x86"],
help="Server build architecture.",
)

deployment_types = [
Expand All @@ -122,6 +126,8 @@ def _get_latest_existing_dir_path(release_dir, component):

args = parser.parse_args()

ibex_install_utils.default_args.SERVER_ARCH = args.server_arch

if not args.no_log_to_var:
Logger.set_up()

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SERVER_ARCH = "x64"
99 changes: 57 additions & 42 deletions installation_and_upgrade/ibex_install_utils/tasks/system_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,51 +428,66 @@ def install_or_upgrade_vc_redist(self) -> None:
"""
Install the latest visual studio redistributable files
"""
import ibex_install_utils.default_args

is_64_bit = platform.machine().endswith("64")
exe_file = Path(EPICS_CRTL_PATH, f"vc_redist.{'x64' if is_64_bit else 'x86'}.exe")
if exe_file.exists() and exe_file.is_file():
log_file = Path(
VAR_DIR, "logs", "deploy", f"vc_redist_log{time.strftime('%Y%m%d%H%M%S')}.txt"
)
arch = ibex_install_utils.default_args.SERVER_ARCH

# AdminRunner doesn't seem to work here, saying it can't find a handle, so just run as a
# normal command as the process itself prompts for admin.
RunProcess(
working_dir=str(exe_file.parent),
executable_file=exe_file.name,
prog_args=["/install", "/norestart", "/passive", "/quiet", "/log", str(log_file)],
expected_return_codes=[0],
).run()

# vc_redist helpfully finishes with errorlevel 0 before actually copying the files over.
# therefore we'll sleep for 5 seconds here
print("waiting for install to finish")
sleep(5)

last_line = ""
with open(log_file, "r") as f:
for line in f.readlines():
print("vc_redist install output: {}".format(line.rstrip()))
last_line = line

status = (
"It looked like it installed correctly, but "
if "Exit code: 0x0" in last_line
else "it looked like the process errored,"
)
print(f"Installing vc_redist for arch: {arch}")

self.prompt.prompt_and_raise_if_not_yes(
f"Installing vc redistributable files finished.\n"
f"{status}"
f"please check log output above for errors,\nor alternatively {log_file}",
default="Y",
)
else:
raise ErrorInTask(
f"VC redistributable files not found in {exe_file.parent}, please check"
f" and make sure {exe_file} is present. "
)
files_to_run = [f"vc_redist.x64.exe"]

Check failure on line 437 in installation_and_upgrade/ibex_install_utils/tasks/system_tasks.py

View workflow job for this annotation

GitHub Actions / call-workflow / ruff

Ruff (F541)

installation_and_upgrade/ibex_install_utils/tasks/system_tasks.py:437:25: F541 f-string without any placeholders
if arch == "x86":
files_to_run.insert(0, "vc_redist.x86.exe")
for file in files_to_run:
exe_file = Path(EPICS_CRTL_PATH, file)
if exe_file.exists() and exe_file.is_file():
log_file = Path(
VAR_DIR, "logs", "deploy", f"vc_redist_log{time.strftime('%Y%m%d%H%M%S')}.txt"
)

# AdminRunner doesn't seem to work here, saying it can't find a handle, so just run as a

Check failure on line 447 in installation_and_upgrade/ibex_install_utils/tasks/system_tasks.py

View workflow job for this annotation

GitHub Actions / call-workflow / ruff

Ruff (E501)

installation_and_upgrade/ibex_install_utils/tasks/system_tasks.py:447:101: E501 Line too long (104 > 100)
# normal command as the process itself prompts for admin.
RunProcess(
working_dir=str(exe_file.parent),
executable_file=exe_file.name,
prog_args=[
"/install",
"/norestart",
"/passive",
"/quiet",
"/log",
str(log_file),
],
expected_return_codes=[0],
).run()

# vc_redist helpfully finishes with errorlevel 0 before actually copying the files over.

Check failure on line 463 in installation_and_upgrade/ibex_install_utils/tasks/system_tasks.py

View workflow job for this annotation

GitHub Actions / call-workflow / ruff

Ruff (E501)

installation_and_upgrade/ibex_install_utils/tasks/system_tasks.py:463:101: E501 Line too long (104 > 100)
# therefore we'll sleep for 5 seconds here
print("waiting for install to finish")
sleep(5)

last_line = ""
with open(log_file, "r") as f:
for line in f.readlines():
print("vc_redist install output: {}".format(line.rstrip()))
last_line = line

status = (
"It looked like it installed correctly, but "
if "Exit code: 0x0" in last_line
else "it looked like the process errored,"
)

self.prompt.prompt_and_raise_if_not_yes(
f"Installing vc redistributable files finished.\n"
f"{status}"
f"please check log output above for errors,\nor alternatively {log_file}",
default="Y",
)
else:
raise ErrorInTask(
f"VC redistributable files not found in {exe_file.parent}, please check"
f" and make sure {exe_file} is present. "
)

def confirm(self, message: str) -> None:
"""
Expand Down

0 comments on commit c916506

Please sign in to comment.