Hotfix: use_mysql
is missing
This commit is contained in:
parent
4b7cde6dfb
commit
8f2b24edaa
|
@ -26,7 +26,7 @@ from titles.ongeki.const import OngekiConstants
|
||||||
|
|
||||||
class AquaData:
|
class AquaData:
|
||||||
def __init__(self, aqua_db_path: str) -> None:
|
def __init__(self, aqua_db_path: str) -> None:
|
||||||
if '@' in aqua_db_path:
|
if "@" in aqua_db_path:
|
||||||
self.__url = f"mysql+pymysql://{aqua_db_path}"
|
self.__url = f"mysql+pymysql://{aqua_db_path}"
|
||||||
else:
|
else:
|
||||||
self.__url = f"sqlite:///{aqua_db_path}"
|
self.__url = f"sqlite:///{aqua_db_path}"
|
||||||
|
@ -93,6 +93,7 @@ class Importer:
|
||||||
self.config_folder = cfg_folder
|
self.config_folder = cfg_folder
|
||||||
self.data = Data(core_cfg)
|
self.data = Data(core_cfg)
|
||||||
self.title_registry: Dict[str, Any] = {}
|
self.title_registry: Dict[str, Any] = {}
|
||||||
|
self.use_mysql = False
|
||||||
|
|
||||||
self.logger = logging.getLogger("importer")
|
self.logger = logging.getLogger("importer")
|
||||||
if not hasattr(self.logger, "initialized"):
|
if not hasattr(self.logger, "initialized"):
|
||||||
|
@ -116,29 +117,29 @@ class Importer:
|
||||||
coloredlogs.install(level="INFO", logger=self.logger, fmt=log_fmt_str)
|
coloredlogs.install(level="INFO", logger=self.logger, fmt=log_fmt_str)
|
||||||
self.logger.initialized = True
|
self.logger.initialized = True
|
||||||
|
|
||||||
if not os.path.isfile(f'{aqua_folder}/application.properties'):
|
if not os.path.isfile(f"{aqua_folder}/application.properties"):
|
||||||
self.logger.error("Could not locate AQUA application.properties file!")
|
self.logger.error("Could not locate AQUA application.properties file!")
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
with open(f'{aqua_folder}/application.properties') as file:
|
with open(f"{aqua_folder}/application.properties") as file:
|
||||||
lines = file.readlines()
|
lines = file.readlines()
|
||||||
|
|
||||||
properties = {}
|
properties = {}
|
||||||
for line in lines:
|
for line in lines:
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
if not line or line.startswith('#'):
|
if not line or line.startswith("#"):
|
||||||
continue
|
continue
|
||||||
parts = line.split('=')
|
parts = line.split("=")
|
||||||
if len(parts) >= 2:
|
if len(parts) >= 2:
|
||||||
key = parts[0].strip()
|
key = parts[0].strip()
|
||||||
value = '='.join(parts[1:]).strip()
|
value = "=".join(parts[1:]).strip()
|
||||||
properties[key] = value
|
properties[key] = value
|
||||||
|
|
||||||
db_driver = properties.get('spring.datasource.driver-class-name')
|
db_driver = properties.get("spring.datasource.driver-class-name")
|
||||||
if 'sqlite' in db_driver:
|
if "sqlite" in db_driver:
|
||||||
aqua_db_path = None
|
aqua_db_path = None
|
||||||
db_url = properties.get('spring.datasource.url').split('sqlite:')[1]
|
db_url = properties.get("spring.datasource.url").split("sqlite:")[1]
|
||||||
temp = os.path.join(f'{aqua_folder}/{db_url}')
|
temp = os.path.join(f"{aqua_folder}/{db_url}")
|
||||||
if os.path.isfile(temp):
|
if os.path.isfile(temp):
|
||||||
aqua_db_path = temp
|
aqua_db_path = temp
|
||||||
|
|
||||||
|
@ -148,12 +149,14 @@ class Importer:
|
||||||
|
|
||||||
self.aqua = AquaData(aqua_db_path)
|
self.aqua = AquaData(aqua_db_path)
|
||||||
|
|
||||||
elif 'mysql' in db_driver or 'mariadb' in db_driver:
|
elif "mysql" in db_driver or "mariadb" in db_driver:
|
||||||
self.use_mysql = True
|
self.use_mysql = True
|
||||||
db_username = properties.get('spring.datasource.username')
|
db_username = properties.get("spring.datasource.username")
|
||||||
db_password = properties.get('spring.datasource.password')
|
db_password = properties.get("spring.datasource.password")
|
||||||
db_url = properties.get('spring.datasource.url').split('?')[0].split('//')[1]
|
db_url = (
|
||||||
self.aqua = AquaData(f'{db_username}:{db_password}@{db_url}')
|
properties.get("spring.datasource.url").split("?")[0].split("//")[1]
|
||||||
|
)
|
||||||
|
self.aqua = AquaData(f"{db_username}:{db_password}@{db_url}")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
self.logger.error("Unknown database type!")
|
self.logger.error("Unknown database type!")
|
||||||
|
@ -751,5 +754,6 @@ def main():
|
||||||
importer.import_chuni()
|
importer.import_chuni()
|
||||||
importer.import_ongeki()
|
importer.import_ongeki()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user