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
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
def main(): args = parser.parse_args() 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) 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)
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)