Exemple #1
0
    def post(self):
        args = parser.parse_args()

        if not args.get("name"):
            abort(400, message="name is required")
        if (args.get("price") or 0) <= 0:
            abort(400, message="price needs to be higher than 0")

        p = Product(name=args["name"], price=args["price"])
        img = args.get("image")
        if img:
            if "." in img.filename:
                ext = args["image"].filename.split(".")[1]
            else:
                ext = "jpg"

            fname = f"{uuid.uuid4()}.{ext}"
            img.save(os.path.join("media", fname))
            p.image = fname

        p.save()
        return _to_json(p), 201
Exemple #2
0
    
    
    for stog_cnt in range(len(storages)):
        for spc_cnt in range(len(specs_names)):
            item = Product(
                store         = 'verizon',
                product_name  = product_name,
                skuId         = skuId,
                brand         = brand,
                color         = colors,
                storage       = storages[stog_cnt],
                price         = prices[stog_cnt],
                spec_name     = specs_names[spc_cnt],
                spec_value    = spec_values[spc_cnt],
                )                
            item.save()
    
    # Click review button to go to the review section
    review_button = driver.find_element_by_id('reviewsLink')
    review_button.click()

    #overall review
    if num_reviews >0:
        overall_elm = overall_elm = driver.find_element_by_xpath('.//div[@class=" row noSideMargin deviceReviews border_bottomBlack  padTop10 padBottom24"]')
        overall_text = re.findall(r'[\d.]+', overall_elm.find_element_by_xpath('.//div[@class="col-xs-6 noSidePad pad5"]').text)
        rating_overall = overall_text[0]
        rating_num = overall_text[-1]
        sub_reviews = overall_elm.find_element_by_xpath('.//div[@class="col-xs-6 noSidePad"]')
        sub_list = re.findall('[.\d]+', sub_reviews.text)
        design = sub_list[0]
        feature = sub_list[1]