2019-04-11 15:49:20 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# -*-coding:UTF-8 -*
|
|
|
|
|
|
|
|
"""
|
|
|
|
Update AIL
|
|
|
|
============================
|
|
|
|
|
|
|
|
Update AIL clone and fork
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import redis
|
|
|
|
import subprocess
|
|
|
|
import configparser
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
|
|
|
configfile = os.path.join(os.environ['AIL_BIN'], 'packages/config.cfg')
|
|
|
|
if not os.path.exists(configfile):
|
|
|
|
raise Exception('Unable to find the configuration file. \
|
|
|
|
Did you set environment variables? \
|
|
|
|
Or activate the virtualenv.')
|
|
|
|
cfg = configparser.ConfigParser()
|
|
|
|
cfg.read(configfile)
|
|
|
|
|
|
|
|
r_serv = redis.StrictRedis(
|
|
|
|
host=cfg.get("ARDB_DB", "host"),
|
|
|
|
port=cfg.getint("ARDB_DB", "port"),
|
|
|
|
db=cfg.getint("ARDB_DB", "db"),
|
|
|
|
decode_responses=True)
|
|
|
|
|
|
|
|
ail_version = r_serv.get('ail:version')
|
|
|
|
if ail_version is None:
|
|
|
|
sys.exit(0)
|
|
|
|
else:
|
|
|
|
if ail_version == 'v1.5':
|
|
|
|
onions_update_status = r_serv.get('v1.5:onions')
|
|
|
|
if onions_update_status is None:
|
2019-04-12 13:06:24 +00:00
|
|
|
update_file = os.path.join(os.environ['AIL_HOME'], 'update', 'v1.4', 'Update-ARDB_Onions.py')
|
|
|
|
process = subprocess.run(['python' ,update_file])
|
|
|
|
|
2019-04-11 15:49:20 +00:00
|
|
|
metadata_update_status = r_serv.get('v1.5:metadata')
|
|
|
|
if metadata_update_status is None:
|
2019-04-12 13:06:24 +00:00
|
|
|
update_file = os.path.join(os.environ['AIL_HOME'], 'update', 'v1.4', 'Update-ARDB_Metadata.py')
|
|
|
|
process = subprocess.run(['python' ,update_file])
|
|
|
|
|
2019-04-11 15:49:20 +00:00
|
|
|
tags_update_status = r_serv.get('v1.5:tags')
|
|
|
|
if tags_update_status is None:
|
2019-04-12 13:06:24 +00:00
|
|
|
update_file = os.path.join(os.environ['AIL_HOME'], 'update', 'v1.4', 'Update-ARDB_Tags.py')
|
|
|
|
process = subprocess.run(['python' ,update_file])
|
|
|
|
|
2019-04-11 15:49:20 +00:00
|
|
|
tags_background_update_status = r_serv.get('v1.5:tags_background')
|
|
|
|
if tags_background_update_status is None:
|
2019-04-12 13:06:24 +00:00
|
|
|
update_file = os.path.join(os.environ['AIL_HOME'], 'update', 'v1.4', 'Update-ARDB_Tags_background.py')
|
|
|
|
process = subprocess.run(['python' ,update_file])
|