How to use the yay.ast.AST function in yay

To help you get started, we’ve selected a few yay examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github yaybu / yaybu / yaybu / provisioner / changes / execute.py View on Github external
if isinstance(self.command, list):
            command = []
            for c in self.command:
                if isinstance(c, AST):
                    command.append(c.as_string())
                else:
                    command.append(c)
            logas = []
            for c in self.command:
                if isinstance(c, AST):
                    logas.append(c.as_safe_string())
                else:
                    logas.append(c)
        elif isinstance(self.command, basestring):
            logas = command = shlex.split(self.command.encode("UTF-8"))
        elif isinstance(self.command, AST):
            command = shlex.split(self.command.as_string().encode("UTF-8"))
            logas = shlex.split(self.command.as_safe_string().encode("UTF-8"))

        command = self._tounicode(command)
        logas = self._tounicode(logas)
        renderer.command(logas)

        env = {
            "PATH":
            "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
        }

        if self.env:
            for key, item in self.env.iteritems():
                env[key] = item
github yaybu / yaybu / yaybu / provisioner / changes / execute.py View on Github external
def apply(self, ctx, renderer):
        transport = ctx.transport

        if isinstance(self.command, list):
            command = []
            for c in self.command:
                if isinstance(c, AST):
                    command.append(c.as_string())
                else:
                    command.append(c)
            logas = []
            for c in self.command:
                if isinstance(c, AST):
                    logas.append(c.as_safe_string())
                else:
                    logas.append(c)
        elif isinstance(self.command, basestring):
            logas = command = shlex.split(self.command.encode("UTF-8"))
        elif isinstance(self.command, AST):
            command = shlex.split(self.command.as_string().encode("UTF-8"))
            logas = shlex.split(self.command.as_safe_string().encode("UTF-8"))

        command = self._tounicode(command)
github yaybu / yaybu / yaybu / provisioner / transports / base.py View on Github external
changeuser = (user != self.whoami())

        full_command = []
        if changeuser or group:
            full_command.append('sudo')
        if changeuser:
            full_command.extend(['-u', user])
        if group:
            full_command.extend(['-g', group])
        if changeuser or group:
            full_command.append("--")

        if isinstance(command, list):
            command = command[:]
            for i, segment in enumerate(command):
                if isinstance(segment, AST):
                    command[i] = segment.as_string()
            command = ' '.join([quote(c) for c in command])

        parts = []

        newenv = {}
        if self.env_passthrough:
            for var in self.env_passthrough:
                if var in os.environ:
                    newenv[var] = os.environ[var]

        if self.env:
            newenv.update(self.env)

        newenv.update({
            # "HOME": "/home/" + self.user,