def process(): topDsct = HttpHandler.getTopDiscount(gcName) if checkIsGoodDiscount(topDsct,price_min,discount_min) and checkIsNewDiscount(topDsct): currentTime = datetime.datetime.strftime(datetime.datetime.now(), '%Y-%m-%d %H:%M:%S') msg = "TIME: " + currentTime + '\tPRICE: ' + topDsct["price"] + '\tDISCOUNT: ' + topDsct["discount"] print msg MailHandler.sendMsg(gcName+'\t'+topDsct["price"]+'\t'+topDsct["discount"], msg)
def process(): global priceTotalOrder global cardsTotalOrder cartInfo = HttpHandler.getCartInfo() cardList = HttpHandler.getCardList(ConfigHandler.GiftCardName) countCart = cartInfo["count"] priceCart = cartInfo["totalPrice"] countSum = 0 priceSum = 0 purchaseList = [] for card in cardList: if priceTotalOrder + priceSum + card["finalPrice"] + priceCart > ConfigHandler.MaxPriceTotalOrder: continue if cardsTotalOrder + countSum + 1 + countCart > ConfigHandler.MaxCardsTotalOrder: continue if countSum + 1 + countCart > ConfigHandler.MaxCardsPerOrder: continue if priceSum + card["finalPrice"] + priceCart > ConfigHandler.MaxPricePerOrder: continue if not checkIsGoodDiscount(card): continue if not checkIsNewDiscount(card): continue countSum += 1 priceSum += card["finalPrice"] priceTotalOrder += card["finalPrice"] cardsTotalOrder += 1 purchaseList.append(card) if len(purchaseList) == 0: return checkIfContinue(priceTotalOrder, cardsTotalOrder) addCardsToCart(purchaseList) time.sleep(1) retCode = HttpHandler.checkout() if retCode == 1: print "Need to verify device" HttpHandler.verifyDevice() HttpHandler.checkout() elif retCode == 2: print "The card is purchased by others" priceTotalOrder -= card["finalPrice"] cardsTotalOrder -= 1 msg = "Ping Info : " + datetime.datetime.strftime(datetime.datetime.now(), '%Y-%m-%d %H:%M:%S') + '\n\tCards Total Purchased : ' + str(cardsTotalOrder) + '/' + str(ConfigHandler.MaxCardsTotalOrder) + '\n\tPrice Total Purchased : ' + str(priceTotalOrder) + '/' + str(ConfigHandler.MaxPriceTotalOrder) MailHandler.sendMsg("Checkout exception",msg) clearSet() HttpHandler.clearShoppingCart() return checkIfContinue(priceTotalOrder, cardsTotalOrder)
def getOrderInfo(raw): orderList = HttpHandler.getOrderList(raw) orderInfoList = [] for orderNumber in orderList: orderInfoList.append(HttpHandler.getOrder(orderNumber)) return orderInfoList
orderInfoList = [] for orderNumber in orderList: orderInfoList.append(HttpHandler.getOrder(orderNumber)) return orderInfoList def saveListToFile(fName, orderInfoList): with open(fName, 'w') as f: f.write("Face Value, Price, SN, PIN\n") for orderInfo in orderInfoList: line = str(orderInfo["faceValue"]) + "," + str( orderInfo["price"]) + "," + str(orderInfo["SN"]) + "," + str( orderInfo["PIN"]) f.write(line + "\n") if __name__ == "__main__": configFile = None if len(sys.argv) == 2: configFile = sys.argv[1] ConfigHandler.initConfig(configFile) ConfigHandler.displayConfig() raw = raw_input( "Input the start date of your order (mm/dd/yy) or how many orders you want to look up (1 , 2 etc)." ) HttpHandler.login(ConfigHandler.RaiseUser, ConfigHandler.RaisePass, ConfigHandler.VisibleBrowser) process(raw) time.sleep(5) HttpHandler.logout()
def addCardsToCart(purchaseList): for oneCard in purchaseList: time.sleep(1) sendEmailNotify(oneCard) HttpHandler.addToCartById(ConfigHandler.GiftCardName, oneCard["id"])
return checkIfContinue(priceTotalOrder, cardsTotalOrder) def checkIfContinue(priceTotalOrder, cardsTotalOrder): print "Ping Info : " + datetime.datetime.strftime(datetime.datetime.now(), '%Y-%m-%d %H:%M:%S') + '\n\tCards Total Purchased : ' + str(cardsTotalOrder) + '/' + str(ConfigHandler.MaxCardsTotalOrder) + '\n\tPrice Total Purchased : ' + str(priceTotalOrder) + '/' + str(ConfigHandler.MaxPriceTotalOrder) if priceTotalOrder >= ConfigHandler.MaxPriceTotalOrder: return False if cardsTotalOrder >= ConfigHandler.MaxCardsTotalOrder: return False return True if __name__ == "__main__": configFile = None if len(sys.argv) == 2: configFile = sys.argv[1] ConfigHandler.initConfig(configFile) ConfigHandler.displayConfig() HttpHandler.login(ConfigHandler.RaiseUser, ConfigHandler.RaisePass, ConfigHandler.VisibleBrowser) MailHandler.init(ConfigHandler.GmailUser, ConfigHandler.GmailPass) ret = True while ret: try: ret = process() time.sleep(5) except Exception,e: print str(e) ret = False time.sleep(5) HttpHandler.logout()
import StringHelper import RegularExpressionParser import DBOperation import logging import json import io import os import sys import math from bs4 import BeautifulSoup #Call Function here try: if __name__ == '__main__': HttpRequest=HttpHandler.HttpHandler() ObjStringUtil=StringHelper.StringHelper() ObjDbOperations=DBOperation.DBOperation() objRegularExpressionParser=RegularExpressionParser.RegularExpressionParser() infoLavel=Config.Config.LogLevel logging.info('Completed configuring logger()!') isRedirection=True Cookies="" Refer="" ResponseCookie="" redirectionURL="" # Category & Subcategory lastURLS = [None] * 2 if len(sys.argv) > 1 and sys.argv[1] == "continue": print("\nContinuing script from last URL\n")
def __init__(self, name): HttpHandler.make_response(404, "Could not find user {}".format(name)) sys.exit(0)
import os import HttpHandler from UserMgr import UserMgr method = os.environ.get('REQ_METHOD') usermgr = UserMgr() if method == HttpHandler.GET: status, msg = 200, usermgr.users elif method == HttpHandler.POST: postreqdata = HttpHandler.get_postdata() res = usermgr.update_age(postreqdata.get("name"), postreqdata.get("age")) status, msg = 201, res else: status, msg = 404, "This method is not support yet" HttpHandler.make_response(status, msg)