示例#1
0
    def process_closed_market(self, market, data: dict) -> None:
        market_id = data.get(self.MARKET_ID_LOOKUP)
        if market_id in self._loaded_markets:
            if self._force_update:
                logger.warning(
                    "File: /{0}/{1}/{2} has already been loaded, updating..".
                    format(self.local_dir, self.recorder_id, market_id))
            else:
                return
        else:
            self._loaded_markets.append(market_id)
        logger.info("Closing market %s" % market_id)

        file_dir = os.path.join(self.local_dir, self.recorder_id, market_id)
        market_definition = data.get("marketDefinition")

        # check that file actually exists
        if not os.path.isfile(file_dir):
            logger.error("File: %s does not exist in /%s/%s/" %
                         (self.local_dir, market_id, self.recorder_id))
            return

        # check that file is not empty / 1 line (i.e. the market had already closed on startup)
        line_count = file_line_count(file_dir)
        if line_count == 1:
            logger.warning(
                "File: %s contains one line only and will not be loaded (already closed on startup)"
                % file_dir)
            return

        self._queue.put((market, file_dir, market_definition))
示例#2
0
 def test_file_line_count(self):
     self.assertGreater(utils.file_line_count(__file__), 10)