Skip to content

Commit

Permalink
Remove index argument. Strip index from CSC string when validating ar…
Browse files Browse the repository at this point in the history
…guments.
  • Loading branch information
rbovill committed Nov 1, 2024
1 parent a20f368 commit 5c0cea6
Showing 1 changed file with 7 additions and 28 deletions.
35 changes: 7 additions & 28 deletions python/lsst/ts/IntegrationTests/csc_state_transition.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,10 @@ def __init__(
self,
csc: str,
state: str,
csc_index: int = 0,
additional_configuration: str = "",
) -> None:
super().__init__()
self.csc = csc
self.csc_index = csc_index
self.state = state
self.added_config = additional_configuration
# Set the ScriptQueue index based on which telescope.
Expand All @@ -70,11 +68,7 @@ def __init__(
self.index = 1
# Construct the intermediate configuration list.
# Convert the list to a string.
if self.csc_index:
full_csc_name = f"{self.csc}:{self.csc_index}"
else:
full_csc_name = self.csc
temp_config = [full_csc_name, self.state]
temp_config = [self.csc, self.state]
if self.added_config:
temp_config.append(self.added_config)
config = ", ".join(str(i) for i in temp_config)
Expand Down Expand Up @@ -105,7 +99,6 @@ def csc_state_transition() -> None:
metavar="csc",
nargs="?",
type=str,
choices=csc_list,
help="Specify which CSC to command (case sensitive).",
)
parser.add_argument(
Expand All @@ -116,14 +109,6 @@ def csc_state_transition() -> None:
choices=state_list,
help="Specify to which state to transition.",
)
parser.add_argument(
"-x",
"--csc_index",
metavar="index",
nargs="?",
type=int,
help="Define the index of the CSC, if applicable.",
)
parser.add_argument(
"-a",
"--additional_configuration",
Expand All @@ -138,21 +123,16 @@ def csc_state_transition() -> None:
help="Print the allowed options.",
)
args = parser.parse_args()
# Print the help if the camera is not defined,
# or info is not passed.
if not (args.info or args.csc or args.state):
if args.info:
parser.print_help()
exit()
if args.info:
print(
f"\nThe allowed options are:\n"
f" csc:\t{csc_list}\n\n"
f" state:\t{state_list}\n"
)
# Print the help if the CSC or STATE is not defined.
if not (args.csc or args.state):
parser.print_help()
exit()
if args.csc not in utils.cscs:
if args.csc.split(":")[0] not in utils.cscs:
print(
f"Invalid CSC: {args.csc}. "
f"Invalid CSC: {args.csc.split(":")[0]}. "
f"Perhaps it is misspelled or not properly capitalized."
)
parser.print_help()
Expand All @@ -168,7 +148,6 @@ def main(opts: argparse.Namespace) -> None:
script_class = CSCStateTransition(
csc=opts.csc,
state=opts.state,
csc_index=opts.csc_index,
additional_configuration=opts.additional_configuration,
)
except KeyError as ke:
Expand Down

0 comments on commit 5c0cea6

Please sign in to comment.