mirror of
https://github.com/LmeSzinc/StarRailCopilot.git
synced 2024-11-22 00:35:34 +00:00
Upd: [ALAS] installer
This commit is contained in:
parent
f7bc6980f9
commit
0067e343b2
@ -1,8 +1,9 @@
|
||||
Deploy:
|
||||
Git:
|
||||
# URL of AzurLaneAutoScript repository
|
||||
# [Other] Use 'https://github.com/LmeSzinc/StarRailCopilot'
|
||||
Repository: https://e.coding.net/llop18870/alas/AzurLaneAutoScript.git
|
||||
# [CN user] Use 'cn' to get update from git-over-cdn service
|
||||
# [Other] Use 'global' to get update from https://github.com/LmeSzinc/StarRailCopilot
|
||||
Repository: cn
|
||||
# Branch of Alas
|
||||
# [Developer] Use 'dev', 'app', etc, to try new features
|
||||
# [Other] Use 'master', the stable branch
|
||||
@ -156,3 +157,6 @@ Deploy:
|
||||
# '["alas"]' specified "alas" config
|
||||
# '["alas","alas2"]' specified "alas" "alas2" configs
|
||||
Run: null
|
||||
# --no-sandbox. https://github.com/electron/electron/issues/30966
|
||||
# Some Windows systems cannot call the GPU normally for virtualization, and you need to manually turn off sandbox mode
|
||||
NoSandbox: false
|
||||
|
@ -1,8 +1,9 @@
|
||||
Deploy:
|
||||
Git:
|
||||
# URL of AzurLaneAutoScript repository
|
||||
# [Other] Use 'https://github.com/LmeSzinc/StarRailCopilot'
|
||||
Repository: https://github.com/LmeSzinc/StarRailCopilot
|
||||
# [CN user] Use 'cn' to get update from git-over-cdn service
|
||||
# [Other] Use 'global' to get update from https://github.com/LmeSzinc/StarRailCopilot
|
||||
Repository: global
|
||||
# Branch of Alas
|
||||
# [Developer] Use 'dev', 'app', etc, to try new features
|
||||
# [Other] Use 'master', the stable branch
|
||||
@ -156,3 +157,6 @@ Deploy:
|
||||
# '["alas"]' specified "alas" config
|
||||
# '["alas","alas2"]' specified "alas" "alas2" configs
|
||||
Run: null
|
||||
# --no-sandbox. https://github.com/electron/electron/issues/30966
|
||||
# Some Windows systems cannot call the GPU normally for virtualization, and you need to manually turn off sandbox mode
|
||||
NoSandbox: false
|
||||
|
@ -1,8 +1,8 @@
|
||||
import logging
|
||||
import os
|
||||
|
||||
from deploy.Windows.emulator import EmulatorManager
|
||||
from deploy.Windows.logger import logger
|
||||
from deploy.Windows.utils import *
|
||||
from deploy.Windows.logger import Progress, logger
|
||||
|
||||
|
||||
def show_fix_tip(module):
|
||||
@ -23,9 +23,11 @@ class AdbManager(EmulatorManager):
|
||||
if self.ReplaceAdb:
|
||||
logger.hr('Replace ADB', 1)
|
||||
self.adb_replace()
|
||||
Progress.AdbReplace()
|
||||
if self.AutoConnect:
|
||||
logger.hr('ADB Connect', 1)
|
||||
self.brute_force_connect()
|
||||
Progress.AdbConnect()
|
||||
|
||||
if False:
|
||||
logger.hr('Uiautomator2 Init', 1)
|
||||
|
@ -1,9 +1,10 @@
|
||||
import os
|
||||
import time
|
||||
import typing as t
|
||||
|
||||
from deploy.Windows.config import DeployConfig
|
||||
from deploy.Windows.logger import logger
|
||||
from deploy.Windows.utils import *
|
||||
from deploy.Windows.logger import Progress, logger
|
||||
from deploy.Windows.utils import DataProcessInfo, cached_property, iter_process
|
||||
|
||||
|
||||
class AlasManager(DeployConfig):
|
||||
@ -43,8 +44,9 @@ class AlasManager(DeployConfig):
|
||||
if proc.pid == self.self_pid:
|
||||
continue
|
||||
if in_alas:
|
||||
cmdline = proc.cmdline.replace(r"\\", "/").replace("\\", "/")
|
||||
for folder in self.alas_folder:
|
||||
if folder in proc.cmdline:
|
||||
if folder in cmdline:
|
||||
yield proc
|
||||
else:
|
||||
yield proc
|
||||
@ -56,15 +58,20 @@ class AlasManager(DeployConfig):
|
||||
self.execute(f'taskkill /f /t /pid {process.pid}', allow_failure=True, output=False)
|
||||
|
||||
def alas_kill(self):
|
||||
while 1:
|
||||
for _ in range(10):
|
||||
logger.hr(f'Kill existing Alas', 0)
|
||||
proc_list = list(self.iter_process_by_names(['alas.exe', 'python.exe'], in_alas=True))
|
||||
proc_list = list(self.iter_process_by_names(['python.exe'], in_alas=True))
|
||||
if not len(proc_list):
|
||||
break
|
||||
Progress.KillExisting()
|
||||
return True
|
||||
for proc in proc_list:
|
||||
logger.info(proc)
|
||||
self.kill_process(proc)
|
||||
|
||||
logger.warning('Unable to kill existing Alas, skip')
|
||||
Progress.KillExisting()
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
self = AlasManager()
|
||||
|
@ -1,9 +1,9 @@
|
||||
import filecmp
|
||||
import os
|
||||
import shutil
|
||||
|
||||
from deploy.Windows.config import DeployConfig
|
||||
from deploy.Windows.logger import logger
|
||||
from deploy.Windows.utils import *
|
||||
from deploy.Windows.logger import Progress, logger
|
||||
|
||||
|
||||
class AppManager(DeployConfig):
|
||||
@ -50,6 +50,8 @@ class AppManager(DeployConfig):
|
||||
|
||||
if not self.AutoUpdate:
|
||||
logger.info('AutoUpdate is disabled, skip')
|
||||
Progress.UpdateAlasApp()
|
||||
return False
|
||||
|
||||
return self.app_asar_replace(os.getcwd())
|
||||
self.app_asar_replace(os.getcwd())
|
||||
Progress.UpdateAlasApp()
|
||||
|
@ -1,9 +1,10 @@
|
||||
import copy
|
||||
import os
|
||||
import subprocess
|
||||
from typing import Optional, Union
|
||||
|
||||
from deploy.Windows.logger import logger
|
||||
from deploy.Windows.utils import *
|
||||
from deploy.Windows.utils import DEPLOY_CONFIG, DEPLOY_TEMPLATE, cached_property, poor_yaml_read, poor_yaml_write
|
||||
|
||||
|
||||
class ExecutionError(Exception):
|
||||
@ -54,7 +55,7 @@ class ConfigModel:
|
||||
|
||||
# Webui
|
||||
WebuiHost: str = "0.0.0.0"
|
||||
WebuiPort: int = 22367
|
||||
WebuiPort: int = 22267
|
||||
Language: str = "en-US"
|
||||
Theme: str = "default"
|
||||
DpiScaling: bool = True
|
||||
@ -73,10 +74,7 @@ class DeployConfig(ConfigModel):
|
||||
self.config = {}
|
||||
self.config_template = {}
|
||||
self.read()
|
||||
if self.Repository == 'https://gitee.com/LmeSzinc/AzurLaneAutoScript':
|
||||
self.Repository = 'https://e.coding.net/llop18870/alas/AzurLaneAutoScript.git'
|
||||
if self.Repository == 'https://gitee.com/lmeszinc/azur-lane-auto-script-mirror':
|
||||
self.Repository = 'https://e.coding.net/llop18870/alas/AzurLaneAutoScript.git'
|
||||
|
||||
self.write()
|
||||
self.show_config()
|
||||
|
||||
|
@ -1,8 +1,9 @@
|
||||
import configparser
|
||||
import os
|
||||
|
||||
from deploy.Windows.config import DeployConfig
|
||||
from deploy.Windows.logger import logger
|
||||
from deploy.Windows.utils import *
|
||||
from deploy.Windows.logger import Progress, logger
|
||||
from deploy.Windows.utils import cached_property
|
||||
|
||||
|
||||
class GitConfigParser(configparser.ConfigParser):
|
||||
@ -41,6 +42,7 @@ class GitManager(DeployConfig):
|
||||
self.remove('./.git/HEAD')
|
||||
self.remove('./.git/ORIG_HEAD')
|
||||
self.execute(f'"{self.git}" init')
|
||||
Progress.GitInit()
|
||||
|
||||
logger.hr('Set Git Proxy', 1)
|
||||
if proxy:
|
||||
@ -60,14 +62,17 @@ class GitManager(DeployConfig):
|
||||
else:
|
||||
if not self.git_config.check('http', 'sslVerify', value='false'):
|
||||
self.execute(f'"{self.git}" config --local http.sslVerify false', allow_failure=True)
|
||||
Progress.GitSetConfig()
|
||||
|
||||
logger.hr('Set Git Repository', 1)
|
||||
if not self.git_config.check(f'remote "{source}"', 'url', value=repo):
|
||||
if not self.execute(f'"{self.git}" remote set-url {source} {repo}', allow_failure=True):
|
||||
self.execute(f'"{self.git}" remote add {source} {repo}')
|
||||
Progress.GitSetRepo()
|
||||
|
||||
logger.hr('Fetch Repository Branch', 1)
|
||||
self.execute(f'"{self.git}" fetch {source} {branch}')
|
||||
Progress.GitFetch()
|
||||
|
||||
logger.hr('Pull Repository Branch', 1)
|
||||
# Remove git lock
|
||||
@ -93,18 +98,22 @@ class GitManager(DeployConfig):
|
||||
self.execute(f'"{self.git}" pull --ff-only {source} {branch}')
|
||||
else:
|
||||
self.execute(f'"{self.git}" reset --hard {source}/{branch}')
|
||||
Progress.GitReset()
|
||||
# Since `git fetch` is already called, checkout is faster
|
||||
if not self.execute(f'"{self.git}" checkout {branch}', allow_failure=True):
|
||||
self.execute(f'"{self.git}" pull --ff-only {source} {branch}')
|
||||
Progress.GitCheckout()
|
||||
|
||||
logger.hr('Show Version', 1)
|
||||
self.execute(f'"{self.git}" --no-pager log --no-merges -1')
|
||||
Progress.GitShowVersion()
|
||||
|
||||
def git_install(self):
|
||||
logger.hr('Update Alas', 0)
|
||||
|
||||
if not self.AutoUpdate:
|
||||
logger.info('AutoUpdate is disabled, skip')
|
||||
Progress.GitShowVersion()
|
||||
return
|
||||
|
||||
self.git_repository_init(
|
||||
|
@ -102,6 +102,7 @@ DataAdbDevice(serial='127.0.0.1:16384', status='device')
|
||||
DataAdbDevice(serial='127.0.0.1:16480', status='device')
|
||||
DataAdbDevice(serial='127.0.0.1:7555', status='device')
|
||||
Process: [ 100% ]
|
||||
中文测试,!@#nfoir
|
||||
"""
|
||||
|
||||
|
||||
|
@ -34,3 +34,34 @@ def hr(title, level=3):
|
||||
|
||||
|
||||
logger.hr = hr
|
||||
|
||||
|
||||
class Percentage:
|
||||
def __init__(self, progress):
|
||||
self.progress = progress
|
||||
|
||||
def __call__(self, *args, **kwargs):
|
||||
logger.info(f'Process: [ {self.progress}% ]')
|
||||
|
||||
|
||||
class Progress:
|
||||
Start = Percentage(0)
|
||||
ShowDeployConfig = Percentage(10)
|
||||
|
||||
GitInit = Percentage(12)
|
||||
GitSetConfig = Percentage(13)
|
||||
GitSetRepo = Percentage(15)
|
||||
GitFetch = Percentage(40)
|
||||
GitReset = Percentage(45)
|
||||
GitCheckout = Percentage(48)
|
||||
GitShowVersion = Percentage(50)
|
||||
|
||||
KillExisting = Percentage(60)
|
||||
UpdateDependency = Percentage(70)
|
||||
UpdateAlasApp = Percentage(75)
|
||||
|
||||
AdbReplace = Percentage(80)
|
||||
AdbConnect = Percentage(95)
|
||||
|
||||
# Must have a 100%
|
||||
Finish = Percentage(100)
|
||||
|
@ -1,10 +1,12 @@
|
||||
import os
|
||||
import re
|
||||
import typing as t
|
||||
from dataclasses import dataclass
|
||||
from urllib.parse import urlparse
|
||||
|
||||
from deploy.Windows.config import DeployConfig
|
||||
from deploy.Windows.logger import logger
|
||||
from deploy.Windows.utils import *
|
||||
from deploy.Windows.logger import logger, Progress
|
||||
from deploy.Windows.utils import cached_property
|
||||
|
||||
|
||||
@dataclass
|
||||
@ -20,6 +22,7 @@ class DataDependency:
|
||||
# PyYaml -> pyyaml
|
||||
self.name = self.name.lower()
|
||||
self.version = self.version.strip()
|
||||
self.version = re.sub(r'\.0$', '', self.version)
|
||||
|
||||
@cached_property
|
||||
def pretty_name(self):
|
||||
@ -93,10 +96,12 @@ class PipManager(DeployConfig):
|
||||
|
||||
if not self.InstallDependencies:
|
||||
logger.info('InstallDependencies is disabled, skip')
|
||||
Progress.UpdateDependency()
|
||||
return
|
||||
|
||||
if not len(self.set_dependency_to_install):
|
||||
logger.info('All dependencies installed')
|
||||
Progress.UpdateDependency()
|
||||
return
|
||||
else:
|
||||
logger.info(f'Dependencies to install: {self.set_dependency_to_install}')
|
||||
@ -124,3 +129,4 @@ class PipManager(DeployConfig):
|
||||
logger.hr('Update Dependencies', 1)
|
||||
arg = ' ' + ' '.join(arg) if arg else ''
|
||||
self.execute(f'{self.pip} install -r {self.requirements_file}{arg}')
|
||||
Progress.UpdateDependency()
|
||||
|
@ -1,8 +1,9 @@
|
||||
Deploy:
|
||||
Git:
|
||||
# URL of AzurLaneAutoScript repository
|
||||
# [Other] Use 'https://github.com/LmeSzinc/StarRailCopilot'
|
||||
Repository: 'https://github.com/LmeSzinc/StarRailCopilot'
|
||||
# [CN user] Use 'cn' to get update from git-over-cdn service
|
||||
# [Other] Use 'global' to get update from https://github.com/LmeSzinc/StarRailCopilot
|
||||
Repository: 'global'
|
||||
# Branch of Alas
|
||||
# [Developer] Use 'dev', 'app', etc, to try new features
|
||||
# [Other] Use 'master', the stable branch
|
||||
@ -156,3 +157,6 @@ Deploy:
|
||||
# '["alas"]' specified "alas" config
|
||||
# '["alas","alas2"]' specified "alas" "alas2" configs
|
||||
Run: null
|
||||
# --no-sandbox. https://github.com/electron/electron/issues/30966
|
||||
# Some Windows systems cannot call the GPU normally for virtualization, and you need to manually turn off sandbox mode
|
||||
NoSandbox: false
|
||||
|
@ -1,7 +1,7 @@
|
||||
import os
|
||||
import re
|
||||
from dataclasses import dataclass
|
||||
from typing import Callable, Iterable, Generic, TypeVar
|
||||
from typing import Callable, Generic, Iterable, TypeVar
|
||||
|
||||
T = TypeVar("T")
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
from deploy.Windows.logger import Progress, logger
|
||||
from deploy.Windows.patch import pre_checks
|
||||
|
||||
pre_checks()
|
||||
@ -22,5 +23,12 @@ class Installer(GitManager, PipManager, AdbManager, AppManager, AlasManager):
|
||||
exit(1)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
Installer().install()
|
||||
def run():
|
||||
Progress.Start()
|
||||
installer = Installer()
|
||||
Progress.ShowDeployConfig()
|
||||
|
||||
installer.install()
|
||||
|
||||
logger.info('Finish')
|
||||
Progress.Finish()
|
||||
|
54
installer.py
Normal file
54
installer.py
Normal file
@ -0,0 +1,54 @@
|
||||
import argparse
|
||||
import sys
|
||||
import typing as t
|
||||
|
||||
sys.stdout.reconfigure(encoding='utf-8')
|
||||
|
||||
"""
|
||||
Alas installer
|
||||
"""
|
||||
|
||||
|
||||
def run_install():
|
||||
from deploy.installer import run
|
||||
run()
|
||||
|
||||
|
||||
def run_print_test():
|
||||
from deploy.Windows.installer_test import run
|
||||
run()
|
||||
|
||||
|
||||
def run_set(modify=t.List[str]) -> t.Dict[str, str]:
|
||||
data = {}
|
||||
for kv in modify:
|
||||
if "=" in kv:
|
||||
key, value = kv.split('=', maxsplit=1)
|
||||
data[key] = value
|
||||
|
||||
from deploy.set import config_set
|
||||
return config_set(data)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description="Alas installer")
|
||||
parser.add_argument(
|
||||
"--print-test",
|
||||
help="To print example installer outputs instead of making an actual installation",
|
||||
action="store_true",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--set",
|
||||
help="Use key=value format to modify config/deploy.yaml\n"
|
||||
"Example: python installer.py --set Branch=dev",
|
||||
type=str,
|
||||
nargs="*",
|
||||
)
|
||||
args, _ = parser.parse_known_args()
|
||||
|
||||
if args.set:
|
||||
run_set(args.set)
|
||||
elif args.print_test:
|
||||
run_print_test()
|
||||
else:
|
||||
run_install()
|
@ -472,7 +472,7 @@ class ConfigGenerator:
|
||||
def generate_deploy_template():
|
||||
template = poor_yaml_read(DEPLOY_TEMPLATE)
|
||||
cn = {
|
||||
'Repository': 'https://e.coding.net/llop18870/alas/AzurLaneAutoScript.git',
|
||||
'Repository': 'cn',
|
||||
'PypiMirror': 'https://pypi.tuna.tsinghua.edu.cn/simple',
|
||||
'Language': 'zh-CN',
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user