Exemple #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)
Exemple #2
0
def create_bank(bank_name, approval_rule_num_accounts,
                approval_rule_time_months, max_accounts):
    """Create and return a new bank."""

    bank = Bank(bank_name=bank_name,
                approval_rule_num_accounts=approval_rule_num_accounts,
                approval_rule_time_months=approval_rule_time_months,
                max_accounts=max_accounts)

    db.session.add(bank)
    db.session.commit()

    return bank
Exemple #3
0
def start(device, count=None):
    m_ad = Adble(device)
    m_db = Model()

    cfg = ConfigParser()
    cfg.read('./config.ini')
    if not count:
        count = cfg.getint('base', 'answer_count')
    elif 0 >= count:
        count = 65532
    else:
        pass
        
    delay_rand = cfg.getboolean('base', 'delay_rand')
    delay = 1
    for i in range(count):
        xml = m_ad.get_xml()
        question = Bank.from_xml(device)
        bank = m_db.query(content=question.content)
        if delay_rand: 
            delay = randint(1,6)

        if bank:
            index = ord(bank.answer)-65
            pos = complex(question.bounds.split(' ')[index])
            print(question)
            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)
                m_ad.tap(int(pos.real), int(pos.imag))
        else:
            t= threading.Thread(target=attention, args=('doubt.mp3',2))#创建线程
            t.start()
            headers = {
                'User-Agent': cfg.get('base', 'user_agent')
            }
            search(question, headers)
            ch = input('请输入:').upper()
            if ch and 'N' == ch:
                break
            if ch and ch in "ABCD":
                question.answer = ch
                m_db.add(question)
Exemple #4
0
def start(device, count, filename, database_uri, delay_seconds, user_agent):
    m_ad = Adble(device)
    m_db = Model(database_uri, 'data-dev')
    if 0 == delay_seconds:
        delay_rand = True
    else:
        delay_rand = False

    for i in range(count):
        xml = m_ad.get_xml(filename)
        question = Bank.from_xml(device)
        bank = m_db.query(content=question.content)
        if delay_rand:
            delay_seconds = randint(1, 6)

        if bank:
            index = ord(bank.answer) - 65
            pos = complex(question.bounds.split(' ')[index])
            print(question)
            print(f"\n {delay_seconds} 秒自动提交答案:  {bank.answer}\n")
            if 0j == pos:
                t = threading.Thread(target=attention,
                                     args=('crossed.mp3', 1))  #创建线程
                t.start()
                sleep(5)
                continue
            else:
                sleep(delay_seconds)
                m_ad.tap(int(pos.real), int(pos.imag))
        else:
            t = threading.Thread(target=attention,
                                 args=('doubt.mp3', 2))  #创建线程
            t.start()
            headers = {'User-Agent': user_agent}
            search(question, headers)
            ch = input('请输入:').upper()
            if ch and 'N' == ch:
                break
            if ch and ch in "ABCD":
                question.answer = ch
                m_db.add(question)
Exemple #5
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)
Exemple #6
0
			user_info = my_bank.selectById(id)
			my_view.printUserInfo(user_info)
		# elif user_input == "4":
			#Take id from user.
			#Check if user exists(Done on login function)
			#If it is a valid user then take in how much to transfer (Done in deposit and withdraw)
			#Check if transfer ammount is less than current balance. (Done in withdraw)
			#If transfer ammount is valid remove that much from your account and add it to the other user's account (Done with deposit and withdraw)
		elif user_input == "5":
			bank_running = False
		else:
			my_view.printOut("Invalid entry. Try again")

my_view = View()

my_bank = Bank()

login_running = True

while login_running == True:
	user_input = my_view.loginMenu()

	if user_input == "1":

		#Run until the user inputs a username that doesnt already exst
		username_while = True
		username = ""
		while username_while == True:
			#Take in potential username
			username = my_view.takeInput("Enter a username: ")
			#Get all users from database