Skip to content

Commit a37552d

Browse files
committed
Merge remote-tracking branch 'origin/master' into rust
2 parents b9014c0 + 950a458 commit a37552d

File tree

5 files changed

+53
-27
lines changed

5 files changed

+53
-27
lines changed

installation_and_upgrade/ibex_install_utils/admin_runner.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
from time import sleep
88
from typing import Any, Generator
99

10+
from ibex_install_utils.logger import temporarily_disable_logging
11+
1012
# Plink is an SSH binary bundled with putty.
1113
# Use Plink as it allows passwords on the command-line, as opposed to
1214
# windows-bundled SSH which does not.
@@ -30,8 +32,9 @@ class AdminRunner:
3032
def _auth_ssh(cls) -> None:
3133
if not cls._ssh_authenticated:
3234
while True:
33-
cls._ssh_user = input("Enter admin username (without domain): ")
34-
cls._ssh_password = getpass.getpass("Enter admin password: ")
35+
with temporarily_disable_logging():
36+
cls._ssh_user = input("Enter admin username (without domain): ")
37+
cls._ssh_password = getpass.getpass("Enter admin password: ")
3538

3639
assert cls._ssh_user is not None
3740
assert cls._ssh_password is not None

installation_and_upgrade/ibex_install_utils/logger.py

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,61 @@
11
import os
22
import sys
33
import time
4+
from contextlib import contextmanager
5+
from typing import Generator
6+
7+
ENABLE_LOGGING = True
8+
9+
10+
@contextmanager
11+
def temporarily_disable_logging() -> Generator[None, None, None]:
12+
global ENABLE_LOGGING
13+
previous_logging_enabled = ENABLE_LOGGING
14+
ENABLE_LOGGING = False
15+
try:
16+
yield
17+
finally:
18+
ENABLE_LOGGING = previous_logging_enabled
419

520

621
class Logger:
722
"""
823
Logger class used to capture output and input to a log file.
924
"""
1025

11-
def __init__(self):
12-
CURRENT_DATE = time.strftime("%Y%m%d")
13-
LOG_FILE = f"DEPLOY-{CURRENT_DATE}.log"
14-
LOG_DIRECTORY = os.path.join("C:\\", "Instrument", "var", "logs", "deploy")
15-
os.makedirs(LOG_DIRECTORY, exist_ok=True)
16-
LOG_PATH = os.path.join(LOG_DIRECTORY, LOG_FILE)
26+
def __init__(self) -> None:
27+
current_date = time.strftime("%Y%m%d")
28+
log_file = f"DEPLOY-{current_date}.log"
29+
log_directory = os.path.join("C:\\", "Instrument", "var", "logs", "deploy")
30+
os.makedirs(log_directory, exist_ok=True)
31+
log_path = os.path.join(log_directory, log_file)
1732

1833
self.console = sys.stdout
1934
self.input = sys.stdin
20-
self.log = open(LOG_PATH, "a")
21-
print(f"Log file is {LOG_PATH}")
22-
23-
def write(self, message):
24-
self.log.write(message)
35+
self.log = open(log_path, "a")
36+
print(f"Log file is {log_path}")
37+
38+
def write(self, message: str) -> int:
39+
if ENABLE_LOGGING:
40+
self.log.write(message)
41+
else:
42+
self.log.write("[concealed]\n")
2543
return self.console.write(message)
2644

27-
def flush(self):
45+
def flush(self) -> None:
2846
self.console.flush()
2947
self.log.flush()
3048

31-
def readline(self):
49+
def readline(self) -> str:
3250
text = self.input.readline()
33-
self.log.write(text)
51+
if ENABLE_LOGGING:
52+
self.log.write(text)
53+
else:
54+
self.log.write("[concealed]\n")
3455
return text
3556

3657
@staticmethod
37-
def set_up():
58+
def set_up() -> None:
3859
logger = Logger()
3960
sys.stdout = logger
4061
sys.stderr = logger

installation_and_upgrade/ibex_install_utils/tasks/mysql_tasks.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
from ibex_install_utils.admin_runner import AdminCommandBuilder
1010
from ibex_install_utils.exceptions import ErrorInRun
11+
from ibex_install_utils.logger import temporarily_disable_logging
1112
from ibex_install_utils.run_process import RunProcess
1213
from ibex_install_utils.software_dependency.mysql import MySQL
1314
from ibex_install_utils.task import task
@@ -217,12 +218,13 @@ def _setup_database_users_and_tables(self, vhd_install: bool = True) -> None:
217218
sql_password = ""
218219
retry_count = 5
219220
while --retry_count > 0:
220-
sql_password = self.prompt.prompt(
221-
"Enter the MySQL root password:",
222-
UserPrompt.ANY,
223-
os.getenv("MYSQL_PASSWORD", "environment variable not set"),
224-
show_automatic_answer=False,
225-
).strip()
221+
with temporarily_disable_logging():
222+
sql_password = self.prompt.prompt(
223+
"Enter the MySQL root password:",
224+
UserPrompt.ANY,
225+
os.getenv("MYSQL_PASSWORD", "environment variable not set"),
226+
show_automatic_answer=False,
227+
).strip()
226228
if len(sql_password) > 0:
227229
break
228230
print("Please enter a non blank password")

installation_and_upgrade/ibex_install_utils/tasks/server_tasks.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,9 +369,7 @@ def update_calibrations_repository(self) -> None:
369369
@task("Server release tests")
370370
def perform_server_tests(self) -> None:
371371
"""Test that the server works"""
372-
server_release_tests_url = (
373-
"https://github.com/ISISComputingGroup/ibex_developers_manual/wiki/Server-Release-Tests"
374-
)
372+
server_release_tests_url = "https://isiscomputinggroup.github.io/ibex_developers_manual/deployment/deploy/Server-Release-Tests.html"
375373

376374
print(f"For further details, see {server_release_tests_url}")
377375
self.prompt.prompt_and_raise_if_not_yes("Check that blocks are logging as expected")

installation_and_upgrade/ibex_install_utils/tasks/system_tasks.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,9 @@ def inform_instrument_scientists(self) -> None:
247247
email_template = f"""Please send the following email to your instrument scientists:
248248
Hello,
249249
We have finished the upgrade of {BaseTasks._get_machine_name()} to IBEX {ibex_version}.
250-
The release notes for this are at the following link: https://github.com/ISISComputingGroup/IBEX/wiki/Release-Notes-v{ibex_version}
250+
The relevant release notes can be found at the following links:
251+
* https://github.com/ISISComputingGroup/IBEX/blob/master/release_notes/Release-Notes-v{ibex_version}.md
252+
* https://github.com/ISISComputingGroup/IBEX/blob/master/release_notes/Release-Notes-v<INSERT PREVIOUS IBEX VERSION HERE>.md
251253
252254
Please let us know if you have any queries or find any problems with the upgrade.
253255
Thank you,

0 commit comments

Comments
 (0)