Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions src/upgrade_step_from_14p0p0.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import socket

from src.common_upgrades.change_macros_in_xml import ChangeMacrosInXML
from src.common_upgrades.utils.macro import Macro
from src.file_access import FileAccess
from src.local_logger import LocalLogger
from src.upgrade_step import UpgradeStep


class UpgradeFrom14p0p0(UpgradeStep):
"""Set CARDS0 macro for all instruments,
except ARGUS/CHRONUS in which it is configured differently already"""

def perform(self, file_access: FileAccess, logger: LocalLogger) -> int:
try:
hostname = socket.gethostname()
# Make sure we do not perform this on ARGUS/CHRONUS where the macro is already present
if hostname not in ["NDXARGUS", "NDXCHRONUS"]:
ioc_name = "CAENV895"
change_macros_in_xml = ChangeMacrosInXML(file_access, logger)
change_macros_in_xml.add_macro(
ioc_name,
Macro("CARDS", "6"),
"^[0-9]+$",
"Number of cards in crate 0, leave blank if this crate does not exist",
"Yes",
)
return 0
except Exception as e:
logger.error("Unable to perform upgrade, caught error: {}".format(e))
return 1
7 changes: 5 additions & 2 deletions upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from src.upgrade_step_from_12p0p1 import AddOscCollimMovingIndicator
from src.upgrade_step_from_12p0p2 import UpgradeFrom12p0p2
from src.upgrade_step_from_12p0p3 import UpgradeFrom12p0p3
from src.upgrade_step_from_14p0p0 import UpgradeFrom14p0p0
from src.upgrade_step_noop import UpgradeStepNoOp

# A list of upgrade step tuples tuple is name of version to apply the upgrade to and upgrade class.
Expand Down Expand Up @@ -70,8 +71,10 @@
("12.0.3", UpgradeFrom12p0p3()),
("13.0.0", UpgradeStepNoOp()),
("13.0.1", UpgradeStepNoOp()),
("14.0.0", None),
# to add step see https://github.com/ISISComputingGroup/ibex_developers_manual/wiki/Config-Upgrader#adding-an-upgrade-step
("14.0.0", UpgradeFrom14p0p0()),
("15.0.0", None),
# to add step see
# https://github.com/ISISComputingGroup/ibex_developers_manual/wiki/Config-Upgrader#adding-an-upgrade-step
]

if __name__ == "__main__":
Expand Down