-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
55 lines (45 loc) · 1.71 KB
/
app.py
File metadata and controls
55 lines (45 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import filecmp
import shutil
from deploy.Windows.config import DeployConfig
from deploy.Windows.logger import logger
from deploy.Windows.utils import *
class AppManager(DeployConfig):
@staticmethod
def app_asar_replace(folder, path='./toolkit/WebApp/resources/app.asar'):
"""
Args:
folder (str): Path to AzurLaneAutoScript
path (str): Path from AzurLaneAutoScript to app.asar
Returns:
bool: If updated.
"""
source = os.path.abspath(os.path.join(folder, path))
logger.info(f'Old file: {source}')
try:
import alas_webapp
except ImportError:
logger.info(f'Dependency alas_webapp not exists, skip updating')
return False
update = alas_webapp.app_file()
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):
logger.info('app.asar is already up to date')
return False
else:
# Keyword "Update app.asar" is used in AlasApp
# to determine whether there is a hot update
logger.info(f'Update app.asar {update} -----> {source}')
os.remove(source)
shutil.copy(update, source)
return True
else:
logger.info(f'{source} not exists, skip updating')
return False
def app_update(self):
logger.hr(f'Update app', 0)
if not self.AutoUpdate:
logger.info('AutoUpdate is disabled, skip')
return False
return self.app_asar_replace(os.getcwd())