Пример #1
0
def doYouWantToContinue():
    playAudio("addmore.wav")
    chck = None
    speechToText=None
    speechToText = recognize()
    print(speechToText)
    if speechToText == "unknown error occured":
        doYouWantToContinue()
        speechToText = None
    else:
        tranlatedText = trans(speechToText)
        temp = tranlatedText.upper()
        if len(temp) != 0:
            x1 = temp.split()
            regex = re.compile("YES|NO|SURE|SURELY|OFCOURSE|CERTAINLY|SOMETIMES|NEVER|NOT|NOPE|ABSOLUTELY|NOTHING|NAI")
            word = regex.findall(temp)
            if len(word) != 0:
                if (word[0] == 'YES' or word[0] == "SOMETIMES" or word[0] == "SURE" or word[0] == "SURELY" or word[0] == "CERTAINLY" or word[0] == "ABSOLUTELY"):
                    audioFile = 'afteraddmore.wav'
                    playAudio(audioFile)
                    speechToText = recognize()
                    print(speechToText)
                    if speechToText == "unknown error occured":
                        audioFile = 'afteraddmore.wav'
                        speechToText = None
                    else:
                        from Product import identifyProduct
                        translatedText = trans(speechToText)
                        identifyProduct(translatedText)
                elif (word[0] == 'NO' or word[0] == "NEVER" or word[0] == "NOT" or word[0] == "NOPE" or word[0] == "NOTHING"):
                    print('Thank You your Order is Placed')
            else:

                doYouWantToContinue()
def acceptQuantityKg(prd):
    quantity = None
    playAudio('audiokg.wav')
    quantity = recognize()
    print(quantity)
    if quantity == "unknown error occured":
        acceptQuantityKg(prd)
    else:
        identifyQuantity(quantity, prd)
Пример #3
0
def acceptQuantityLt(prd):
    quantity = None
    playAudio('audiolit.wav')
    quantity = recognize()
    if quantity == "unknown error occured":
        acceptQuantityLt(prd)
    else:

        identifyQuantity(quantity, prd)
def orderStart(flg):
    if flg == 0:
        audioFile = 'ordertitle.wav'
    elif flg == 1:
        audioFile = 'afteraddmore.wav'
    playAudio(audioFile)
    speechToText = recognize()
    print(speechToText)
    if speechToText == "unknown error occured":
        orderStart(0)
        speechToText = None
    else:
        translatedText = trans(speechToText)
        identifyProduct(translatedText)
Пример #5
0
def Login2school(username, password):
    # Enable cookie support for urllib2
    url = 'http://cityjw.dlut.edu.cn:7001/ACTIONLOGON.APPPROCESS?mode=4'
    cookiejar = cookielib.CookieJar()
    urlopener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookiejar))
    urllib2.install_opener(urlopener)

    urlopener.addheaders.append(
        ('Referer', r'http://cityjw.dlut.edu.cn:7001/ACTIONLOGON.APPPROCESS?mode=3'))
    urlopener.addheaders.append(
        ('Accept-Language', r'zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3'))
    urlopener.addheaders.append(('Accept-Encoding', r'gzip,deflate'))
    urlopener.addheaders.append(('Host', r'http://cityjw.dlut.edu.cn:7001'))
    urlopener.addheaders.append(
        ('User-Agent', r'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:28.0) Gecko/20100101 Firefox/28.0'))
    urlopener.addheaders.append(('Connection', 'Keep-Alive'))

    # print 'crawler Login......'

    imgurl = r'http://cityjw.dlut.edu.cn:7001/ACTIONVALIDATERANDOMPICTURE.APPPROCESS'
    # download captcha
    isDownOK, img = DownloadFile(imgurl, urlopener)
    # recognize the captcha
    authcode = recognize(binary(img))
    # Send login/password to the site and get the session cookie
    values = {'WebUserNO': username, 'Password': password,
              'Agnomen': authcode, 'submit.x': 0, 'submit.y': 0}
    urlcontent = urlopener.open(
        urllib2.Request(url, urllib.urlencode(values).replace('%2A', '*')))
    page = urlcontent.read()
    page = unpack(page, urlcontent)
    page = page.decode('gb2312').encode('utf-8')
    # Make sure we are logged in, check the returned page content
    if 'ACTIONLOGOUT' not in page:
        # print 'Login failed with username=%s, password=%s and authcode=%s' \
              #% (username, password, authcode)
        return None, urlopener
    else:
        # print 'Login succeeded! with username=%s, password=%s and authcode=%s' \
        #     % (username, password, authcode)
        pattern = re.compile(r'<td align="left">(.*)</td>')
        name = pattern.search(page).groups()
        name = name[0]
        return name, urlopener