Skip to content

Commit 77719b4

Browse files
Merge pull request #203 from ISISComputingGroup/summer_update
Add summer update script
2 parents 57bfd48 + 860e059 commit 77719b4

File tree

4 files changed

+137
-67
lines changed

4 files changed

+137
-67
lines changed

installation_and_upgrade/ibex_install_utils/install_tasks.py

Lines changed: 64 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,21 @@
1414
from ibex_install_utils.tasks.server_tasks import ServerTasks
1515
from ibex_install_utils.tasks.system_tasks import SystemTasks
1616
from ibex_install_utils.tasks.vhd_tasks import VHDTasks
17+
from ibex_install_utils.user_prompt import UserPrompt
1718

1819

1920
class UpgradeInstrument:
2021
"""Class to upgrade the instrument installation to the given version of IBEX."""
2122

2223
def __init__(
2324
self,
24-
user_prompt,
25-
server_source_dir,
26-
client_source_dir,
27-
genie_python3_dir,
28-
ibex_version,
29-
file_utils=FileUtils(),
30-
):
25+
user_prompt: UserPrompt,
26+
server_source_dir: str,
27+
client_source_dir: str,
28+
genie_python3_dir: str,
29+
ibex_version: str,
30+
file_utils: FileUtils = FileUtils(),
31+
) -> None:
3132
"""Initializer.
3233
3334
Args:
@@ -111,14 +112,14 @@ def __init__(
111112
)
112113

113114
@staticmethod
114-
def icp_in_labview_modules():
115+
def icp_in_labview_modules() -> bool:
115116
"""Condition on which to install ICP_Binaries or
116117
117118
:return: True if the ICP is installed in labview modules, False otherwise
118119
"""
119120
return os.path.exists(LABVIEW_DAE_DIR)
120121

121-
def run_test_update(self):
122+
def run_test_update(self) -> None:
122123
"""Run a complete test upgrade on the current system"""
123124
self._system_tasks.user_confirm_upgrade_type_on_machine("Training Machine")
124125
self._system_tasks.install_or_upgrade_git()
@@ -136,10 +137,11 @@ def run_test_update(self):
136137
self._system_tasks.upgrade_notepad_pp()
137138
self._server_tasks.setup_log_rotation()
138139

139-
def remove_all_and_install_client_and_server(self):
140+
def remove_all_and_install_client_and_server(self) -> None:
140141
"""Either install or upgrade the ibex client and server"""
141142
self._system_tasks.confirm(
142-
"This script removes IBEX client and server and installs the latest build of both, and upgrade the "
143+
"This script removes IBEX client and server and installs "
144+
"the latest build of both, and upgrade the "
143145
"config/schema without any extra steps. Proceed?"
144146
)
145147

@@ -153,13 +155,13 @@ def remove_all_and_install_client_and_server(self):
153155
self._server_tasks.upgrade_instrument_configuration()
154156
self._server_tasks.install_shared_scripts_repository()
155157

156-
def run_instrument_tests(self):
158+
def run_instrument_tests(self) -> None:
157159
"""Run through client and server tests once installation / deployment has completed."""
158160
self._client_tasks.perform_client_tests()
159161
self._server_tasks.perform_server_tests()
160162
self._system_tasks.inform_instrument_scientists()
161163

162-
def run_instrument_install(self):
164+
def run_instrument_install(self) -> None:
163165
"""Do a first installation of IBEX on a new instrument."""
164166
self._system_tasks.confirm(
165167
"This script performs a first-time full installation of the IBEX server and client"
@@ -198,19 +200,20 @@ def run_instrument_install(self):
198200
self._python_tasks.update_script_definitions()
199201
self._server_tasks.setup_log_rotation()
200202

201-
def save_motor_params(self):
203+
def save_motor_params(self) -> None:
202204
self._server_tasks.save_motor_parameters_to_file()
203205

204-
def run_instrument_deploy(self):
206+
def run_instrument_deploy(self) -> None:
205207
"""Deploy a full IBEX upgrade on an existing instrument."""
206208
self._system_tasks.confirm(
207-
"This script performs a full upgrade of the IBEX server and client on an existing instrument. Proceed?"
209+
"This script performs a full upgrade of the IBEX server "
210+
"and client on an existing instrument. Proceed?"
208211
)
209212
self.run_instrument_deploy_pre_stop()
210213
self.run_instrument_deploy_main()
211214
self.run_instrument_deploy_post_start()
212215

213-
def run_instrument_deploy_post_start(self):
216+
def run_instrument_deploy_post_start(self) -> None:
214217
"""Upgrade an instrument. Steps to do after ibex has been started.
215218
216219
Current the server can not be started in this python script.
@@ -225,8 +228,9 @@ def run_instrument_deploy_post_start(self):
225228
self._system_tasks.put_autostart_script_in_startup_area()
226229
self._system_tasks.inform_instrument_scientists()
227230

