示例#1
0
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)
示例#2
0
 def read_conf(self, ConfObj):
     ''' Getting config options for this handler '''
     self.log.notice("[NewsHandler]: read_conf")
     MailHandler.read_conf(self, ConfObj,
                    ['host', 'db', 'db_user', 'db_pass',
                     'photo_tbl', 'photo_tblsq',
                     'news_tbl', 'news_tblsq',
                     'site', 'attach_path', 'tnx', 'tny'])
示例#3
0
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)
示例#4
0
def sendEmailNotify(card):
    currentTime = datetime.datetime.strftime(datetime.datetime.now(), '%Y-%m-%d %H:%M:%S')
    msg = "TIME: " + str(currentTime) + '\tPrice: $' + str(card["listPrice"]) + '\tPercent: ' + str(card["percent"]) + '%\tFinal Price: $' + str(card["finalPrice"])
    print msg
    MailHandler.sendMsg("Purchase Log : " + ConfigHandler.GiftCardName + '\t$'+str(card["listPrice"])+'\t'+str(card["percent"])+'%', msg)
示例#5
0
    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()
示例#6
0
文件: UrlHandler.py 项目: nah-ko/MBot
 def read_conf(self, ConfObj):
     """ Getting config options for this handler """
     self.log.notice("[UrlHandler]: read_conf")
     MailHandler.read_conf(self, ConfObj, ["mailsize", "attsize"])