Exemplo n.º 1
0
def run(session, question, ch=''):
    pull_xml(filename)
    current = Bank.from_xml(filename)
    if question:
        # if current == question:
        #     print('输入“n”或“N”退出!')
        #     return question
        # elif ch and ch in 'ABCD':
        if ch and ch in 'ABCD':
            question.answer = ch
            db_add(session, question)

    question = current
    print('\n%s\n%s' %
          ('-' * min(len(question.content) * 2, 120), question.content))
    bank = db_qeury(session, content=question.content)
    if bank:
        # items = [x for x in (bank.item1, bank.item2, bank.item3, bank.item4) if x]
        # index = ord(bank.answer)-65
        # if index < len(items):
        #     items[index] = f'{items[index]} <--- [{bank.answer}]'
        # options = '\n'.join(items)
        # print(f'\n{options}')
        print(f"\n手机提交答案后可直接回车 正确答案:  {bank.answer}\n")
        return question
    return search(question)
Exemplo n.º 2
0
def run(session, num=float('inf')):
    # t= threading.Thread(target=attention)#创建线程
    # t.setDaemon(True)#设置为后台线程,这里默认是False,设置为True之后则主线程不用等待子线程
    while num:
        num = num - 1
        pull_xml(filename)
        sleep(1)
        question = Bank.from_xml(filename)
        print('\n%s\n%s' %
              ('-' * min(len(question.content) * 2, 120), question.content))
        bank = db_qeury(session, content=question.content)
        delay = 1  # randint(3,5)
        if bank:
            index = ord(bank.answer) - 65
            pos = complex(question.bounds.split(' ')[index])
            if question.item1: print('A. %s' % question.item1)
            if question.item2: print('B. %s' % question.item2)
            if question.item3: print('C. %s' % question.item3)
            if question.item4: print('D. %s' % question.item4)
            print(f"\n {delay} 秒自动提交答案:  {bank.answer}\n")
            if 0j == pos:
                t = threading.Thread(target=attention,
                                     args=('crossed.mp3', 1))  #创建线程
                t.start()
                sleep(5)
                continue
            else:
                sleep(delay)
                tap_screen(int(pos.real), int(pos.imag))
        else:
            t = threading.Thread(target=attention,
                                 args=('doubt.mp3', 2))  #创建线程
            t.start()
            search(question)
            ch = input('请输入:').upper()
            if ch and 'N' == ch:
                break
            if ch and ch in "ABCD":
                question.answer = ch
                db_add(session, question)