コード例 #1
0
ファイル: tasks.py プロジェクト: RijeshCk/trackit
def RefreshAll():
	# send_email_notification('Product Refresh started')
	results = []
	d={}
	# products_to_refresh = ProductData.objects.all()
	products_to_refresh = Subscription.objects.all()
	
	for products in products_to_refresh:
		product = products.product
		data = amazonparser.parse(product.product_url)
		price = data['price']
		product_availability = data['availability']
		PriceData = PriceDetails(price = price, product = product, date = datetime.datetime.now())
		PriceData.save()
		product.product_availability = product_availability
		product.product_previous_price  = product.product_price
		product.product_price = price
		try:
			product.save()
		except:
			pass
		
		if products.user in d.keys():
			result = PriceDropcheck(product)
			if result:
				d[products.user].append(result)
		else:
			result = PriceDropcheck(product)
			if result:
				d[products.user] = [PriceDropcheck(product)]

	for users in d.keys():
		alert_user(users,d[users])
コード例 #2
0
def RefreshAll():
    # send_email_notification('Product Refresh started')
    results = []
    d = {}
    # products_to_refresh = ProductData.objects.all()
    products_to_refresh = Subscription.objects.all()

    for products in products_to_refresh:
        product = products.product
        data = amazonparser.parse(product.product_url)
        price = data['price']
        product_availability = data['availability']
        PriceData = PriceDetails(price=price,
                                 product=product,
                                 date=datetime.datetime.now())
        PriceData.save()
        product.product_availability = product_availability
        product.product_previous_price = product.product_price
        product.product_price = price
        try:
            product.save()
        except:
            pass

        if products.user in d.keys():
            result = PriceDropcheck(product)
            if result:
                d[products.user].append(result)
        else:
            result = PriceDropcheck(product)
            if result:
                d[products.user] = [PriceDropcheck(product)]

    for users in d.keys():
        alert_user(users, d[users])
コード例 #3
0
def user_repo_scan():  # pragma: no cover
    """
    Endpoint for scanning an OSIO user's repository.

    Runs a scan to find out security vulnerability in a user's repository
    """
    resp_dict = {"status": "success", "summary": ""}

    if request.content_type != 'application/json':
        resp_dict["status"] = "failure"
        resp_dict["summary"] = "Set content type to application/json"
        return flask.jsonify(resp_dict), 400

    input_json = request.get_json()

    validate_string = "{} cannot be empty"
    if 'git-url' not in input_json:
        validate_string = validate_string.format("git-url")
        return False, validate_string

    # Call the worker flow to run a user repository scan asynchronously
    status = alert_user(input_json, SERVICE_TOKEN)
    if status is not True:
        resp_dict["status"] = "failure"
        resp_dict["summary"] = "Scan initialization failure"
        return flask.jsonify(resp_dict), 500

    resp_dict.update({
        "summary":
        "Report for {} is being generated in the background. You will "
        "be notified via your preferred openshift.io notification mechanism "
        "on its completion.".format(input_json.get('git-url')),
    })

    return flask.jsonify(resp_dict), 200