Exemplo n.º 1
0
    def __init__(self, directory_path, *args):
        """See Task.__init__"""
        super().__init__()
        self.directory_path = xtask.parse_path(directory_path)

        self.args = []
        for arg in args:
            arg = xtask.task_variables_to_value(arg)
            self.args.append(arg)
Exemplo n.º 2
0
    def start(self, process_name, *args):
        """Starts a process."""
        if Process.is_running(process_name):
            self._error("Process '{}' is already running".format(process_name))
            return False

        if len(args) < 2:
            self._error("'directory' and 'command' arguments not given but mandatory")
            return False

        directory_path = xtask.parse_path(args[0])

        if not directory_path.exists():
            self._error("Location {} does not exist".format(directory_path))
            return False

        command = args[1]
        args = list(args[2:])

        if command.startswith("."):
            command_path = directory_path / command
            if not command_path.exists():
                self._error("Cannot find command {}".format(command_path))
            else:
                command = str(command_path)
        elif pexpect.which(command) is None:
            self._error("Unknown command '{}'".format(command))
            return False

        try:
            self._info(
                "Starting process '{}' by calling '{} {}' in directory {}".format(
                    process_name, command, " ".join(args), directory_path
                )
            )
            process = pexpect.spawn(command, args, cwd=directory_path, timeout=5)
            Process._processes[process_name] = process
        except Exception:
            self._exception(
                "Something went wrong while starting process '{}'".format(process_name)
            )
            return False

        return True
Exemplo n.º 3
0
 def __init__(self, directory_path):
     """See `Task.__init__`."""
     super().__init__()
     self.directory_path = xtask.parse_path(directory_path)
Exemplo n.º 4
0
 def __init__(self, file_path):
     """See `Task.__init__`."""
     super().__init__()
     self.file_path = xtask.parse_path(file_path)
Exemplo n.º 5
0
 def __init__(self, directory_path, target_directory_path):
     """See `Task.__init__`"""
     super().__init__()
     self.directory_path = xtask.parse_path(directory_path)
     self.target_directory_path = xtask.parse_path(target_directory_path)
Exemplo n.º 6
0
 def __init__(self, repo_link, repo_path):
     """See `Task.__init__`"""
     super().__init__()
     self.repo_link = repo_link
     self.repo_path = xtask.parse_path(repo_path)
Exemplo n.º 7
0
 def __init__(self, repo_path):
     """See Task.__init__"""
     super().__init__()
     self.repo_path = xtask.parse_path(repo_path)
Exemplo n.º 8
0
 def __init__(self, resource_name, destination_path):
     """See `Task.__init__`"""
     super().__init__()
     self.resource_name = resource_name
     self.destination_path = xtask.parse_path(destination_path)
Exemplo n.º 9
0
 def __init__(self, tarfile_path, extract_path):
     """See `Task.__init__`."""
     super().__init__()
     self.tarfile_path = xtask.parse_path(tarfile_path)
     self.extract_path = xtask.parse_path(extract_path)
Exemplo n.º 10
0
 def __init__(self, link_location, link_target):
     """See `Task.__init__`."""
     super().__init__()
     self.link_location = xtask.parse_path(link_location)
     self.link_target = xtask.parse_path(link_target)