Skip to content

Commit

Permalink
Merge pull request LmeSzinc#431 from LmeSzinc/dev
Browse files Browse the repository at this point in the history
Bug fix
  • Loading branch information
LmeSzinc authored Apr 22, 2024
2 parents 42a5fdd + b31724c commit a0a0c21
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 10 deletions.
31 changes: 22 additions & 9 deletions deploy/Windows/config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import copy
import os
import subprocess
import sys
from typing import Optional, Union

from deploy.Windows.logger import logger
Expand Down Expand Up @@ -80,12 +81,6 @@ def __init__(self, file=DEPLOY_CONFIG):
self.config_template = {}
self.read()

# Bypass webui.config.DeployConfig.__setattr__()
# Don't write these into deploy.yaml
super().__setattr__('GitOverCdn', self.Repository in ['cn'])
if self.Repository in ['global', 'cn']:
super().__setattr__('Repository', 'https://github.com/LmeSzinc/StarRailCopilot')

self.write()
self.show_config()

Expand All @@ -109,9 +104,21 @@ def read(self):
if hasattr(self, key):
super().__setattr__(key, value)

self.config_redirect()

def write(self):
poor_yaml_write(self.config, self.file)

def config_redirect(self):
"""
Redirect deploy config, must be called after each `read()`
"""
# Bypass webui.config.DeployConfig.__setattr__()
# Don't write these into deploy.yaml
super().__setattr__('GitOverCdn', self.Repository in ['cn'])
if self.Repository in ['global', 'cn']:
super().__setattr__('Repository', 'https://github.com/LmeSzinc/StarRailCopilot')

def filepath(self, path):
"""
Args:
Expand Down Expand Up @@ -143,7 +150,7 @@ def adb(self) -> str:
if os.path.exists(exe):
return exe

logger.warning(f'AdbExecutable: {exe} does not exists, use `adb` instead')
logger.warning(f'AdbExecutable: {exe} does not exist, use `adb` instead')
return 'adb'

@cached_property
Expand All @@ -152,12 +159,18 @@ def git(self) -> str:
if os.path.exists(exe):
return exe

logger.warning(f'GitExecutable: {exe} does not exists, use `git` instead')
logger.warning(f'GitExecutable: {exe} does not exist, use `git` instead')
return 'git'

@cached_property
def python(self) -> str:
return self.filepath(self.PythonExecutable)
exe = self.filepath(self.PythonExecutable)
if os.path.exists(exe):
return exe

current = sys.executable.replace("\\", "/")
logger.warning(f'PythonExecutable: {exe} does not exist, use current python instead: {current}')
return current

@cached_property
def requirements_file(self) -> str:
Expand Down
9 changes: 9 additions & 0 deletions module/device/method/minitouch.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,12 +314,18 @@ def retry_wrapper(self, *args, **kwargs):

def init():
self.adb_reconnect()
if self._minitouch_port:
self.adb_forward_remove(f'tcp:{self._minitouch_port}')
del_cached_property(self, '_minitouch_builder')
# Emulator closed
except ConnectionAbortedError as e:
logger.error(e)

def init():
self.adb_reconnect()
if self._minitouch_port:
self.adb_forward_remove(f'tcp:{self._minitouch_port}')
del_cached_property(self, '_minitouch_builder')
# MinitouchNotInstalledError: Received empty data from minitouch
except MinitouchNotInstalledError as e:
logger.error(e)
Expand All @@ -343,6 +349,9 @@ def init():
if handle_adb_error(e):
def init():
self.adb_reconnect()
if self._minitouch_port:
self.adb_forward_remove(f'tcp:{self._minitouch_port}')
del_cached_property(self, '_minitouch_builder')
else:
break
except BrokenPipeError as e:
Expand Down
2 changes: 2 additions & 0 deletions module/webui/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ def read(self):
if hasattr(self, key):
super().__setattr__(key, value)

self.config_redirect()

def write(self):
"""
Write `self.config` into deploy config.
Expand Down
2 changes: 1 addition & 1 deletion tasks/rogue/blessing/blessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ def load_filter(self):
"strategy_config": self.main.config.RogueBlessing_SelectionStrategy,
"preset_values": {
'preset': RESONANCE_PRESET[self.main.config.RogueWorld_Path],
'custom': self.main.config.RogueBlessing_PresetResonanceFilter,
'custom': self.main.config.RogueBlessing_CustomResonanceFilter,
},
}
}
Expand Down

0 comments on commit a0a0c21

Please sign in to comment.