Пример #1
0
    async def process(self, data):
        LOG.info('company2data [{}] process {}'.format(self.job, data))
        config = self.config
        if config.ENV == 'DEV':
            return True
        async with aiohttp.ClientSession(loop=self._loop) as session:
            if 'corp_category' in data and int(data['corp_category']) != 1:
                LOG.warning(
                    'for job[{}], corp_category is invalid in {}'.format(
                        self.job, data))
                return False
            await self.pre_trans(session, data)
            # 上传公司(必要)
            company_increment_output = self.trans(
                data, config.CONFIG['DATA_MAP']['trans_company_increment_map'],
                None)
            await self.upload_company_increment(session,
                                                company_increment_output)

            # 上传产品(非必要)
            if not config.CONFIG['DATA_MAP'].get('trans_product_increment_map',
                                                 None):
                LOG.warning(
                    'for job[{}], trans_product_increment_map is invalid'.
                    format(self.job))
                return
            product_increment_output = self.trans(
                data, config.CONFIG['DATA_MAP']['trans_product_increment_map'],
                None)
            await self.upload_product_increment(session,
                                                product_increment_output)
Пример #2
0
    async def process(self, data):
        LOG.info('Kr2data process {}'.format(data))
        config = self.config
        async with aiohttp.ClientSession(loop=self._loop) as session:
            self.pre_trans(session, data)
            # 上传公司
            company_increment_output = self.trans(
                data, config.CONFIG['DATA_MAP']['trans_company_increment_map'],
                None)
            await self.upload_company_increment(session,
                                                company_increment_output)

            # 上传产品
            if not config.CONFIG['DATA_MAP'].get('trans_product_increment_map',
                                                 None):
                LOG.warning(
                    'for job[{}], trans_product_increment_map is invalid'.
                    format(self.job))
                return
            product_increment_output = self.trans(
                data, config.CONFIG['DATA_MAP']['trans_product_increment_map'],
                None)
            await self.upload_product_increment(session,
                                                product_increment_output)