Skip to content

Commit

Permalink
Merge pull request #1260 from LmeSzinc/dev
Browse files Browse the repository at this point in the history
Bug fix
  • Loading branch information
LmeSzinc authored Jun 26, 2022
2 parents 7bfff90 + 1b65a91 commit 047d1bc
Show file tree
Hide file tree
Showing 51 changed files with 264 additions and 227 deletions.
1 change: 0 additions & 1 deletion campaign/campaign_main/campaign_11_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
90 90 90 90 90 90 90 90
90 90 90 90 90 90 90 90
90 90 90 90 90 90 90 90
"""
MAP.spawn_data = [
{'battle': 0, 'enemy': 2},
Expand Down
1 change: 0 additions & 1 deletion campaign/campaign_main/campaign_11_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
90 90 90 90 90 90 90 10 05 90 90
90 90 90 90 90 25 20 15 90 90 90
90 90 90 40 35 30 90 90 90 90 90
"""
MAP.spawn_data = [
{'battle': 0, 'enemy': 3},
Expand Down
2 changes: 1 addition & 1 deletion campaign/campaign_main/campaign_11_3.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
90 90 90 90 90 90 90 90 90
90 90 90 90 90 90 90 90 90
90 90 90 90 90 90 90 90 90
90 90 90 90 90 90 90 90 90
90 90 90 90 90 90 90 90 90
"""
MAP.spawn_data = [
{'battle': 0, 'enemy': 3},
Expand Down
1 change: 0 additions & 1 deletion campaign/campaign_main/campaign_8_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
20 20 20 10 10 20 20 35
50 90 90 60 60 90 90 90
90 90 90 70 80 90 90 90
"""
MAP.spawn_data = [
{'battle': 0, 'enemy': 3},
Expand Down
1 change: 0 additions & 1 deletion campaign/event_20200312_cn/sp3.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
++ ++ ++ -- -- -- -- ++ --
MB -- ME ME -- ++ -- ME --
-- ME -- -- SP ++ -- -- --
'''
MAP.weight_data = '''
10 10 10 10 10 10 10 10 10
Expand Down
2 changes: 1 addition & 1 deletion campaign/event_20200521_en/b3.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
-- ME ++ -- -- ME ++ ++ ++
-- -- MS -- ++ ME -- ME --
SP -- -- -- ++ -- -- ME --
SP -- MS -- -- ME -- -- --
SP -- MS -- -- ME -- -- --
'''
A1, B1, C1, D1, E1, F1, G1, H1, I1, \
A2, B2, C2, D2, E2, F2, G2, H2, I2, \
Expand Down
14 changes: 7 additions & 7 deletions campaign/event_20200521_en/d2.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
MAP.shape = 'I7'
MAP.camera_data = ['D2', 'D5', 'F3', 'F5']
MAP.map_data = '''
SP -- -- -- -- -- ME ++ MB
-- ME -- MS ME -- -- ++ --
-- -- ME ++ ++ ++ -- -- --
ME __ -- ME ME ME -- MS --
ME MS -- ++ ++ ++ -- -- --
-- ME -- ME -- -- -- ++ --
SP -- -- -- -- ME -- ++ MB
SP -- -- -- -- -- ME ++ MB
-- ME -- MS ME -- -- ++ --
-- -- ME ++ ++ ++ -- -- --
ME __ -- ME ME ME -- MS --
ME MS -- ++ ++ ++ -- -- --
-- ME -- ME -- -- -- ++ --
SP -- -- -- -- ME -- ++ MB
'''
MAP.weight_data = '''
10 10 10 10 10 10 10 10 10
Expand Down
2 changes: 1 addition & 1 deletion campaign/event_20200521_en/d3.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
-- ME ++ -- -- ME ++ ++ ++
-- -- MS -- ++ ME -- ME --
SP -- -- -- ++ -- -- ME --
SP -- MS -- -- ME -- -- --
SP -- MS -- -- ME -- -- --
'''
A1, B1, C1, D1, E1, F1, G1, H1, I1, \
A2, B2, C2, D2, E2, F2, G2, H2, I2, \
Expand Down
4 changes: 2 additions & 2 deletions campaign/event_20200603_en/sp3.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
MAP = CampaignMap('sp3')
MAP.shape = 'i6'
MAP.map_data = '''
++ MB -- ME -- ME -- ++ ++
MB -- ME -- ++ -- ME ++ ++
++ MB -- ME -- ME -- ++ ++
MB -- ME -- ++ -- ME ++ ++
MB ME -- ME -- ME -- ME --
++ ++ ++ -- ME -- ME ++ --
MB -- ME ME -- ++ -- -- SP
Expand Down
2 changes: 1 addition & 1 deletion campaign/war_archives_20210325_cn/campaign_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class CampaignBase(CampaignBase_):
Override full scan methods to make sure that, Dace can be kept when tracking siren movements.
"""
dace = None

def full_scan_movable(self, *args, **kwargs):
self.dace = self.map.select(enemy_genre='Siren_Dace')
logger.attr('Submarine_Dace', self.dace)
Expand Down
5 changes: 3 additions & 2 deletions deploy/AidLux/requirements_generator.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import re
from deploy.logger import logger

BASE_FOLDER = './deploy/AidLux'

Expand Down Expand Up @@ -41,10 +42,10 @@ def write_file(file, data):


def aidlux_requirements_generate(requirements_in='requirements-in.txt'):
print('aidlux_requirements_generate')
logger.info('aidlux_requirements_generate')
requirements = read_file(requirements_in)
for aidlux in iter_version():
print(f'Generate requirements for AidLux {aidlux}')
logger.info(f'Generate requirements for AidLux {aidlux}')
pre_installed = read_file(os.path.join(BASE_FOLDER, f'./{aidlux}/pre-installed.txt'))
new = {}
for name, version in requirements.items():
Expand Down
15 changes: 8 additions & 7 deletions deploy/adb.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

from deploy.config import DeployConfig
from deploy.emulator import EmulatorConnect
from deploy.logger import logger
from deploy.utils import *


def show_fix_tip(module):
print(f"""
logger.info(f"""
To fix this:
1. Open console.bat
2. Execute the following commands:
Expand All @@ -22,18 +23,18 @@ def adb(self):
return self.filepath('AdbExecutable')

def adb_install(self):
hr0('Start ADB service')
logger.hr('Start ADB service', 0)

emulator = EmulatorConnect(adb=self.adb)
if self.ReplaceAdb:
hr1('Replace ADB')
logger.hr('Replace ADB', 1)
emulator.adb_replace()
elif self.AutoConnect:
hr1('ADB Connect')
logger.hr('ADB Connect', 1)
emulator.brute_force_connect()

if self.InstallUiautomator2:
hr1('Uiautomator2 Init')
logger.hr('Uiautomator2 Init', 1)
try:
import adbutils
except ModuleNotFoundError as e:
Expand All @@ -57,8 +58,8 @@ def adb_install(self):
try:
init.install()
except AssertionError:
print(f'AssertionError when installing uiautomator2 on device {device.serial}')
print('If you are using BlueStacks or LD player or WSA, '
logger.info(f'AssertionError when installing uiautomator2 on device {device.serial}')
logger.info('If you are using BlueStacks or LD player or WSA, '
'please enable ADB in the settings of your emulator')
exit(1)
init._device.shell(["rm", "/data/local/tmp/minicap"])
Expand Down
13 changes: 7 additions & 6 deletions deploy/alas.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from deploy.config import DeployConfig
from deploy.logger import logger
from deploy.utils import *


Expand All @@ -25,7 +26,7 @@ def iter_process_by_name(self, name):
try:
from win32com.client import GetObject
except ModuleNotFoundError:
print('pywin32 not installed, skip')
logger.info('pywin32 not installed, skip')
return False

try:
Expand All @@ -44,20 +45,20 @@ def iter_process_by_name(self, name):
except Exception as e:
# Possible exception
# pywintypes.com_error: (-2147217392, 'OLE error 0x80041010', None, None)
print(str(e))
logger.info(str(e))
return False

def kill_by_name(self, name):
"""
Args:
name (str): Process name
"""
hr1(f'Kill {name}')
logger.hr(f'Kill {name}', 1)
for row in self.iter_process_by_name(name):
print(' '.join(map(str, row)))
self.execute(f'taskkill /f /pid {row[2]}', allow_failure=True)
logger.info(' '.join(map(str, row)))
self.execute(f'taskkill /f /pid {row[2]}', allow_failure=True, output=False)

def alas_kill(self):
hr0(f'Kill existing Alas')
logger.hr(f'Kill existing Alas', 0)
self.kill_by_name('alas.exe')
self.kill_by_name('python.exe')
19 changes: 10 additions & 9 deletions deploy/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import shutil

from deploy.config import DeployConfig
from deploy.logger import logger
from deploy.utils import *


Expand All @@ -17,36 +18,36 @@ def app_asar_replace(folder, path='./toolkit/WebApp/resources/app.asar'):
bool: If updated.
"""
source = os.path.abspath(os.path.join(folder, path))
print(f'Old file: {source}')
logger.info(f'Old file: {source}')

try:
import alas_webapp
except ImportError:
print(f'Dependency alas_webapp not exists, skip updating')
logger.info(f'Dependency alas_webapp not exists, skip updating')
return False

update = alas_webapp.app_file()
print(f'New version: {alas_webapp.__version__}')
print(f'New file: {update}')
logger.info(f'New version: {alas_webapp.__version__}')
logger.info(f'New file: {update}')

if os.path.exists(source):
if filecmp.cmp(source, update, shallow=True):
print('app.asar is already up to date')
logger.info('app.asar is already up to date')
return False
else:
print(f'Copy {update} -----> {source}')
logger.info(f'Copy {update} -----> {source}')
os.remove(source)
shutil.copy(update, source)
return True
else:
print(f'{source} not exists, skip updating')
logger.info(f'{source} not exists, skip updating')
return False

def app_update(self):
hr0(f'Update app.asar')
logger.hr(f'Update app.asar', 0)

if not self.AutoUpdate:
print('AutoUpdate is disabled, skip')
logger.info('AutoUpdate is disabled, skip')
return False

return self.app_asar_replace(os.getcwd())
31 changes: 18 additions & 13 deletions deploy/config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import copy
from typing import Optional, Union

from deploy.logger import logger
from deploy.utils import *


Expand Down Expand Up @@ -66,15 +67,15 @@ def __init__(self, file=DEPLOY_CONFIG):
self.show_config()

def show_config(self):
hr0("Show deploy config")
logger.hr("Show deploy config", 1)
for k, v in self.config.items():
if k in ("Password"):
continue
if self.config_template[k] == v:
continue
print(f"{k}: {v}")
logger.info(f"{k}: {v}")

print(f"Rest of the configs are the same as default")
logger.info(f"Rest of the configs are the same as default")

def read(self):
self.config = poor_yaml_read(DEPLOY_TEMPLATE)
Expand Down Expand Up @@ -112,36 +113,40 @@ def root_filepath(self):
.replace('"', '"')
)

def execute(self, command, allow_failure=False):
def execute(self, command, allow_failure=False, output=True):
"""
Args:
command (str):
allow_failure (bool):
output(bool):
Returns:
bool: If success.
Terminate installation if failed to execute and not allow_failure.
"""
command = command.replace(r"\\", "/").replace("\\", "/").replace('"', '"')
print(command)
if not output:
command = command + ' >nul 2>nul'
logger.info(command)
error_code = os.system(command)
if error_code:
if allow_failure:
print(f"[ allowed failure ], error_code: {error_code}")
logger.info(f"[ allowed failure ], error_code: {error_code}")
return False
else:
print(f"[ failure ], error_code: {error_code}")
self.show_error()
logger.info(f"[ failure ], error_code: {error_code}")
self.show_error(command, error_code)
raise ExecutionError
else:
print(f"[ success ]")
logger.info(f"[ success ]")
return True

def show_error(self):
def show_error(self, command=None, error_code=None):
logger.hr("Update failed", 0)
self.show_config()
print("")
hr1("Update failed")
print(
logger.info("")
logger.info(f"Last command: {command}\nerror_code: {error_code}")
logger.info(
"Please check your deploy settings in config/deploy.yaml "
"and re-open Alas.exe"
)
7 changes: 4 additions & 3 deletions deploy/docker/requirements_generator.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import os
from deploy.logger import logger

BASE_FOLDER = os.path.dirname(os.path.abspath(__file__))
print(BASE_FOLDER)
logger.info(BASE_FOLDER)

def read_file(file):
out = {}
Expand Down Expand Up @@ -37,10 +38,10 @@ def docker_requirements_generate(requirements_in='requirements-in.txt'):

requirements = read_file(requirements_in)

print(f'Generate requirements for Docker image')
logger.info(f'Generate requirements for Docker image')

new = {}
print(requirements)
logger.info(requirements)
for name, version in requirements.items():
# alas-webapp is for windows only
if name == 'alas-webapp':
Expand Down
Loading

0 comments on commit 047d1bc

Please sign in to comment.