コード例 #1
0
 def run_command(
     cls,
     cmd,  # type: Union[List[str], CommandArgs]
     show_stdout=True,  # type: bool
     cwd=None,  # type: Optional[str]
     on_returncode="raise",  # type: Literal["raise", "warn", "ignore"]
     extra_ok_returncodes=None,  # type: Optional[Iterable[int]]
     command_desc=None,  # type: Optional[str]
     extra_environ=None,  # type: Optional[Mapping[str, Any]]
     spinner=None,  # type: Optional[SpinnerInterface]
     log_failed_cmd=True,  # type: bool
     stdout_only=False,  # type: bool
 ):
     # type: (...) -> str
     """
     Run a VCS subcommand
     This is simply a wrapper around call_subprocess that adds the VCS
     command name, and checks that the VCS is available
     """
     cmd = make_command(cls.name, *cmd)
     try:
         return call_subprocess(
             cmd,
             show_stdout,
             cwd,
             on_returncode=on_returncode,
             extra_ok_returncodes=extra_ok_returncodes,
             command_desc=command_desc,
             extra_environ=extra_environ,
             unset_environ=cls.unset_environ,
             spinner=spinner,
             log_failed_cmd=log_failed_cmd,
             stdout_only=stdout_only,
         )
     except FileNotFoundError:
         # errno.ENOENT = no such file or directory
         # In other words, the VCS executable isn't available
         raise BadCommand(
             f"Cannot find command {cls.name!r} - do you have "
             f"{cls.name!r} installed and in your PATH?"
         )
     except PermissionError:
         # errno.EACCES = Permission denied
         # This error occurs, for instance, when the command is installed
         # only for another user. So, the current user don't have
         # permission to call the other user command.
         raise BadCommand(
             f"No permission to execute {cls.name!r} - install it "
             f"locally, globally (ask admin), or check your PATH. "
             f"See possible solutions at "
             f"https://pip.pypa.io/en/latest/reference/pip_freeze/"
             f"#fixing-permission-denied."
         )
コード例 #2
0
 def run_command(
     cls,
     cmd,  # type: Union[List[str], CommandArgs]
     cwd=None,  # type: Optional[str]
     extra_environ=None,  # type: Optional[Mapping[str, Any]]
     extra_ok_returncodes=None,  # type: Optional[Iterable[int]]
     log_failed_cmd=True,  # type: bool
 ):
     # type: (...) -> Text
     """
     Run a VCS subcommand
     This is simply a wrapper around call_subprocess that adds the VCS
     command name, and checks that the VCS is available
     """
     cmd = make_command(cls.name, *cmd)
     try:
         return call_subprocess(
             cmd,
             cwd,
             extra_environ=extra_environ,
             extra_ok_returncodes=extra_ok_returncodes,
             log_failed_cmd=log_failed_cmd,
         )
     except OSError as e:
         # errno.ENOENT = no such file or directory
         # In other words, the VCS executable isn't available
         if e.errno == errno.ENOENT:
             raise BadCommand(
                 "Cannot find command {cls.name!r} - do you have "
                 "{cls.name!r} installed and in your "
                 "PATH?".format(**locals())
             )
         else:
             raise  # re-raise exception if a different error occurred
コード例 #3
0
 def run_command(self,
                 cmd,
                 show_stdout=True,
                 cwd=None,
                 on_returncode='raise',
                 command_desc=None,
                 extra_environ=None,
                 spinner=None):
     """
     Run a VCS subcommand
     This is simply a wrapper around call_subprocess that adds the VCS
     command name, and checks that the VCS is available
     """
     cmd = [self.name] + cmd
     try:
         return call_subprocess(cmd,
                                show_stdout,
                                cwd,
                                on_returncode,
                                command_desc,
                                extra_environ,
                                unset_environ=self.unset_environ,
                                spinner=spinner)
     except OSError as e:
         # errno.ENOENT = no such file or directory
         # In other words, the VCS executable isn't available
         if e.errno == errno.ENOENT:
             raise BadCommand('Cannot find command %r - do you have '
                              '%r installed and in your '
                              'PATH?' % (self.name, self.name))
         else:
             raise  # re-raise exception if a different error occurred
