Skip to content

Commit

Permalink
commodities and grammar fixes (#150)
Browse files Browse the repository at this point in the history
* commodities and grammar fixes

* bump version

* fix error message

* fix the update messages in AAA

* fix all random 429 errors

* default lower threads

* keep logs in there
  • Loading branch information
cohenaj194 authored Nov 7, 2024
1 parent 0b347d4 commit ab48fb6
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/windows-exe-build.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Build Windows Executable

env:
AAA_VERSION: "1.2.5"
AAA_VERSION: "1.2.5.1"

on:
workflow_dispatch:
Expand Down
9 changes: 5 additions & 4 deletions AzerothAuctionAssassin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import sys
from datetime import datetime

AAA_VERSION = "1.2.5"
AAA_VERSION = "1.2.5.1"

windowsApp_Path = None
try:
Expand Down Expand Up @@ -362,7 +362,8 @@ def make_side_buttons(self):
self.layout_area.addWidget(self.stop_button, 10, 0)

self.mega_alerts_progress = QLabel("Waiting for user to Start!")
self.mega_alerts_progress.setFixedSize(150, 25)
# this is important, if the messages from mega alerts status are too long, it will break the UI
self.mega_alerts_progress.setFixedSize(150, 100)
self.layout_area.addWidget(self.mega_alerts_progress, 11, 0)

def make_home_page(self, home_page):
Expand Down Expand Up @@ -471,7 +472,7 @@ def make_settings_page(self, settings_page):
self.settings_page_layout.addWidget(self.wow_region, 9, 0, 1, 1)

self.number_of_mega_threads = QLineEdit(settings_page)
self.number_of_mega_threads.setText("48")
self.number_of_mega_threads.setText("10")
self.number_of_mega_threads_label = QLabel("Number of Threads", settings_page)
self.number_of_mega_threads_label.setToolTip(
"Change the thread count.\nDo 100 for the fastest scans, but RIP to ur CPU and MEM."
Expand Down Expand Up @@ -2034,7 +2035,7 @@ def reset_app_data(self):
self.wow_client_secret_input.setText(""),
self.authentication_token.setText(""),
self.show_bid_prices.setChecked(False),
self.number_of_mega_threads.setText("48"),
self.number_of_mega_threads.setText("10"),
self.wow_head_link.setChecked(False),
self.no_links.setChecked(False),
self.discount_percent.setText("10"),
Expand Down
4 changes: 2 additions & 2 deletions mega_alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ def main():

else:
self.progress.emit(
f"The updates will come\non min {mega_data.get_upload_time_minutes()} of each hour."
f"The updates will come\non min {mega_data.get_upload_time_minutes()}\nof each hour."
)
print(
f"Blizzard API data only updates 1 time per hour. The updates will come on minute {mega_data.get_upload_time_minutes()} of each hour. "
Expand Down Expand Up @@ -588,7 +588,7 @@ def main_fast():
+ f"Running {mega_data.THREADS} concurrent api calls\n"
+ f"checking for items {mega_data.DESIRED_ITEMS}\n"
+ f"or pets {mega_data.DESIRED_PETS}\n"
+ f"or or ilvl items from list {mega_data.DESIRED_ILVL_LIST}\n"
+ f"or ilvl items from list {mega_data.DESIRED_ILVL_LIST}\n"
)

# start app here
Expand Down
24 changes: 16 additions & 8 deletions utils/mega_data_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from __future__ import print_function
import json, requests, os, time
from datetime import datetime
from tenacity import retry, stop_after_attempt
from tenacity import retry, stop_after_attempt, retry_if_exception_type
from utils.api_requests import (
send_discord_message,
get_itemnames,
Expand Down Expand Up @@ -224,7 +224,7 @@ def process_var(var_value, default_behaviour):
return var_value

# access token setter
@retry(stop=stop_after_attempt(3))
@retry(stop=stop_after_attempt(10))
def check_access_token(self):
# tokens are valid for 24 hours
if (
Expand Down Expand Up @@ -557,16 +557,20 @@ def construct_api_url(self, connectedRealmId, endpoint):

return url

@retry(stop=stop_after_attempt(3))
@retry(
stop=stop_after_attempt(10),
retry=retry_if_exception_type(requests.RequestException),
retry_error_callback=lambda retry_state: {"auctions": []},
)
def make_ah_api_request(self, url, connectedRealmId):
headers = {"Authorization": f"Bearer {self.check_access_token()}"}
req = requests.get(url, headers=headers, timeout=20)

# check for api errors
if req.status_code == 429:
error_message = f"{req} BLIZZARD too many requests error on {self.REGION} {str(connectedRealmId)} realm data, sleep 30 min and exit"
error_message = f"{req} BLIZZARD too many requests error on {self.REGION} {str(connectedRealmId)} realm data, skipping"
print(error_message)
time.sleep(30 * 60)
time.sleep(3)
raise Exception(error_message)
elif req.status_code != 200:
error_message = f"{req} BLIZZARD error getting {self.REGION} {str(connectedRealmId)} realm data"
Expand Down Expand Up @@ -610,7 +614,11 @@ def update_local_timers(self, dataSetID, lastUploadTimeRaw):
}
self.upload_timers[dataSetID] = new_realm_time

@retry(stop=stop_after_attempt(3))
@retry(
stop=stop_after_attempt(10),
retry=retry_if_exception_type(requests.RequestException),
retry_error_callback=lambda retry_state: {"auctions": []},
)
def make_commodity_ah_api_request(self):
if self.REGION == "NA":
url = f"https://us.api.blizzard.com/data/wow/auctions/commodities?namespace=dynamic-us&locale=en_US"
Expand All @@ -627,9 +635,9 @@ def make_commodity_ah_api_request(self):

# check for api errors
if req.status_code == 429:
error_message = f"{req} BLIZZARD too many requests error on {self.REGION} commodities data, sleep 30 min and exit"
error_message = f"{req} BLIZZARD too many requests error on {self.REGION} commodities data, skipping"
print(error_message)
time.sleep(30 * 60)
time.sleep(3)
raise Exception(error_message)
elif req.status_code != 200:
error_message = f"{req} BLIZZARD error getting {self.REGION} {str(connectedRealmId)} realm data"
Expand Down

0 comments on commit ab48fb6

Please sign in to comment.