Parse an az command into a list of arguments for subprocess.run
(command)
| 23 | |
| 24 | |
| 25 | def _parse_az_command(command): |
| 26 | '''Parse an az command into a list of arguments for subprocess.run''' |
| 27 | if isinstance(command, list): |
| 28 | args = command |
| 29 | elif isinstance(command, str): |
| 30 | args = command.split() |
| 31 | else: |
| 32 | raise ValueError(f'az command must be a string or list, not {type(command)}') |
| 33 | |
| 34 | az = shutil.which('az') |
| 35 | if args[0] == 'az': |
| 36 | args.pop(0) |
| 37 | if args[0] != az: |
| 38 | args = [az] + args |
| 39 | |
| 40 | return args |
| 41 | |
| 42 | |
| 43 | def _az(command, log_command=True): |