コード例 #4
0
ファイル: versioncontrol.py プロジェクト: wai123999/pip
 def run_command(
     cls,
     cmd,  # type: Union[List[str], CommandArgs]
     cwd=None,  # type: Optional[str]
     extra_environ=None,  # type: Optional[Mapping[str, Any]]
     extra_ok_returncodes=None,  # type: Optional[Iterable[int]]
     log_failed_cmd=True  # type: bool
 ):
     # type: (...) -> str
     """
     Run a VCS subcommand
     This is simply a wrapper around call_subprocess that adds the VCS
     command name, and checks that the VCS is available
     """
     cmd = make_command(cls.name, *cmd)
     try:
         return call_subprocess(cmd, cwd,
                                extra_environ=extra_environ,
                                extra_ok_returncodes=extra_ok_returncodes,
                                log_failed_cmd=log_failed_cmd)
     except FileNotFoundError:
         # errno.ENOENT = no such file or directory
         # In other words, the VCS executable isn't available
         raise BadCommand(
             'Cannot find command {cls.name!r} - do you have '
             '{cls.name!r} installed and in your '
             'PATH?'.format(**locals()))
コード例 #5
0
    def run_command(
            cls,
            cmd,  # type: Union[List[str], CommandArgs]
            show_stdout=True,  # type: bool
            cwd=None,  # type: Optional[str]
            on_returncode='raise',  # type: str
            extra_ok_returncodes=None,  # type: Optional[Iterable[int]]
            command_desc=None,  # type: Optional[str]
            extra_environ=None,  # type: Optional[Mapping[str, Any]]
            spinner=None,  # type: Optional[SpinnerInterface]
            log_failed_cmd=True,  # type: bool
            stdout_only=False,  # type: bool
    ):

        # type: (...) -> str
        """

        Run a VCS subcommand

        This is simply a wrapper around call_subprocess that adds the VCS

        command name, and checks that the VCS is available

        """

        cmd = make_command(cls.name, *cmd)

        try:

            return call_subprocess(cmd,
                                   show_stdout,
                                   cwd,
                                   on_returncode=on_returncode,
                                   extra_ok_returncodes=extra_ok_returncodes,
                                   command_desc=command_desc,
                                   extra_environ=extra_environ,
                                   unset_environ=cls.unset_environ,
                                   spinner=spinner,
                                   log_failed_cmd=log_failed_cmd,
                                   stdout_only=stdout_only)

        except FileNotFoundError:

            # errno.ENOENT = no such file or directory

            # In other words, the VCS executable isn't available

            raise BadCommand('Cannot find command {cls.name!r} - do you have '
                             '{cls.name!r} installed and in your '
                             'PATH?'.format(**locals()))
コード例 #6
0
 def run_command(
     cls,
     cmd,  # type: Union[List[str], CommandArgs]
     show_stdout=True,  # type: bool
     cwd=None,  # type: Optional[str]
     on_returncode="raise",  # type: str
     extra_ok_returncodes=None,  # type: Optional[Iterable[int]]
     command_desc=None,  # type: Optional[str]
     extra_environ=None,  # type: Optional[Mapping[str, Any]]
     spinner=None,  # type: Optional[SpinnerInterface]
     log_failed_cmd=True,  # type: bool
 ):
     # type: (...) -> Text
     """
     Run a VCS subcommand
     This is simply a wrapper around call_subprocess that adds the VCS
     command name, and checks that the VCS is available
     """
     cmd = make_command(cls.name, *cmd)
     try:
         return call_subprocess(
             cmd,
             show_stdout,
             cwd,
             on_returncode=on_returncode,
             extra_ok_returncodes=extra_ok_returncodes,
             command_desc=command_desc,
             extra_environ=extra_environ,
             unset_environ=cls.unset_environ,
             spinner=spinner,
             log_failed_cmd=log_failed_cmd,
         )
     except OSError as e:
         # errno.ENOENT = no such file or directory
         # In other words, the VCS executable isn't available
         if e.errno == errno.ENOENT:
             raise BadCommand(
                 "Cannot find command %r - do you have "
                 "%r installed and in your "
                 "PATH?" % (cls.name, cls.name)
             )
         else:
             raise  # re-raise exception if a different error occurred
