Ejemplo n.º 1
0
 def get(self):
     s = Services()
     result = s.get_pages(7)
     return {
         'ans': 'HelloWorld',
         'daa': result
     }
Ejemplo n.º 2
0
def copy_all_product_to_imp():
    """
    Copy all product from price_ofert to imp_product
    """
    log.info('Run copy all product from price_ofert to imp_price')
    s = ImpPriceServices()
    s.copu_all_produc_to_imp()
Ejemplo n.º 3
0
def run_parasing_pages(shop_id=None,
                       url_str=None,
                       entry_point_id=None,
                       limit=None,
                       interval=None):
    """
    Run parasing product page for shop_id, Run as task celery
    """
    import time
    from price.tasks import product_page_parase
    ipp = ImpPriceServices()
    if limit is not None:
        limit = int(limit) - 1
    oi = 0
    for oi, result in enumerate(ipp.get_pages(shop_id, url_str,
                                              entry_point_id)):
        if limit is not None and oi > limit:
            log.info('I stop working because a limit has been set: {}'.format(
                limit + 1))
            break
        log.info('I order url processing: {}'.format(result.url))
        product_page_parase.delay(result)
        if interval:
            log.info('Wait ... {} s.'.format(interval))
            time.sleep(int(interval))
    log.info('I oreder {} tasks'.format(oi))
Ejemplo n.º 4
0
def tag_category(imp_catalog_page_id=None, creation_date=None):
    from price.modules.imp_price.services import Services
    from price.tasks import add_category_assignment
    s = Services()
    for result in s.get_list_pages(imp_catalog_page_id, creation_date):
        log.info('Order tag category {}'.format(result))
        tp = s.get_tagging_product(result.imp_catalog_page_id)
        add_category_assignment.delay(tp)
Ejemplo n.º 5
0
 def get(self, imp_catalog_page_id):
     s = Services()
     result = s.get_product_images(imp_catalog_page_id)
     log.debug('Result : %r', result)
     if result:
         return result.images
     else:
         return None
Ejemplo n.º 6
0
 def get(self, field, value):
     s = Services()
     # lista = s.search_product_by_category(value)
     # log.info('To jest lista %r', lista)
     return [
         k.imp_catalog_page_id
         for k in s.search_product_by_category(value)
     ]
Ejemplo n.º 7
0
def try_download_page(url, show_log=False):
    """
    Try download and parse product page
    """
    s = ImpPriceServices()
    if show_log:
        show_log = bool(show_log)
    s.try_download_page(url, show_log)
Ejemplo n.º 8
0
def add_tag_synonym(context, value):
    from price.tasks import tagging_product
    from price.modules.tager.services import Services
    s = Services()
    tag = s.add_tag_synonym(context, value)
    for imp_catalog_page_id, title in s.get_list_results_by_string(tag):
        log.info('Order for tagging: {} ImpID: {}'.format(
            title, imp_catalog_page_id))
        tagging_product.delay(imp_catalog_page_id, title)
Ejemplo n.º 9
0
def tag_unprocessed(scan_date=None):
    from price.modules.imp_price.services import Services
    from price.tasks import add_brand_assignment, add_category_assignment
    s = Services()
    for imp_catalog_page_id in s.get_unprocessed_pages(scan_date):
        log.info('Order Imp_catalog_page: {}'.format(imp_catalog_page_id))
        tp = s.get_tagging_product(imp_catalog_page_id)
        add_brand_assignment.delay(tp)
        add_category_assignment.delay(tp)
Ejemplo n.º 10
0
def proces_not_parased_page(entry_point_id=None):
    ipp = ImpPriceServices()
    if entry_point_id:
        log.info('Processing entry point ID: %r', entry_point_id)
        run_parasing_pages(None, None, entry_point_id)
    else:
        for entry_point_id in ipp.get_processed_entry_points():
            log.info('Processing entry point ID: %r', entry_point_id)
            run_parasing_pages(None, None, entry_point_id)
Ejemplo n.º 11
0
def copy_product(scan_date=None):
    no = 0
    from price.tasks import copy_product
    ips = ImpPriceServices()
    log.info('Copy product for date {}'.format(scan_date))
    for result in ips.get_all_price_for_catalog_page(scan_date):
        # log.debug('Result %r', dir(result))
        copy_product.delay(result[0], result[1])
        if no % 1000 == 0:
            log.debug('Order {} task to copy product'.format(no))
        no = no + 1
Ejemplo n.º 12
0
def copy_product_to_imp(scan_date=None):
    """
    Copy product from price_ofert to imp_product
    """
    log.info('copy_product_to_imp params: scan_date={}'.format(scan_date))
    s = ImpPriceServices()
    if scan_date:
        count = s.copy_product_to_imp(scan_date)
    else:
        count = s.copy_product_to_imp()
    log.info('Copy {} objects'.format(count))
