Skip to content

Commit abfd00d

Browse files
committed
Merge branch 'bug_fix'
2 parents 1ddc7d9 + 55b68d1 commit abfd00d

4 files changed

Lines changed: 35 additions & 9 deletions

File tree

deploy/Windows/config.py

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import copy
22
import os
33
import subprocess
4+
import sys
45
from typing import Optional, Union
56

67
from deploy.Windows.logger import logger
@@ -80,12 +81,6 @@ def __init__(self, file=DEPLOY_CONFIG):
8081
self.config_template = {}
8182
self.read()
8283

83-
# Bypass webui.config.DeployConfig.__setattr__()
84-
# Don't write these into deploy.yaml
85-
super().__setattr__('GitOverCdn', self.Repository in ['cn'])
86-
if self.Repository in ['global', 'cn']:
87-
super().__setattr__('Repository', 'https://github.com/LmeSzinc/StarRailCopilot')
88-
8984
self.write()
9085
self.show_config()
9186

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

107+
self.config_redirect()
108+
112109
def write(self):
113110
poor_yaml_write(self.config, self.file)
114111

112+
def config_redirect(self):
113+
"""
114+
Redirect deploy config, must be called after each `read()`
115+
"""
116+
# Bypass webui.config.DeployConfig.__setattr__()
117+
# Don't write these into deploy.yaml
118+
super().__setattr__('GitOverCdn', self.Repository in ['cn'])
119+
if self.Repository in ['global', 'cn']:
120+
super().__setattr__('Repository', 'https://github.com/LmeSzinc/StarRailCopilot')
121+
115122
def filepath(self, path):
116123
"""
117124
Args:
@@ -143,7 +150,7 @@ def adb(self) -> str:
143150
if os.path.exists(exe):
144151
return exe
145152

146-
logger.warning(f'AdbExecutable: {exe} does not exists, use `adb` instead')
153+
logger.warning(f'AdbExecutable: {exe} does not exist, use `adb` instead')
147154
return 'adb'
148155

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

155-
logger.warning(f'GitExecutable: {exe} does not exists, use `git` instead')
162+
logger.warning(f'GitExecutable: {exe} does not exist, use `git` instead')
156163
return 'git'
157164

158165
@cached_property
159166
def python(self) -> str:
160-
return self.filepath(self.PythonExecutable)
167+
exe = self.filepath(self.PythonExecutable)
168+
if os.path.exists(exe):
169+
return exe
170+
171+
current = sys.executable.replace("\\", "/")
172+
logger.warning(f'PythonExecutable: {exe} does not exist, use current python instead: {current}')
173+
return current
161174

162175
@cached_property
163176
def requirements_file(self) -> str:

module/device/method/minitouch.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,12 +314,18 @@ def retry_wrapper(self, *args, **kwargs):
314314

315315
def init():
316316
self.adb_reconnect()
317+
if self._minitouch_port:
318+
self.adb_forward_remove(f'tcp:{self._minitouch_port}')
319+
del_cached_property(self, '_minitouch_builder')
317320
# Emulator closed
318321
except ConnectionAbortedError as e:
319322
logger.error(e)
320323

321324
def init():
322325
self.adb_reconnect()
326+
if self._minitouch_port:
327+
self.adb_forward_remove(f'tcp:{self._minitouch_port}')
328+
del_cached_property(self, '_minitouch_builder')
323329
# MinitouchNotInstalledError: Received empty data from minitouch
324330
except MinitouchNotInstalledError as e:
325331
logger.error(e)
@@ -343,6 +349,9 @@ def init():
343349
if handle_adb_error(e):
344350
def init():
345351
self.adb_reconnect()
352+
if self._minitouch_port:
353+
self.adb_forward_remove(f'tcp:{self._minitouch_port}')
354+
del_cached_property(self, '_minitouch_builder')
346355
else:
347356
break
348357
except BrokenPipeError as e:

module/os_handler/storage.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ def storage_enter(self, skip_first_screenshot=True):
3838
# A game bug that AUTO_SEARCH_REWARD from the last cleared zone popups
3939
if self.appear_then_click(AUTO_SEARCH_REWARD, offset=(50, 50), interval=3):
4040
continue
41+
if self.handle_map_event():
42+
continue
4143

4244
self.handle_info_bar()
4345

module/webui/config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ def read(self):
3838
if hasattr(self, key):
3939
super().__setattr__(key, value)
4040

41+
self.config_redirect()
42+
4143
def write(self):
4244
"""
4345
Write `self.config` into deploy config.

0 commit comments

Comments
 (0)