🎨 Moved apk to inside app class

This commit is contained in:
Nikhil Badyal
2023-08-23 10:18:15 +05:30
parent b635e697ce
commit ee534b150a
2 changed files with 22 additions and 13 deletions
+1 -7
View File
@@ -5,7 +5,6 @@ from environs import Env
from loguru import logger from loguru import logger
from src.config import RevancedConfig from src.config import RevancedConfig
from src.downloader.factory import DownloaderFactory
from src.exceptions import AppNotFound, PatchesJsonLoadFailed, PatchingFailed from src.exceptions import AppNotFound, PatchesJsonLoadFailed, PatchingFailed
from src.parser import Parser from src.parser import Parser
from src.patches import Patches from src.patches import Patches
@@ -30,13 +29,8 @@ def main() -> None:
patcher = Patches(config, app) patcher = Patches(config, app)
parser = Parser(patcher, config) parser = Parser(patcher, config)
app_all_patches = patcher.get_app_configs(app) app_all_patches = patcher.get_app_configs(app)
app.download_apk_for_patching(config)
patcher.include_exclude_patch(app, parser, app_all_patches) patcher.include_exclude_patch(app, parser, app_all_patches)
downloader = DownloaderFactory.create_downloader(
app=app.app_name, config=config
)
app.download_file_name, app.download_dl = downloader.download(
app.app_version, app.app_name
)
logger.info(app) logger.info(app)
parser.patch_app(app) parser.patch_app(app)
except AppNotFound as e: except AppNotFound as e:
+21 -6
View File
@@ -3,7 +3,7 @@ import concurrent
import hashlib import hashlib
import pathlib import pathlib
from concurrent.futures import ThreadPoolExecutor from concurrent.futures import ThreadPoolExecutor
from typing import Dict from typing import Dict, List
from loguru import logger from loguru import logger
@@ -29,20 +29,35 @@ class APP(object):
self.patches_json_dl = config.env.str( self.patches_json_dl = config.env.str(
f"{app_name}_PATCHES_JSON_DL".upper(), config.global_patches_json_dl f"{app_name}_PATCHES_JSON_DL".upper(), config.global_patches_json_dl
) )
self.exclude_request = config.env.list(f"{app_name}_EXCLUDE_PATCH".upper(), []) self.exclude_request: List[str] = config.env.list(
self.include_request = config.env.list(f"{app_name}_INCLUDE_PATCH".upper(), []) f"{app_name}_EXCLUDE_PATCH".upper(), []
)
self.include_request: List[str] = config.env.list(
f"{app_name}_INCLUDE_PATCH".upper(), []
)
self.resource: Dict[str, str] = {} self.resource: Dict[str, str] = {}
self.no_of_patches = 0 self.no_of_patches: int = 0
self.keystore_name = config.env.str( self.keystore_name = config.env.str(
f"{app_name}_KEYSTORE_FILE_NAME".upper(), config.global_keystore_name f"{app_name}_KEYSTORE_FILE_NAME".upper(), config.global_keystore_name
) )
self.archs_to_build = config.env.list( self.archs_to_build = config.env.list(
f"{app_name}_ARCHS_TO_BUILD".upper(), config.global_archs_to_build f"{app_name}_ARCHS_TO_BUILD".upper(), config.global_archs_to_build
) )
self.download_file_name = None self.download_file_name = ""
self.download_dl = None self.download_dl = ""
self.download_patch_resources(config) self.download_patch_resources(config)
def download_apk_for_patching(self, config: RevancedConfig) -> None:
"""Download apk to be patched."""
from src.downloader.factory import DownloaderFactory
logger.info("Downloading apk to be patched")
downloader = DownloaderFactory.create_downloader(
app=self.app_name, config=config
)
self.download_file_name, self.download_dl = downloader.download(
self.app_version, self.app_name
)
def get_output_file_name(self) -> str: def get_output_file_name(self) -> str:
"""The function returns a string representing the output file name for """The function returns a string representing the output file name for
an APK file appended with version. an APK file appended with version.