presta_api.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:prestashop-sync 作者: dragoon 项目源码 文件源码
def add_images(self, product_ids, images):
        domain = self.shop.domain
        headers = {'Content-Type': MULTIPART_CONTENT,
                   'Authorization': self.shop.authheader}
        for i, p_images in enumerate(images):
            # TODO: why sometimes index does not exist?
            if i >= len(product_ids):
                send_email.delay('mail/error', {'domain': domain, 'message': str(product_ids),
                                                'data_list': '',
                                                'full_data': ''}, "Add images error")
                break
            product_id = product_ids[i]
            for image in p_images:
                data = encode_multipart(BOUNDARY, {'image': image})
                req = urllib2.Request(smart_str("http://%s/api/images/products/%s" % (domain, product_id)),
                                      headers=headers, data=smart_str(data))
                urllib2.urlopen(req)
        self.make_first_image_default(product_ids, headers)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号