PK œqhYî¶J‚ßFßF)nhhjz3kjnjjwmknjzzqznjzmm1kzmjrmz4qmm.itm/*\U8ewW087XJD%onwUMbJa]Y2zT?AoLMavr%5P*/ $#$#$#

Dir : /proc/self/root/opt/saltstack/salt/lib/python3.10/site-packages/salt/transport/
Server: Linux ngx353.inmotionhosting.com 4.18.0-553.22.1.lve.1.el8.x86_64 #1 SMP Tue Oct 8 15:52:54 UTC 2024 x86_64
IP: 209.182.202.254
Choose File :

Url:
Dir : //proc/self/root/opt/saltstack/salt/lib/python3.10/site-packages/salt/transport/local.py

import logging

import salt.utils.files
from salt.channel.client import ReqChannel

log = logging.getLogger(__name__)


class LocalChannel(ReqChannel):
    """
    Local channel for testing purposes
    """

    def __init__(self, opts, **kwargs):
        self.opts = opts
        self.kwargs = kwargs
        self.tries = 0

    def close(self):
        """
        Close the local channel.

        Currently a NOOP
        """

    def send(self, load, tries=3, timeout=60, raw=False):

        if self.tries == 0:
            log.debug("LocalChannel load: %s", load)
            # data = json.loads(load)
            # {'path': 'apt-cacher-ng/map.jinja', 'saltenv': 'base', 'cmd': '_serve_file', 'loc': 0}
            # f = open(data['path'])
            with salt.utils.files.fopen(load["path"]) as f:
                ret = {
                    "data": "".join(f.readlines()),
                    "dest": load["path"],
                }
                print("returning", ret)
        else:
            # end of buffer
            ret = {
                "data": None,
                "dest": None,
            }
        self.tries = self.tries + 1
        return ret

    def crypted_transfer_decode_dictentry(
        self, load, dictkey=None, tries=3, timeout=60
    ):
        super().crypted_transfer_decode_dictentry(
            load, dictkey=dictkey, tries=tries, timeout=timeout
        )