Esempio n. 1
0
def checkContainersAndGenerateMailBody(containers):


	body = ""
	bodyElements = []

	for container in containers:
		containerId = container['containerId']
		store = container['store']

		items = psn.getItemsByContainer(containerId, store, {"platform": "ps4"})

		if (items == None):
			utils.print_enc("No items found for Container '"+containerId+"' in store "+store)
		else:

			body = "<table style=\"width: 100%; border-spacing: 0px;\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\"><tbody><tr><td align=\"center\">"
			body = body + "<table width=\"620\" style=\"width: 620px;\" align=\"center\" cellspacing=\"0\" cellpadding=\"0\"><tbody>"
			body = body + ("<tr><td><p style=\"font-family: sans-serif; font-size: 1.0em; color: #FFFFFF; background-color: #5177B4; padding: 10px; "
						   "text-align: center; font-weight: bold; border-radius: 5px 5px 5px 5px;\">Deals in Store "
						   + store  + " for container " + container["containerId"] + "</p></td></tr>")

			for subsetStartIdx in range(0, len(items), 3):
				itemsSubset = items[subsetStartIdx: subsetStartIdx + 3]

				bodyElements.append(generateBodyItemsRow(container, itemsSubset))

	body = body + "\n".join(bodyElements) + "</tbody></table></td></tr></tbody></table>"

	return body
Esempio n. 2
0
def main():
    args = parser.parse_args()

    if not args.log:
        logging.getLogger().disabled = True

    if (args.query != None and args.store != None):
        printString = searchForItemsByNameAndFormatOutput(
            args.query, args.store)
        if (len(printString) > 0):
            utils.print_enc("\n".join(printString))
            exit(0)
        else:
            exit(-1)
    elif (args.container != None and args.store != None):
        printString = searchForItemsByContainerAndFormatOutput(
            args.container, args.store, {"platform": "ps4"})
        if (len(printString) > 0):
            utils.print_enc("\n".join(printString))
            exit(0)
        else:
            exit(-1)

    elif (args.store != None and args.id != None and args.price != None):
        priceMatched = checkWishPrice(args.id, args.store, args.price)
        if (priceMatched):
            exit(0)
        else:
            exit(-1)
Esempio n. 3
0
def checkWishPrice(cid, store, wishPrice):

    item = psn.getItemForCid(cid, store)
    normalPrice = psn.getPrice(item)
    name = psn.getName(item)

    if (normalPrice > wishPrice):
        utils.print_enc(("Wish price {0:.2f} for '" + name +
                         "' does not yet match {1:.2f}, exiting").format(
                             wishPrice, normalPrice))
        return False
    else:
        utils.print_enc(
            ("Wish price {0:.2f} for '" + name +
             "' matched. Is now: {1:.2f}").format(wishPrice, normalPrice))
        return True
Esempio n. 4
0
def checkAlertsAndGenerateMailBody(alerts):

    bodyElements = []
    unmatchedAlerts = list(alerts)

    for alert in alerts:
        cid = alert['cid']
        store = alert['store']

        item = psn.getItemForCid(cid, store)

        if (item == None):
            utils.print_enc("No item found for cid '" + cid + "' in store " +
                            store)
        else:
            if (alertIsMatched(alert, item)):
                bodyElements.append(generateBodyElement(alert, item))

                unmatchedAlerts.remove(alert)

    body = "\n".join(bodyElements)

    return unmatchedAlerts, body
Esempio n. 5
0
def main():
	dealContainerAlertsFilename = "alert_deal_containers.csv"
	containers = getContainers(dealContainerAlertsFilename)

	body = checkContainersAndGenerateMailBody(containers)
	utils.print_enc("Finished processing")
	
	if (len(body) > 0):
		sendMail(body)
		utils.print_enc("Mail was sent")
	else:
		utils.print_enc("No mail was sent")
	
	exit(0)
Esempio n. 6
0
def main():
    alertsFilename = "alerts.csv"
    alerts = getAlerts(alertsFilename)

    alertsRemaining, body = checkAlertsAndGenerateMailBody(alerts)
    utils.print_enc("Finished processing")

    if (len(body) > 0):
        sendMail(body)
        utils.print_enc("Mail was sent")
        setAlerts(alertsFilename, alertsRemaining)
    else:
        utils.print_enc("No mail was sent")

    exit(0)