2022-07-08 07:47:47 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# -*-coding:UTF-8 -*
|
|
|
|
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import time
|
|
|
|
import datetime
|
|
|
|
|
2022-11-23 10:02:33 +00:00
|
|
|
sys.path.append(os.environ['AIL_BIN'])
|
|
|
|
##################################
|
|
|
|
# Import Project packages
|
|
|
|
##################################
|
|
|
|
from lib import ConfigLoader
|
2022-07-08 07:47:47 +00:00
|
|
|
|
|
|
|
class AIL_Updater(object):
|
|
|
|
"""docstring for AIL_Updater."""
|
|
|
|
|
|
|
|
def __init__(self, new_version):
|
|
|
|
self.version = new_version
|
|
|
|
self.start_time = time.time()
|
|
|
|
|
|
|
|
self.config = ConfigLoader.ConfigLoader()
|
|
|
|
self.r_serv = self.config.get_redis_conn("ARDB_DB")
|
|
|
|
|
|
|
|
self.f_version = float(self.version[1:])
|
|
|
|
self.current_f_version = self.r_serv.get('ail:version')
|
|
|
|
if self.current_f_version:
|
|
|
|
self.current_f_version = float(self.current_f_version[1:])
|
|
|
|
else:
|
|
|
|
self.current_f_version = 0
|
|
|
|
|
|
|
|
def update(self):
|
|
|
|
"""
|
|
|
|
AIL DB update
|
|
|
|
"""
|
|
|
|
pass
|
|
|
|
|
|
|
|
def end_update(self):
|
|
|
|
"""
|
|
|
|
Update DB version
|
|
|
|
"""
|
2022-11-23 10:02:33 +00:00
|
|
|
# Set current ail version
|
2022-07-08 07:47:47 +00:00
|
|
|
self.r_serv.hset('ail:update_date', self.version, datetime.datetime.now().strftime("%Y%m%d"))
|
2022-11-23 10:02:33 +00:00
|
|
|
# Set current ail version
|
2022-07-08 07:47:47 +00:00
|
|
|
if self.f_version > self.current_f_version:
|
|
|
|
self.r_serv.set('ail:version', self.version)
|
|
|
|
|
|
|
|
def run_update(self):
|
|
|
|
self.update()
|
|
|
|
self.end_update()
|