2023-06-30 15:37:09 +08:00
|
|
|
import shutil
|
|
|
|
|
2022-05-07 18:20:28 +08:00
|
|
|
from deploy.git import GitManager
|
2021-10-29 18:45:26 +08:00
|
|
|
from deploy.utils import *
|
2021-10-26 23:09:21 +08:00
|
|
|
from module.handler.login import LoginHandler
|
|
|
|
from module.logger import logger
|
|
|
|
|
2023-06-30 15:37:09 +08:00
|
|
|
localization_txt = """
|
|
|
|
Localization = true
|
|
|
|
Localization_skin = true
|
|
|
|
""".strip() + '\n'
|
|
|
|
|
2021-10-26 23:09:21 +08:00
|
|
|
|
|
|
|
class AzurLaneUncensored(LoginHandler):
|
2023-06-30 15:37:09 +08:00
|
|
|
def create_level1_uncensored(self):
|
|
|
|
logger.info('Create level 1 uncensored')
|
|
|
|
folder = './files'
|
|
|
|
try:
|
|
|
|
shutil.rmtree(folder)
|
|
|
|
except FileNotFoundError:
|
|
|
|
pass
|
|
|
|
os.makedirs(folder, exist_ok=True)
|
|
|
|
with open(os.path.join(folder, 'localization.txt'), 'w', encoding='utf-8') as f:
|
|
|
|
f.write(localization_txt)
|
|
|
|
|
2021-10-26 23:09:21 +08:00
|
|
|
def run(self):
|
|
|
|
"""
|
|
|
|
This will do:
|
|
|
|
1. Update AzurLaneUncensored repo
|
|
|
|
2. Adb push to emulator
|
|
|
|
3. Restart game
|
|
|
|
"""
|
2023-03-31 22:06:04 +08:00
|
|
|
if self.config.AzurLaneUncensored_Repository == 'https://gitee.com/LmeSzinc/AzurLaneUncensored':
|
|
|
|
self.config.AzurLaneUncensored_Repository = 'https://e.coding.net/llop18870/alas/AzurLaneUncensored.git'
|
|
|
|
|
2021-10-26 23:09:21 +08:00
|
|
|
repo = self.config.AzurLaneUncensored_Repository
|
|
|
|
folder = './toolkit/AzurLaneUncensored'
|
|
|
|
|
|
|
|
logger.hr('Update AzurLaneUncensored', level=1)
|
|
|
|
logger.info('This will take a while at first use')
|
|
|
|
manager = GitManager()
|
2021-10-28 14:22:08 +08:00
|
|
|
manager.config['GitExecutable'] = os.path.abspath(manager.config['GitExecutable'])
|
|
|
|
manager.config['AdbExecutable'] = os.path.abspath(manager.config['AdbExecutable'])
|
2021-10-26 23:09:21 +08:00
|
|
|
os.makedirs(folder, exist_ok=True)
|
|
|
|
prev = os.getcwd()
|
2021-10-28 14:22:08 +08:00
|
|
|
|
|
|
|
# Running in ./toolkit/AzurLaneUncensored
|
2021-10-26 23:09:21 +08:00
|
|
|
os.chdir(folder)
|
2021-10-29 18:45:26 +08:00
|
|
|
# Monkey patch `print()` build-in to show logs.
|
2023-06-30 15:37:09 +08:00
|
|
|
self.create_level1_uncensored()
|
|
|
|
# manager.git_repository_init(
|
|
|
|
# repo=repo,
|
|
|
|
# source='origin',
|
|
|
|
# branch='master',
|
|
|
|
# proxy=manager.config['GitProxy'],
|
|
|
|
# keep_changes=False
|
|
|
|
# )
|
2021-10-26 23:09:21 +08:00
|
|
|
|
|
|
|
logger.hr('Push Uncensored Files', level=1)
|
2021-10-29 18:45:26 +08:00
|
|
|
logger.info('This will take a few seconds')
|
2022-04-19 00:17:22 +08:00
|
|
|
command = ['push', 'files', f'/sdcard/Android/data/{self.device.package}']
|
2021-10-26 23:09:21 +08:00
|
|
|
logger.info(f'Command: {command}')
|
2021-11-08 20:44:29 +08:00
|
|
|
self.device.adb_command(command, timeout=30)
|
2021-10-26 23:09:21 +08:00
|
|
|
logger.info('Push success')
|
|
|
|
|
2021-10-28 14:22:08 +08:00
|
|
|
# Back to root folder
|
2021-10-26 23:09:21 +08:00
|
|
|
os.chdir(prev)
|
|
|
|
logger.hr('Restart AzurLane', level=1)
|
2023-04-04 02:44:56 +08:00
|
|
|
self.config.override(Error_HandleError=True)
|
2021-10-26 23:09:21 +08:00
|
|
|
self.device.app_stop()
|
|
|
|
self.device.app_start()
|
|
|
|
self.handle_app_login()
|
|
|
|
|
|
|
|
logger.info('Uncensored Finished')
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
AzurLaneUncensored('alas', task='AzurLaneUncensored').run()
|