mirror of
https://github.com/LmeSzinc/AzurLaneAutoScript.git
synced 2025-01-08 12:47:32 +08:00
Add: Disable multi-instances on phone cloud environment
This commit is contained in:
parent
ae8172e580
commit
8987c9253b
@ -5,6 +5,7 @@ from cached_property import cached_property
|
||||
|
||||
from deploy.utils import DEPLOY_TEMPLATE, poor_yaml_read, poor_yaml_write
|
||||
from module.base.timer import timer
|
||||
from module.config.env import IS_ON_PHONE_CLOUD
|
||||
from module.config.redirect_utils.utils import *
|
||||
from module.config.server import to_server, to_package, VALID_PACKAGE, VALID_CHANNEL_PACKAGE, VALID_SERVER_LIST
|
||||
from module.config.utils import *
|
||||
@ -616,6 +617,7 @@ class ConfigUpdater:
|
||||
|
||||
if not is_template:
|
||||
new = self.config_redirect(old, new)
|
||||
new = self._override(new)
|
||||
|
||||
return new
|
||||
|
||||
@ -668,6 +670,25 @@ class ConfigUpdater:
|
||||
|
||||
return new
|
||||
|
||||
def _override(self, data):
|
||||
def remove_drop_save(key):
|
||||
value = deep_get(data, keys=key, default='do_not')
|
||||
if value == 'save_and_upload':
|
||||
value = 'upload'
|
||||
deep_set(data, keys=key, value=value)
|
||||
elif value == 'save':
|
||||
value = 'do_not'
|
||||
deep_set(data, keys=key, value=value)
|
||||
|
||||
if IS_ON_PHONE_CLOUD:
|
||||
deep_set(data, 'Alas.Emulator.Serial', '127.0.0.1:5555')
|
||||
deep_set(data, 'Alas.Emulator.ScreenshotMethod', 'DroidCast_raw')
|
||||
deep_set(data, 'Alas.Emulator.ControlMethod', 'MaaTouch')
|
||||
for arg in deep_get(self.args, keys='Alas.DropRecord', default={}).keys():
|
||||
remove_drop_save(arg)
|
||||
|
||||
return data
|
||||
|
||||
def read_file(self, config_name, is_template=False):
|
||||
"""
|
||||
Read and update config file.
|
||||
|
3
module/config/env.py
Normal file
3
module/config/env.py
Normal file
@ -0,0 +1,3 @@
|
||||
import os
|
||||
|
||||
IS_ON_PHONE_CLOUD = os.environ.get("cloudphone", "") == "cloudphone"
|
@ -7,6 +7,7 @@ from adbutils import AdbClient, AdbDevice
|
||||
|
||||
from module.base.decorator import cached_property
|
||||
from module.config.config import AzurLaneConfig
|
||||
from module.config.env import IS_ON_PHONE_CLOUD
|
||||
from module.config.utils import deep_iter
|
||||
from module.exception import RequestHumanTakeover
|
||||
from module.logger import logger
|
||||
@ -33,6 +34,8 @@ class ConnectionAttr:
|
||||
else:
|
||||
self.config = config
|
||||
|
||||
logger.attr('IS_ON_PHONE_CLOUD', IS_ON_PHONE_CLOUD)
|
||||
|
||||
# Init adb client
|
||||
logger.attr('AdbBinary', self.adb_binary)
|
||||
# Monkey patch to custom adb
|
||||
|
@ -34,6 +34,7 @@ from pywebio.session import go_app, info, local, register_thread, run_js, set_en
|
||||
|
||||
import module.webui.lang as lang
|
||||
from module.config.config import AzurLaneConfig, Function
|
||||
from module.config.env import IS_ON_PHONE_CLOUD
|
||||
from module.config.utils import (
|
||||
alas_instance,
|
||||
alas_template,
|
||||
@ -114,20 +115,21 @@ class AlasGUI(Frame):
|
||||
{"label": t("Gui.Aside.Home"), "value": "Home", "color": "aside"}
|
||||
],
|
||||
onclick=[self.ui_develop],
|
||||
),
|
||||
)
|
||||
for name in alas_instance():
|
||||
put_icon_buttons(
|
||||
Icon.RUN,
|
||||
buttons=[{"label": name, "value": name, "color": "aside"}],
|
||||
onclick=self.ui_alas,
|
||||
)
|
||||
put_icon_buttons(
|
||||
Icon.ADD,
|
||||
buttons=[
|
||||
{"label": t("Gui.Aside.AddAlas"), "value": "AddAlas", "color": "aside"}
|
||||
],
|
||||
onclick=[self.ui_add_alas],
|
||||
),
|
||||
if not IS_ON_PHONE_CLOUD:
|
||||
put_icon_buttons(
|
||||
Icon.ADD,
|
||||
buttons=[
|
||||
{"label": t("Gui.Aside.AddAlas"), "value": "AddAlas", "color": "aside"}
|
||||
],
|
||||
onclick=[self.ui_add_alas],
|
||||
)
|
||||
|
||||
@use_scope("header_status")
|
||||
def set_status(self, state: int) -> None:
|
||||
@ -1261,6 +1263,7 @@ def app():
|
||||
logger.attr("Language", lang.LANG)
|
||||
logger.attr("Password", True if key else False)
|
||||
logger.attr("CDN", cdn)
|
||||
logger.attr("IS_ON_PHONE_CLOUD", IS_ON_PHONE_CLOUD)
|
||||
|
||||
def index():
|
||||
if key is not None and not login(key):
|
||||
|
Loading…
Reference in New Issue
Block a user