コード例 #1
0
 def submit_feed(self, feed, feed_type, marketplaceids=None,
                 content_type="text/xml", purge=False):
     """
     Uploads a feed ( xml or .tsv ) to the seller's inventory.
     Can be used for creating/updating products on Amazon.
     """
     purge = 'true' if purge else 'false'
     data = dict(Action='SubmitFeed',
                 FeedType=feed_type,
                 PurgeAndReplace=purge)
     data.update(self.enumerate_param('MarketplaceIdList.Id.', marketplaceids))
     md = calc_md5(feed)
     return self.request(data, method="POST", body=feed,
                         extra_headers={'Content-MD5': md, 'Content-Type': content_type})
コード例 #2
0
ファイル: aws.py プロジェクト: robertocsp/elizaz
def get_feed_submission_result(seller_id, auth_token, feed_id):
    feeds_api = mws.Feeds(access_key=MWS_ACCESS_KEY,
                          secret_key=MWS_SECRET_KEY,
                          account_id=seller_id,
                          auth_token=auth_token)
    feed_submission_result_return = feeds_api.get_feed_submission_result(
        feed_id)
    content_md5 = calc_md5(
        feed_submission_result_return.response.content).decode('utf-8')
    if feed_submission_result_return.response.headers[
            'Content-MD5'] != content_md5:
        logger.error('DATA CORRUPTION')
        logger.error(feed_submission_result_return.original)
        logger.error(
            'header md5 :: %(header_md5)s != content md5 :: %(content_md5)s' %
            {
                'header_md5':
                feed_submission_result_return.response.headers['Content-MD5'],
                'content_md5':
                content_md5
            })
        raise DataCorruptionException()
    processing_report = feed_submission_result_return.parsed[
        'ProcessingReport']
    result_status = ['_DONE_']
    log_result = False
    if processing_report['StatusCode']['value'] != 'Complete':
        log_result = True
        result_status.append(processing_report['StatusCode']['value'].upper())
        result_status.append('_')
    processing_summary = processing_report['ProcessingSummary']
    if processing_summary:
        messages_with_error = int(
            processing_summary['MessagesWithError']['value'])
        messages_with_warning = int(
            processing_summary['MessagesWithWarning']['value'])
        if messages_with_error > 0:
            log_result = True
            result_status.append('_WITH_ERROR_')
        if messages_with_error > 0 and messages_with_warning > 0:
            result_status.append('_AND_')
        if messages_with_warning > 0:
            log_result = True
            result_status.append('_WITH_WARNING_')
    if log_result:
        logger.error(feed_submission_result_return.original)
    return ''.join(result_status)
コード例 #3
0
def test_calc_md5():
    assert calc_md5(b"mws") == b"mA5nPbh1CSx9M3dbkr3Cyg=="
コード例 #4
0
def test_calc_md5():
    assert calc_md5(b'mws') == b'mA5nPbh1CSx9M3dbkr3Cyg=='