예제 #1
0
def main():
    """Pop the list of changed asins and take action on them."""
    while True:
        starttime = time.time()
        new_prices = []
        for asin in r.smembers('updated_asins'):
            message = get_latest_message(asin)
            r.srem('updated_asins', asin)  # remove memo to process asin
            if not isinstance(message, bool):
                # all rows of one message have the same date
                winner = get_buyboxwinner(message)
                own_skus = get_sku(asin)  # max one for each type
                sku, new_price = matchprice(own_skus, winner)
                if sku and new_price and boundaries(sku, new_price):
                    new_prices.append([sku, new_price])
                    # we store the action in redis
                    time_changed = message['time_changed'][0].isoformat()
                    # we will use the redis stream datatype
                    print(redis.__version__)
                    print(f'action: {asin}, {new_price}')
                    r.xadd(
                        'actions', {
                            'asin': asin,
                            'sku': sku,
                            'new_price': new_price,
                            'time_changed': time_changed
                        })

        feed_data = create_feed(new_prices)
        feeds_api = mws.Feeds(**helper.mwscred)
        feeds_api.submit_feed(feed_data, '_POST_FLAT_FILE_INVLOADER_DATA_')
        # We send maximum every 120 seconds a new feed to the mws api.
        time.sleep(120.0 - ((time.time() - starttime) % 120.0))
예제 #2
0
 def setUp(self):
     self.api = mws.Feeds(
         self.CREDENTIAL_ACCESS,
         self.CREDENTIAL_SECRET,
         self.CREDENTIAL_ACCOUNT,
         auth_token=self.CREDENTIAL_TOKEN
     )
     self.api._test_request_params = True
예제 #3
0
 def SubmitFeed(self, newfiles):
     # Setup API
     feeds_api = mws.Feeds(
         access_key=config['amazon']['accessKeyId'],
         secret_key=config['amazon']['secretAccessKey'],
         account_id=config['amazon']['merchantId'],
         region='UK',
     )
     # Upload each file
     results = []
     for file in newfiles:
         with open(file, 'r') as tsvfile:
             data = tsvfile.read()
         receive = feeds_api.submit_feed(
             feed=data.encode(),
             feed_type="_POST_FLAT_FILE_INVLOADER_DATA_")
         results.append(receive)
     return results
예제 #4
0
conf = config['MANNE']

#initialising
access_key = conf['aws_access_key_id']
secret_key = conf['secret_key']
account_id = conf['seller_id']
auth_token = conf['mws_auth_token']
bigbuy_api_key = conf['bigbuy_api_key']
de_marketplace = 'A1PA6795UKMFR9'
region = 'DE'

#initialising
bigbuy_url = 'https://api.bigbuy.eu'
bb_header = {'Authorization': 'Bearer ' + bigbuy_api_key}
feed_api = mws.Feeds(access_key=access_key,
                     secret_key=secret_key,
                     account_id=account_id,
                     auth_token=auth_token)
products_api = mws.Products(access_key=access_key,
                            secret_key=secret_key,
                            account_id=account_id,
                            auth_token=auth_token)
reports_api = mws.Reports(access_key=access_key,
                          secret_key=secret_key,
                          account_id=account_id,
                          auth_token=auth_token,
                          region=region)


def get_sku_list():
    #changed report_type
    report_request = reports_api.request_report(