Ejemplo n.º 13
0
def tag_brand(imp_catalog_page_id=None, creation_date=None):
    from price.modules.imp_price.services import Services
    from price.tasks import add_brand_assignment
    log.info('tag_brand params:%r, %r)', imp_catalog_page_id, creation_date)
    s = Services()
    no = 1
    for imp_catalog_page_id, name in s.get_list_pages(imp_catalog_page_id,
                                                      creation_date):
        # log.info('Order tag brand {}'.format(imp_catalog_page_id))
        tp = s.get_tagging_product(imp_catalog_page_id)
        add_brand_assignment.delay(tp)
        no = no + 1
    log.info('tag_brand: order {} tasks'.format(no))
Ejemplo n.º 14
0
def tagging_product(imp_catalog_page_id=None, title=None, creation_date=None):
    from price.tasks import tagging_product
    from price.modules.imp_price.services import Services
    log.info(
        'tagging_product params: imp_catalog_page_id: {}, title: {} , creation_date: {}'
        .format(imp_catalog_page_id, title, creation_date))
    s = Services()
    no = 1
    for imp_catalog_page_id, title in s.get_list_pages(imp_catalog_page_id,
                                                       creation_date):
        tagging_product.delay(imp_catalog_page_id, title)
        no = no + 1
    log.info('tagging_product order {} tasks'.format(no))
Ejemplo n.º 15
0
 def post(self):
     # , status_type, imp_catalog_page_id):
     s = Services()
     post_data = ImpCatalogPageStatusSchema().load(request.form)
     """
     log.info('request.data: %r', request.data)
     log.info('request.data: %r', request.args)
     log.info('request.data: %r', request.form)
     log.info('request.data: %r', request.json)
     """
     log.info('Post Data: %r', post_data)
     if post_data.get('status_type') == 'category':
         status_id = s.set_catalog_page_status_category(post_data.get('imp_catalog_page_id'))
     elif post_data.get('status_type') == 'brand':
         status_id = s.set_catalog_page_status_brand(post_data.get('imp_catalog_page_id'))
     return {
         'status_type': post_data.get('status_type'),
         'status_id': status_id
     }
Ejemplo n.º 16
0
def add_category_synonym(value):
    from price.modules.tager.services import Services
    from price.modules.imp_price.services import Services as ImpServices
    from price.tasks import add_category_assignment
    s = Services()
    imps = ImpServices()
    s.add_category_synonym(value)
    list_imp_catalog_page_id = get(
        'http://127.0.0.1:7001/catalog_page_search/category/{}'.format(value))
    for imp_catalog_page_id in list_imp_catalog_page_id:
        tp = imps.get_tagging_product(imp_catalog_page_id)
        if tp:
            log.info('Order category_assignment ImpID: {} Title: {}'.format(
                imp_catalog_page_id, tp.get('catalog_title')))
            add_category_assignment.delay(tp)
    for imp_catalog_page_id in list_imp_catalog_page_id:
        tp = imps.get_tagging_product(imp_catalog_page_id)
        if tp:
            log.info('Order tagging_product ImpID: {} Title: {}'.format(
                imp_catalog_page_id, tp.get('catalog_title')))
            tagging_product(imp_catalog_page_id, tp.get('catalog_title'))
Ejemplo n.º 17
0
def get_all_context():
    from price.modules.tager.services import Services
    s = Services()
    log.info('Liist context \n%r', s.get_all_context())
Ejemplo n.º 18
0
def parase_product_pages(shop_id):
    """
    Run parasing product page for shop_id, synchronous commissioning
    """
    s = ImpPriceServices()
    s.parase_product_pages(shop_id)
Ejemplo n.º 19
0
def add_brnad_synonym(value):
    from price.modules.tager.services import Services
    s = Services()
    s.add_brnad_synonym(value)
Ejemplo n.º 20
0
 def get(self, imp_catalog_page_id):
     s = Services()
     return s.get_product_info(imp_catalog_page_id)
Ejemplo n.º 21
0
 def get(self, imp_catalog_page_id, scan_date):
     log.debug('Get info about catalog_product_id: {} for date: {}'.format(imp_catalog_page_id, scan_date))
     s = Services()
     # result = s.get_product_by_id(imp_catalog_page_id, scan_date)
     return s.get_product_by_id(imp_catalog_page_id, scan_date)
Ejemplo n.º 22
0
def product_page_parase(result):
    pps = PpServices()
    pps.process_product_pages(result)
Ejemplo n.º 23
0
def add_tag_context(context):
    from price.modules.tager.services import Services
    s = Services()
    s.add_tag_context(context)
Ejemplo n.º 24
0
def add_product_category(name, meta_category_id=None):
    from price.modules.product.services import Services
    s = Services()
    s.add_categroy(name, meta_category_id)