228-
def run_instrument_deploy_main(self):
229-
"""Upgrade an instrument. Steps to do after ibex has been stopped but before it is restarted.
231+
def run_instrument_deploy_main(self) -> None:
232+
"""Upgrade an instrument. Steps to do after ibex has been stopped
233+
but before it is restarted.
230234
231235
Current the server can not be started or stopped in this python script.
232236
"""
@@ -253,7 +257,7 @@ def run_instrument_deploy_main(self):
253257
self._python_tasks.remove_instrument_script_githooks()
254258
self._server_tasks.setup_log_rotation()
255259

256-
def run_instrument_deploy_pre_stop(self):
260+
def run_instrument_deploy_pre_stop(self) -> None:
257261
"""Upgrade an instrument. Steps to do before ibex is stopped.
258262
259263
Current the server can not be started or stopped in this python script.
@@ -267,7 +271,7 @@ def run_instrument_deploy_pre_stop(self):
267271
bytes(central_inst_info, encoding="utf8")
268272
).decode("utf-8")
269273
central_inst_info = json.loads(central_inst_info)
270-
except:
274+
except Exception:
271275
central_inst_info = {}
272276

273277
central_specific_inst_info = None
@@ -284,24 +288,38 @@ def run_instrument_deploy_pre_stop(self):
284288

285289
self._server_tasks.save_motor_blocks_blockserver_to_file()
286290

287-
def run_truncate_database(self):
291+
def run_truncate_database(self) -> None:
288292
"""Backup and truncate databases only"""
289293
self._mysql_tasks.backup_database()
290294
self._mysql_tasks.truncate_database()
291295

292-
def run_force_upgrade_mysql(self):
296+
def run_force_upgrade_mysql(self) -> None:
293297
""":key
294298
Do upgrade of mysql, with data dump.
295299
"""
296300
self._mysql_tasks.install_mysql(force=True)
297301

298-
def run_developer_update(self):
302+
def run_upgrade_mysql(self) -> None:
303+
""":key
304+
Do upgrade of mysql with no table recreate.
305+
"""
306+
self._mysql_tasks.install_mysql(force=False)
307+
308+
def run_update_calibrations_repository(self) -> None:
309+
"""update_calibrations_repository"""
310+
self._server_tasks.update_calibrations_repository()
311+
312+
def run_setup_log_rotation(self) -> None:
313+
"""setup_log_rotation"""
314+
self._server_tasks.setup_log_rotation()
315+
316+
def run_developer_update(self) -> None:
299317
"""Update all the developer tools to latest version"""
300318
self._mysql_tasks.install_mysql(force=False)
301319
self._system_tasks.check_java_installation()
302320
self._system_tasks.install_or_upgrade_git()
303321

