def test_database_add_search_term(self): database = MySqlDataSouce() id = database.add_search_history("TEST", "TE") self.assertTrue(id > 0)
parser = LeoParser() with open('resources/words.txt', 'r') as hall: data = hall.read() words = extractor.get_words_from_text(data) error_count = 0 for word in words : if error_count > 5 : print("Error count reached sleeping " + ERROR_COUNT_SLEEP_SECONDS+ " seconds") error_count = 0 time.sleep(ERROR_COUNT_SLEEP_SECONDS) print("Searching for word: " + word) id = dao.add_search_history(word, ENGLISH) if id <= 0 : print("Adding search history record errored with : " + id) continue try: result = fetcher.search_english_word(ENGLISH, word) error_count = 0 except RateLimitException as e: print("Rate Limit exeception fetching: %s %s", word, e.message) dao.update_search_status_payload(id, ERROR_RATE_LIMIT, e.message) time.sleep(EXCEPTION_SLEEP_SECONDS) error_count += 1 continue except ClientPoolRateException as e: print("Client pool exeception fetching: %s %s", word, e.message) dao.update_search_status_payload(id, ERROR_CLIENT_POOL, e.message)