mirror of
https://github.com/LmeSzinc/StarRailCopilot.git
synced 2024-11-21 08:18:18 +00:00
Fix: [ALAS] Patch to fix atx_agent_url on arm64-v8a
This commit is contained in:
parent
763806150e
commit
487dbf1408
@ -59,17 +59,34 @@ def patch_uiautomator2():
|
|||||||
https://tool.appetizer.io is added to bypass the wall in China but https://tool.appetizer.io is slow outside of CN
|
https://tool.appetizer.io is added to bypass the wall in China but https://tool.appetizer.io is slow outside of CN
|
||||||
plus some CN users cannot access it for unknown reason.
|
plus some CN users cannot access it for unknown reason.
|
||||||
|
|
||||||
So we patch `uiautomator2/init.py` to a local assets cache `uiautomator2cache/cache`.
|
1. So we patch `uiautomator2/init.py` to a local assets cache `uiautomator2cache/cache`.
|
||||||
appdir = os.path.join(os.path.expanduser('~'), '.uiautomator2')
|
appdir = os.path.join(os.path.expanduser('~'), '.uiautomator2')
|
||||||
to:
|
to:
|
||||||
appdir = os.path.join(__file__, '../../uiautomator2cache')
|
appdir = os.path.join(__file__, '../../uiautomator2cache')
|
||||||
|
|
||||||
And we also remove minicap installations since emulators doesn't need it.
|
2. And we also remove minicap installations since emulators doesn't need it.
|
||||||
for url in self.minicap_urls:
|
for url in self.minicap_urls:
|
||||||
self.push_url(url)
|
self.push_url(url)
|
||||||
to:
|
to:
|
||||||
for url in []:
|
for url in []:
|
||||||
self.push_url(url)
|
self.push_url(url)
|
||||||
|
|
||||||
|
3. Fix atx_agent_url so ARM Mac can have correct ATX installed
|
||||||
|
```
|
||||||
|
@property
|
||||||
|
def atx_agent_url(self):
|
||||||
|
files = {
|
||||||
|
'armeabi-v7a': 'atx-agent_{v}_linux_armv7.tar.gz',
|
||||||
|
'arm64-v8a': 'atx-agent_{v}_linux_armv7.tar.gz',
|
||||||
|
'armeabi': 'atx-agent_{v}_linux_armv6.tar.gz',
|
||||||
|
'x86': 'atx-agent_{v}_linux_386.tar.gz',
|
||||||
|
'x86_64': 'atx-agent_{v}_linux_386.tar.gz',
|
||||||
|
}
|
||||||
|
```
|
||||||
|
where
|
||||||
|
'arm64-v8a': 'atx-agent_{v}_linux_armv7.tar.gz',
|
||||||
|
to
|
||||||
|
'arm64-v8a': 'atx-agent_{v}_linux_arm64.tar.gz',
|
||||||
"""
|
"""
|
||||||
init_file = './toolkit/Lib/site-packages/uiautomator2/init.py'
|
init_file = './toolkit/Lib/site-packages/uiautomator2/init.py'
|
||||||
cache_dir = './toolkit/Lib/site-packages/uiautomator2cache/cache'
|
cache_dir = './toolkit/Lib/site-packages/uiautomator2cache/cache'
|
||||||
@ -92,6 +109,17 @@ def patch_uiautomator2():
|
|||||||
else:
|
else:
|
||||||
logger.info(f'{init_file} minicap_urls no need to patch')
|
logger.info(f'{init_file} minicap_urls no need to patch')
|
||||||
|
|
||||||
|
# Patch atx_agent_url
|
||||||
|
res = re.search(r"'arm64-v8a': 'atx-agent_\{v}_linux_armv7.tar.gz'", content)
|
||||||
|
if res:
|
||||||
|
content = re.sub(r"'arm64-v8a': 'atx-agent_\{v}_linux_armv7.tar.gz'",
|
||||||
|
"'arm64-v8a': 'atx-agent_{v}_linux_arm64.tar.gz'",
|
||||||
|
content)
|
||||||
|
modified = True
|
||||||
|
logger.info(f'{init_file} atx_agent_url patched')
|
||||||
|
else:
|
||||||
|
logger.info(f'{init_file} atx_agent_url no need to patch')
|
||||||
|
|
||||||
# Patch appdir
|
# Patch appdir
|
||||||
if os.path.exists(cache_dir):
|
if os.path.exists(cache_dir):
|
||||||
res = re.search(r'appdir ?=(.*)\n', content)
|
res = re.search(r'appdir ?=(.*)\n', content)
|
||||||
|
@ -73,6 +73,38 @@ u2.setup_logger = setup_logger
|
|||||||
u2.init.setup_logger = setup_logger
|
u2.init.setup_logger = setup_logger
|
||||||
|
|
||||||
|
|
||||||
|
# Patch Initer
|
||||||
|
class PatchedIniter(u2.init.Initer):
|
||||||
|
@property
|
||||||
|
def atx_agent_url(self):
|
||||||
|
files = {
|
||||||
|
'armeabi-v7a': 'atx-agent_{v}_linux_armv7.tar.gz',
|
||||||
|
# 'arm64-v8a': 'atx-agent_{v}_linux_armv7.tar.gz',
|
||||||
|
'arm64-v8a': 'atx-agent_{v}_linux_arm64.tar.gz',
|
||||||
|
'armeabi': 'atx-agent_{v}_linux_armv6.tar.gz',
|
||||||
|
'x86': 'atx-agent_{v}_linux_386.tar.gz',
|
||||||
|
'x86_64': 'atx-agent_{v}_linux_386.tar.gz',
|
||||||
|
}
|
||||||
|
name = None
|
||||||
|
for abi in self.abis:
|
||||||
|
name = files.get(abi)
|
||||||
|
if name:
|
||||||
|
break
|
||||||
|
if not name:
|
||||||
|
raise Exception(
|
||||||
|
"arch(%s) need to be supported yet, please report an issue in github"
|
||||||
|
% self.abis)
|
||||||
|
return u2.init.GITHUB_BASEURL + '/atx-agent/releases/download/%s/%s' % (
|
||||||
|
u2.version.__atx_agent_version__, name.format(v=u2.version.__atx_agent_version__))
|
||||||
|
|
||||||
|
@property
|
||||||
|
def minicap_urls(self):
|
||||||
|
return []
|
||||||
|
|
||||||
|
|
||||||
|
u2.init.Initer = PatchedIniter
|
||||||
|
|
||||||
|
|
||||||
def is_port_using(port_num):
|
def is_port_using(port_num):
|
||||||
""" if port is using by others, return True. else return False """
|
""" if port is using by others, return True. else return False """
|
||||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
@ -394,6 +426,7 @@ class HierarchyButton:
|
|||||||
"""
|
"""
|
||||||
Element props
|
Element props
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def _get_bool_prop(self, prop: str) -> bool:
|
def _get_bool_prop(self, prop: str) -> bool:
|
||||||
return self.attrib.get(prop, "").lower() == 'true'
|
return self.attrib.get(prop, "").lower() == 'true'
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user