Exemple #1
0
    def watch(self):
        logging.info("Starting watch for collection %s",
                     self.metadata["collection"])

        data = yield Query(self.settings["database"],
                           self.metadata["collection"],
                           manipulate=self.metadata["manipulate"]).find(
                               projection=self.metadata["projection"],
                               sort=self.metadata["sort"],
                               limit=self.metadata["limit"])

        filtered_data = []
        for item in data:
            filtered_item = self.filter_data(item)
            if filtered_item:
                filtered_data.append(filtered_item)

        self.callback(
            dict(action=self.message["action"],
                 operation="watched",
                 correlation=self.message["correlation"],
                 status_code=200,
                 body=filtered_data))

        add_callback(self.metadata["collection"], self.data_callback)
Exemple #2
0
    def watch(self):
        logging.info("Starting watch for collection %s", self.metadata["collection"])

        data = yield Query(
            self.settings["database"],
            self.metadata["collection"],
            manipulate=self.metadata["manipulate"]).find(
                projection=self.metadata["projection"],
                sort=self.metadata["sort"],
                limit=self.metadata["limit"])

        filtered_data = []
        for item in data:
            filtered_item = self.filter_data(item)
            if filtered_item:
                filtered_data.append(filtered_item)

        self.callback(dict(
            action=self.message["action"],
            operation="watched",
            correlation=self.message["correlation"],
            status_code=200,
            body=filtered_data
        ))

        add_callback(self.metadata["collection"], self.data_callback)
Exemple #3
0
    def sync_loop(self):
        logging.info("Initializing sync loop.")
        yield add_callback("Settings", self.update_repo)

        synced_head = None

        settings = yield Query(self.database, "Settings").find_one() or dict()
        if settings["charts"]:
            self.url = settings["charts"]["repo_url"]

        while True:
            try:
                if self.url != self.repo.remotes.origin.url:
                    logging.info("Changing reference from '%s' to '%s'.",
                                 self.repo.remotes.origin.url, self.url)
                    self.repo.delete_remote('origin')
                    self.repo.create_remote('origin', url=self.url)
                    synced_head = None

                self.repo.git.fetch('--all')
                self.repo.git.reset('--hard', 'origin/master')

                if synced_head != self.repo.head.ref.commit:
                    yield self.sync()
                    synced_head = self.repo.head.ref.commit

            except:
                logging.exception("Failed to pull repository.")

            yield sleep(5)
Exemple #4
0
    def sync_loop(self):
        logging.info("Initializing sync loop.")
        yield add_callback("Settings", self.update_repo)

        synced_head = None

        settings = yield Query(self.database, "Settings").find_one() or dict()
        if settings["charts"]:
            self.url = settings["charts"]["repo_url"]

        while True:
            try:
                if self.url != self.repo.remotes.origin.url:
                    logging.info("Changing reference from '%s' to '%s'.", self.repo.remotes.origin.url, self.url)
                    self.repo.delete_remote('origin')
                    self.repo.create_remote('origin', url=self.url)
                    synced_head = None

                self.repo.git.fetch('--all')
                self.repo.git.reset('--hard', 'origin/master')

                if synced_head != self.repo.head.ref.commit:
                    yield self.sync()
                    synced_head = self.repo.head.ref.commit

            except:
                logging.exception("Failed to pull repository.")

            yield sleep(5)
Exemple #5
0
    def watch(self):
        action = self.message["action"]
        logging.info("Starting watch for collection %s", ACTIONS_METADATA[action]["collection"])

        data = yield Query(self.settings["database"], ACTIONS_METADATA[action]["collection"]).find(
            projection=ACTIONS_METADATA[action]["projection"])

        data = self.filter_data(data)
        self.callback(dict(
            action=self.message["action"],
            operation="watched",
            correlation=self.message["correlation"],
            status_code=200,
            body=data
        ))

        add_callback(ACTIONS_METADATA[self.message["action"]]["collection"], self.data_callback)
Exemple #6
0
    def watch(self):
        logging.info("Starting watch for collection %s",
                     self.metadata["collection"])

        data = yield Query(self.settings["database"],
                           self.metadata["collection"],
                           manipulate=self.metadata["manipulate"]).find(
                               projection=self.metadata["projection"])

        data = self.filter_data(data)
        self.callback(
            dict(action=self.message["action"],
                 operation="watched",
                 correlation=self.message["correlation"],
                 status_code=200,
                 body=data))

        add_callback(self.metadata["collection"], self.data_callback)
Exemple #7
0
    def watch(self):
        logging.info("Starting watch for collection %s", self.metadata["collection"])

        data = yield Query(
            self.settings["database"],
            self.metadata["collection"],
            manipulate=self.metadata["manipulate"]).find(projection=self.metadata["projection"])

        data = self.filter_data(data)
        self.callback(dict(
            action=self.message["action"],
            operation="watched",
            correlation=self.message["correlation"],
            status_code=200,
            body=data
        ))

        add_callback(self.metadata["collection"], self.data_callback)
Exemple #8
0
    def watch(self):
        action = self.message["action"]
        logging.info("Starting watch for collection %s",
                     ACTIONS_METADATA[action]["collection"])

        data = yield Query(
            self.settings["database"],
            ACTIONS_METADATA[action]["collection"]).find(
                projection=ACTIONS_METADATA[action]["projection"])

        data = self.filter_data(data)
        self.callback(
            dict(action=self.message["action"],
                 operation="watched",
                 correlation=self.message["correlation"],
                 status_code=200,
                 body=data))

        add_callback(ACTIONS_METADATA[self.message["action"]]["collection"],
                     self.data_callback)