from parallels.core.logging import get_logger
from parallels.core.runners.base import BaseRunner
from parallels.core.utils import windows_utils

logger = get_logger(__name__)


class WindowsRunner(BaseRunner):
    def file_exists(self, filename):
        raise NotImplementedError()

    def _format_run_command(self, cmd, args=None):
        """Format command arguments passed for 'run' and 'run_unchecked' methods into command line string

        This command line will be added to log and error messages, so it is expected that you could
        simply copy-paste it from logs or migrator output, and execute.

        :type cmd: str | unicode
        :type args: list[str | unicode] | None
        :rtype: str | unicode
        """
        return windows_utils.format_command_list(cmd, args)

    def _format_command(self, cmd, args=None):
        """Format command arguments passed for 'sh' and 'sh_unchecked' methods into command line string

        This command line will be added to log and error messages, so it is expected that you could
        simply copy-paste it from logs or migrator output, and execute.

        :type cmd: str | unicode
        :type args: dict[str | unicode, str | unicode] | None
        """
        if args is not None and len(args) > 0:
            return windows_utils.format_command(cmd, **args)
        else:
            return cmd
