예제 #1
0
파일: streams.py 프로젝트: maximerobin/Ufwi
    def __call__(self, **args):
        s = set(args.keys()).difference(set(self.default_args.keys()))
        try:
            if not s:
                d = succeed([self.get_file_value(self.ACCEPTED_PATH, self.DROPPED_PATH)])
            elif len(s) == 1 and "raw_label" in args:
                if int(args["raw_label"]) == 0:
                    d = succeed([self.get_file_value(self.DROPPED_PATH)])
                else:
                    d = succeed([self.get_file_value(self.ACCEPTED_PATH)])
            else:
                raise IOError()
        except IOError:
            d = self._sql_query(args, "count_packets").addCallback(self._sendSQLToStream)

        d.addCallback(self._returnPacket)
        return d
예제 #2
0
    def service_new(self, ctx, title, enterprise, interval, logo, scenario, filters):
        session = ctx.getSession()
        if 'report' in session:
            raise AlreadyEditingReport(tr("You are already in a report edition"))

        report = Report(title, enterprise, interval, b64decode(logo))
        session['report'] = report

        d = succeed(True)
        for command in scenario:
            for args in command:
                if isinstance(args, dict):
                    # Predefined args are more prioritary than user filters.
                    saved_args = args.copy()
                    args.clear()
                    args.update(filters)
                    args.update(saved_args)
            d.addCallback(self.lambda_callService(ctx, 'reporting', *command))

        return d