Merge pull request #431 from LmeSzinc/dev

Bug fix
This commit is contained in:
LmeSzinc 2024-04-23 01:01:56 +08:00 committed by GitHub
commit a0a0c21842
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 34 additions and 10 deletions

View File

@ -1,6 +1,7 @@
import copy
import os
import subprocess
import sys
from typing import Optional, Union
from deploy.Windows.logger import logger
@ -80,12 +81,6 @@ class DeployConfig(ConfigModel):
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()
@ -109,9 +104,21 @@ class DeployConfig(ConfigModel):
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:
@ -143,7 +150,7 @@ class DeployConfig(ConfigModel):
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
@ -152,12 +159,18 @@ class DeployConfig(ConfigModel):
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:

View File

@ -314,12 +314,18 @@ def retry(func):
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)
@ -343,6 +349,9 @@ def retry(func):
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:

View File

@ -37,6 +37,8 @@ class DeployConfig(_DeployConfig):
if hasattr(self, key):
super().__setattr__(key, value)
self.config_redirect()
def write(self):
"""
Write `self.config` into deploy config.

View File

@ -306,7 +306,7 @@ class RogueBlessingSelector(RogueSelector):
"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,
},
}
}