def main(inshop):

    global shop
    shop = inshop

    args = parser.parse_args()

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

    if (args.query is not None and args.store is not None):
        printString = search_for_items_by_name_and_format_output(
            args.query, args.store)
        if (len(printString) > 0):
            utils.print_enc("\n".join(printString))
            exit(0)
        else:
            exit(-1)

    elif (args.store is not None and args.id is not None and args.price is not None):
        priceMatched = check_wish_price(args.id, args.store, args.price)
        if (priceMatched):
            exit(0)
        else:
            exit(-1)
Exemple #2
0
def main(inshop):

    global shop
    shop = inshop

    args = parser.parse_args()

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

    if (args.query is not None and args.store is not None):
        printString = search_for_items_by_name_and_format_output(
            args.query, args.store, args.json)
        if len(printString) == 0:
            exit(-1)
        elif not args.json:
            utils.print_enc("\n".join(printString))
            exit(0)
        elif args.json:
            print(printString)
            exit(0)

    elif (args.store is not None and args.id is not None
          and args.price is not None):
        priceMatched = check_wish_price(args.id, args.store, args.price)
        if (priceMatched):
            exit(0)
        else:
            exit(-1)
Exemple #3
0
def main(shop):
    args = parser.parse_args()

    if not args.log:
        logging.getLogger().disabled = True
    else:
        logging.basicConfig(
            filename="psnprices.log",
            level=logging.INFO,
            format="%(asctime)s [%(levelname)-8s] %(message)s",
            filemode="w",
        )

    if args.query is not None and args.store is not None:
        print_string = search_for_items_by_name_and_format_output(
            shop, args.query, args.json)
        if len(print_string) == 0:
            exit(-1)
        elif not args.json:
            utils.print_enc("\n".join(print_string))
            exit(0)
        elif args.json:
            print(print_string)
            exit(0)

    elif args.store is not None and args.id is not None and args.price is not None:
        price_matched = check_wish_price(shop, args.id, args.price)
        if price_matched:
            exit(0)
        else:
            exit(-1)
Exemple #4
0
def check_wish_price(shop: Shop, cid: str, wish_price: float) -> bool:
    item = shop.get_item_by(item_id=cid)
    normal_price = item.prices[0].value
    name = item.name

    if normal_price > wish_price:
        utils.print_enc(("Wish price {0:.2f} for '" + name +
                         "' does not yet match {1:.2f}, exiting").format(
                             wish_price, normal_price))
        return False
    else:
        utils.print_enc(
            ("Wish price {0:.2f} for '" + name +
             "' matched. Is now: {1:.2f}").format(wish_price, normal_price))
        return True
Exemple #5
0
def check_wish_price(cid, store, wishPrice):

    # item = psn._getItemForCid(cid, store)
    item = shop.get_item_by(id=cid)
    normalPrice = item.prices[0].value
    name = item.name

    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 check_wish_price(cid, store, wishPrice):

    # item = psn._getItemForCid(cid, store)
    item = shop.get_item_by(id=cid)
    normalPrice = item.prices[0].value
    name = item.name

    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 check_containers_and_generate_mail_body(containers):

    body = ""
    bodyElements = []

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

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

        if (items is 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(
                    generate_body_itemsRow(
                        container, itemsSubset))

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

    return body
def main():
    dealContainerAlertsFilename = "alert_deal_containers.csv"
    containers = get_containers(dealContainerAlertsFilename)

    body = check_containers_and_generate_mail_body(containers)
    utils.print_enc("Finished processing")

    if (len(body) > 0):
        send_mail(body)
        utils.print_enc("Mail was sent")
    else:
        utils.print_enc("No mail was sent")

    exit(0)
Exemple #9
0
def main():
    alertsFilename = "alerts.csv"
    alerts = get_alerts(alertsFilename)

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

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

    exit(0)
def main():
    alertsFilename = "alerts.csv"
    alerts = get_alerts(alertsFilename)

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

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

    exit(0)