コード例 #7
0
 def run_command(
     cls,
     cmd,  # type: List[str]
     show_stdout=True,  # type: bool
     cwd=None,  # type: Optional[str]
     on_returncode='raise',  # type: str
     extra_ok_returncodes=None,  # type: Optional[Iterable[int]]
     command_desc=None,  # type: Optional[str]
     extra_environ=None,  # type: Optional[Mapping[str, Any]]
     spinner=None  # type: Optional[SpinnerInterface]
 ):
     # type: (...) -> Optional[Text]
     """
     Run a VCS subcommand
     This is simply a wrapper around call_subprocess that adds the VCS
     command.py name, and checks that the VCS is available
     """
     cmd = [cls.name] + cmd
     try:
         return call_subprocess(cmd,
                                show_stdout,
                                cwd,
                                on_returncode=on_returncode,
                                extra_ok_returncodes=extra_ok_returncodes,
                                command_desc=command_desc,
                                extra_environ=extra_environ,
                                unset_environ=cls.unset_environ,
                                spinner=spinner)
     except OSError as e:
         # errno.ENOENT = no such file or directory
         # In other words, the VCS executable isn't available
         if e.errno == errno.ENOENT:
             raise BadCommand('Cannot find command.py %r - do you have '
                              '%r installed and in your '
                              'PATH?' % (cls.name, cls.name))
         else:
             raise  # re-raise exception if a different error occurred
コード例 #8
0
 def run_command(
     cls,
     cmd,  # type: Union[List[str], CommandArgs]
     cwd=None,  # type: Optional[str]
     extra_environ=None,  # type: Optional[Mapping[str, Any]]
     extra_ok_returncodes=None,  # type: Optional[Iterable[int]]
     log_failed_cmd=True  # type: bool
 ):
   
     cmd = make_command(cls.name, *cmd)
     try:
         return call_subprocess(cmd, cwd,
                                extra_environ=extra_environ,
                                extra_ok_returncodes=extra_ok_returncodes,
                                log_failed_cmd=log_failed_cmd)
     except OSError as e:
        
         if e.errno == errno.ENOENT:
             raise BadCommand(
                 'Cannot find command {cls.name!r} - do you have '
                 '{cls.name!r} installed and in your '
                 'PATH?'.format(**locals()))
         else:
             raise  # re-raise exception if a different error occurred
コード例 #9
0
=======
            return call_subprocess(cmd, show_stdout, cwd,
                                   on_returncode=on_returncode,
                                   extra_ok_returncodes=extra_ok_returncodes,
                                   command_desc=command_desc,
                                   extra_environ=extra_environ,
                                   unset_environ=cls.unset_environ,
                                   spinner=spinner,
>>>>>>> b66a76afa15ab74019740676a52a071b85ed8f71
                                   log_failed_cmd=log_failed_cmd)
        except OSError as e:
            # errno.ENOENT = no such file or directory
            # In other words, the VCS executable isn't available
            if e.errno == errno.ENOENT:
                raise BadCommand(
                    'Cannot find command {cls.name!r} - do you have '
                    '{cls.name!r} installed and in your '
                    'PATH?'.format(**locals()))
            else:
                raise  # re-raise exception if a different error occurred

    @classmethod
    def is_repository_directory(cls, path):
        # type: (str) -> bool
        """
        Return whether a directory path is a repository directory.
        """
        logger.debug('Checking in %s for %s (%s)...',
                     path, cls.dirname, cls.name)
        return os.path.exists(os.path.join(path, cls.dirname))

    @classmethod