def __init__(self):
     MerchantBaseLogic.__init__(self)
     global settings
     self.settings = settings
     '''
         Internal state handling
     '''
     self.execQueue = []
     '''
         Information store
     '''
     self.products = {}
     self.offers = {}
     '''
         Predefined API token
     '''
     self.merchant_id = settings['merchant_id']
     self.merchant_token = merchant_token
     '''
         Setup API
     '''
     PricewarsRequester.add_api_token(self.merchant_token)
     self.marketplace_api = MarketplaceApi(
         host=self.settings['marketplace_url'])
     self.producer_api = ProducerApi(host=self.settings['producer_url'])
     '''
         Start Logic Loop
     '''
     self.run_logic_loop()
Exemple #2
0
 def __init__(self):
     MerchantBaseLogic.__init__(self)
     global settings
     self.settings = settings
     '''
         Predefined API token
     '''
     self.merchant_id = settings['merchant_id']
     self.merchant_token = merchant_token
     '''
         Setup API
     '''
     PricewarsRequester.add_api_token(self.merchant_token)
     self.marketplace_api = MarketplaceApi(
         host=self.settings['marketplace_url'])
     self.producer_api = ProducerApi(host=self.settings['producer_url'])
     '''
         Setup ML model
     '''
     self.models_per_product = self.load_models_from_filesystem()
     self.last_learning = datetime.datetime.now()
     trigger_learning(self.merchant_token, self.merchant_id,
                      settings['kafka_reverse_proxy_url'])
     '''
         Start Logic Loop
     '''
     self.run_logic_loop()
def download_kafka_files(merchant_token, kafka_url):
    logging.debug('Downloading files from Kafka ...')
    PricewarsRequester.add_api_token(merchant_token)
    kafka_api = KafkaApi(host=kafka_url)
    data_url_ms = kafka_api.request_csv_export_for_topic('marketSituation')
    data_url_bo = kafka_api.request_csv_export_for_topic('buyOffer')
    return requests.get(data_url_ms, timeout=2), requests.get(data_url_bo,
                                                              timeout=2)
Exemple #4
0
 def __init__(self):
     MerchantBaseLogic.__init__(self)
     global settings
     self.settings = settings
     '''
         Predefined API token
     '''
     self.merchant_id = settings['merchant_id']
     self.merchant_token = merchant_token
     '''
         Setup API
     '''
     PricewarsRequester.add_api_token(self.merchant_token)
     self.marketplace_api = MarketplaceApi(
         host=self.settings['marketplace_url'])
     self.producer_api = ProducerApi(host=self.settings['producer_url'])
     '''
         Start Logic Loop
     '''
     self.run_logic_loop()
        return

    output = open(args.output, "w")
    output.write(str(result))
    output.close()


if __name__ == '__main__':
    print('\n\n---------------------------------------')
    sys.stdout.flush()
    print('start learning')
    args = parse_arguments()

    if (args.token is not None):
        merchant_token = args.token
        PricewarsRequester.add_api_token(merchant_token)
        merchant_id = base64.b64encode(
            hashlib.sha256(
                merchant_token.encode('utf-8')).digest()).decode('utf-8')

    if (args.merchant is not None):
        merchant_id = args.merchant

    kafka_host = args.kafka_host
    kafka_api = KafkaApi(host=kafka_host)

    print('load')
    if ((args.buy is not None) and args.train is not None):
        load_offline()
    else:
        try:
Exemple #6
0
 def __init__(self, merchant_token, marketplace_url, producer_url):
     PricewarsRequester.add_api_token(merchant_token)
     self.marketplace_api = MarketplaceApi(host=marketplace_url)
     self.producer_api = ProducerApi(host=producer_url)
     self.request_counter = 0