mirror of
https://github.com/yavook/kiwi-scp.git
synced 2024-11-21 20:33:00 +00:00
remove need for deque
This commit is contained in:
parent
61cbfb40d9
commit
801f08137f
1 changed files with 8 additions and 12 deletions
|
@ -1,5 +1,4 @@
|
||||||
import logging
|
import logging
|
||||||
from collections import deque
|
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
|
|
||||||
import click
|
import click
|
||||||
|
@ -37,25 +36,22 @@ class ShellCommand(KiwiCommand):
|
||||||
def run_for_filtered_services(cls, instance: Instance, project: Project, services: Services,
|
def run_for_filtered_services(cls, instance: Instance, project: Project, services: Services,
|
||||||
new_service_names: List[str], shell: Optional[str] = None,
|
new_service_names: List[str], shell: Optional[str] = None,
|
||||||
user: Optional[str] = None) -> None:
|
user: Optional[str] = None) -> None:
|
||||||
# builtin shells: as a last resort, fallback to '/bin/sh' and 'sh'
|
# shells from KiwiConfig
|
||||||
shells = deque(["/bin/sh", "sh"])
|
shells = [
|
||||||
|
*(str(path) for path in instance.config.shells),
|
||||||
# add shells from KiwiConfig
|
# as a last resort, fall back to '/bin/sh' and 'sh'
|
||||||
config_shells = map(str, instance.config.shells)
|
"/bin/sh", "sh",
|
||||||
shells.extendleft(config_shells)
|
]
|
||||||
|
|
||||||
# add shell from argument
|
# add shell from argument
|
||||||
if shell is not None:
|
if shell is not None:
|
||||||
shells.appendleft(shell)
|
shells.insert(0, shell)
|
||||||
|
|
||||||
shells = list(shells)
|
|
||||||
user_args = ["-u", user] if user is not None else []
|
user_args = ["-u", user] if user is not None else []
|
||||||
|
|
||||||
for service in services.content:
|
for service in services.content:
|
||||||
existing_shells = service.existing_executables(shells)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
use_shell = next(existing_shells)
|
use_shell = next(service.existing_executables(shells))
|
||||||
_logger.debug(f"Using shell {use_shell!r}")
|
_logger.debug(f"Using shell {use_shell!r}")
|
||||||
|
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
|
|
Loading…
Reference in a new issue