304-
def run_vhd_creation(self):
322+
def run_vhd_creation(self) -> None:
305323
"""Automated job which creates a set of VHDs containing all IBEX components.
306324
307325
Note: this will run under jenkins, don't add interactive tasks to this list.
@@ -331,21 +349,23 @@ def run_vhd_creation(self):
331349

332350
self._vhd_tasks.deploy_vhds()
333351

334-
def mount_vhds(self):
352+
def mount_vhds(self) -> None:
335353
"""Task which actually mounts the VHDs (will be run as admin)"""
336354
self._vhd_tasks.mount_vhds()
337355

338-
def dismount_vhds(self):
356+
def dismount_vhds(self) -> None:
339357
"""Task which actually dismounts the VHDs (will be run as admin)"""
340358
self._vhd_tasks.dismount_vhds()
341359

342-
def request_dismount_vhds(self):
360+
def request_dismount_vhds(self) -> None:
343361
"""Standalone task to request VHDs to be dismounted"""
344362
self._vhd_tasks.request_dismount_vhds()
345363

346-
def run_vhd_post_install(self):
347-
"""This job is run by the MDT build system when it has built a windows image and mounted the VHDS
348-
It will tidy up and remaining jobs that were not possible when the vdh was created e.g. register mysql service
364+
def run_vhd_post_install(self) -> None:
365+
"""This job is run by the MDT build system when it has built
366+
a windows image and mounted the VHDS
367+
It will tidy up and remaining jobs that were not possible when
368+
the vdh was created e.g. register mysql service
349369
"""
350370
# self._server_tasks.update_icp(self.icp_in_labview_modules())
351371
self._mysql_tasks.configure_mysql_for_vhd_post_install()
@@ -388,7 +408,19 @@ def run_vhd_post_install(self):
388408
),
389409
"force_upgrade_mysql": (
390410
UpgradeInstrument.run_force_upgrade_mysql,
391-
"upgrade mysql version to latest",
411+
"upgrade mysql version to latest and recreate tables",
412+
),
413+
"upgrade_mysql": (
414+
UpgradeInstrument.run_upgrade_mysql,
415+
"upgrade mysql version to latest but do not recreate tables",
416+
),
417+
"update_calibrations_repository": (
418+
UpgradeInstrument.run_update_calibrations_repository,
419+
"update calibrations repository",
420+
),
421+
"setup_log_rotation": (
422+
UpgradeInstrument.run_setup_log_rotation,
423+
"setup log rotation",
392424
),
393425
"developer_update": (UpgradeInstrument.run_developer_update, "install latest developer tools"),
394426
"create_vhds": (

installation_and_upgrade/ibex_install_utils/tasks/git_tasks.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,30 +32,32 @@ def checkout_to_release_branch(self) -> None:
3232
try:
3333
# assumes the alias 'origin' does not exist yet
3434
subprocess.check_call(
35-
f"cd {EPICS_PATH} && git remote add origin http://control-svcs.isis.cclrc.ac.uk/gitroot/releases/{version}/{remote_repo}",
35+
f"cd /d {EPICS_PATH} && git remote add origin http://control-svcs.isis.cclrc.ac.uk/gitroot/releases/{version}/{remote_repo}",
3636
shell=True,
3737
)
3838
print("Added the remote")
3939
except subprocess.CalledProcessError as e:
4040
print(f"Error creating remote: {e}")
4141

4242
try:
43-
subprocess.check_call(f"cd {EPICS_PATH} && git fetch", shell=True)
43+
subprocess.check_call(f"cd /d {EPICS_PATH} && git fetch", shell=True)
4444
print("Fetched remote")
4545
except subprocess.CalledProcessError as e:
4646
print(f"Error fetching remote: {e}")
4747

4848
try:
4949
# run a git status to rebuild index if needed
50-
subprocess.check_call(f"cd {EPICS_PATH} && git status", shell=True)
50+
subprocess.check_call(f"cd /d {EPICS_PATH} && git status", shell=True)
5151
except subprocess.CalledProcessError as e:
5252
print(f"Error running git status: {e}")
5353

5454
try:
55-
subprocess.check_call(f"cd {EPICS_PATH} && git checkout -b %COMPUTERNAME%", shell=True)
55+
subprocess.check_call(
56+
f"cd /d {EPICS_PATH} && git checkout -b %COMPUTERNAME%", shell=True
57+
)
5658
print("Checked out to the new release branch")
5759
subprocess.check_call(
58-
f"cd {EPICS_PATH} && git push -u origin %COMPUTERNAME%", shell=True
60+
f"cd /d {EPICS_PATH} && git push -u origin %COMPUTERNAME%", shell=True
5961
)
6062
print("Pushed to the remote")
6163
except subprocess.CalledProcessError as e:

0 commit comments

Comments
 (0)