Skip to content

Commit

Permalink
Ignore reset config when error not from config
Browse files Browse the repository at this point in the history
  • Loading branch information
ken2057 committed Jul 2, 2022
1 parent 02b01c5 commit d92f4dd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/farm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def wrapper(self):
err = str(ex)
except NotFullTeamException as ex:
err = str(ex)
self.save_error(err)
self.save_error(err, is_config_error=False)
except UnableJoinException as ex:
err = str(ex)
special = True
Expand Down Expand Up @@ -334,14 +334,15 @@ def save_status(self, status: str):
def get_status_from_usage(self) -> str:
return get_json_file(USAGE_FILE).get('status', 'None')

def save_error(self, error: str):
def save_error(self, error: str, is_config_error=True):
'''
Use when got error that can't re-run able
e.g. Tier raid/quest unreachable
'''
usage = get_json_file(USAGE_FILE)
f = usage.get(self.feature, {})
f['error'] = error
f['is_config_error'] = is_config_error
usage[self.feature] = f
save_json_file(USAGE_FILE, usage)

Expand Down
6 changes: 4 additions & 2 deletions src/ui/main_screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from utils import \
clean_config_of_farm, \
find_image_and_click_then_sleep, \
is_config_error, \
is_rerun_mode, \
go_main_screen, \
is_debug, \
Expand Down Expand Up @@ -273,8 +274,9 @@ def move_to_queue():

def _create_error_frame_btn(self, farm: Farm, error: str):
def _repaired_error(farm: Farm, fr: ttk.Frame):
clean_config_of_farm(farm.feature)
self.try_create_farm(farm).set_default_config()
if is_config_error(farm.feature):
clean_config_of_farm(farm.feature)
self.try_create_farm(farm).set_default_config()
self.errors.remove(farm)
self._add_queue_and_farms(farm)
fr.pack_forget()
Expand Down
4 changes: 4 additions & 0 deletions src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,3 +318,7 @@ def clean_config_of_farm(name: str):
except:
pass
save_json_file(CONFIG_FILE, cfg)


def is_config_error(name: str):
return get_json_file(USAGE_FILE).get(name, {}).get('is_config_error', False)

0 comments on commit d92f4dd

Please sign in to comment.