Пример #1
0
 def exec_pipeline(self, pstr):
     md = MDRepository()
     p = yaml.safe_load(six.StringIO(pstr))
     print("\n{}".format(yaml.dump(p)))
     pl = Plumbing(p, pid="test")
     res = pl.process(md, state={'batch': True, 'stats': {}})
     return res, md
Пример #2
0
    class PipelineCallback():
        """
A delayed pipeline callback used as a post for parse_metadata
        """
        def __init__(self, entry_point, req, stats):
            self.entry_point = entry_point
            self.plumbing = Plumbing(req.plumbing.pipeline, "%s-via-%s" % (req.plumbing.id, entry_point))
            self.req = req
            self.stats = stats

        def __call__(self, *args, **kwargs):
            t = args[0]
            if t is None:
                raise ValueError("PipelineCallback must be called with a parse-tree argument")
            try:
                return self.plumbing.process(self.req.md, state={self.entry_point: True, 'stats': self.stats}, t=t)
            except Exception, ex:
                traceback.print_exc(ex)
                raise ex