Example #1
0
    def __init__(self, paths=None, tmplext=None):
        logger.debug(f"New Explorer at paths: {paths}")

        if not paths or paths is None:
            logger.warning(
                f"No path specified. Using current working directory.")
            self.paths = ['.']
        else:
            self.paths = paths

        self.tmplext = '.tpl' if tmplext is None else tmplext
Example #2
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        logger.debug(f"Creating Drawer for source: {self.source}")
        for dirpath, dirnames, filenames in \
                os.walk(self.source, followlinks=False):
            destpath = f"{self.dest}{dirpath[len(self.source):]}"

            for dirname in dirnames:
                self.records.append(
                    Folder(os.path.join(dirpath, dirname), self.tmplext))
                self.records[-1].dest = os.path.join(destpath, dirname)

            for fname in filenames:
                self.records.append(
                    File(os.path.join(dirpath, fname), self.tmplext))
                self.records[-1].dest = os.path.join(destpath, fname)
Example #3
0
    def render_path(self, destination):
        """Render path names"""
        env = Environment(loader=BaseLoader())
        content = env.from_string(destination)
        parsed_content = env.parse(destination)

        logger.debug(f"Rendering destination filename: {destination}")

        undefvars = meta.find_undeclared_variables(parsed_content)
        if not undefvars:
            logger.debug(f"Destination filename good as is: {destination}")
            yield destination, None

        else:
            for variable in undefvars:
                for confname, value in list(self._get_vars(variable)):
                    if confname is not None:
                        yield content.render({variable: confname}), value
Example #4
0
 def __init__(self, templates, config=None):
     self.tmpls = templates
     self.config = [] if config is None else config
     logger.debug(f"Launching renderer on templates: {templates}")
Example #5
0
from shadow.protocols import in_protocol_chains, SCSProxyServer


def init():
    context.in_protocol_stack = [SCSProxyServer]
    context.out_protocol_stack = []
    context.logger = logger


if __name__ == '__main__':
    init()
    loop = asyncio.get_event_loop()
    loop.set_debug(enabled=True)
    logging.getLogger('asyncio').setLevel(logging.DEBUG)
    get_server_proto = partial(in_protocol_chains, loop)
    coro = loop.create_server(get_server_proto, '0.0.0.0', 9999)

    logger.debug(context.in_protocol_stack)
    server = loop.run_until_complete(coro)
    try:
        loop.run_forever()
    except KeyboardInterrupt:
        pass

    # Close the server
    server.close()
    loop.run_until_complete(server.wait_closed())
    loop.shutdown_asyncgens()
    loop.stop()
    loop.close()
Example #6
0
 def __init__(self, path, tmplext='.tpl'):
     logger.debug(f"New Cabinet at {path}")
     self.source = path
     self.tmplext = tmplext