2019-04-11 15:49:20 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# -*-coding:UTF-8 -*
|
|
|
|
|
|
|
|
"""
|
|
|
|
Update AIL
|
|
|
|
============================
|
|
|
|
|
2019-04-12 14:07:40 +00:00
|
|
|
Update AIL in the background
|
2019-04-11 15:49:20 +00:00
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import subprocess
|
2019-11-05 14:18:03 +00:00
|
|
|
|
2022-07-08 07:47:47 +00:00
|
|
|
sys.path.append(os.environ['AIL_BIN'])
|
|
|
|
##################################
|
|
|
|
# Import Project packages
|
|
|
|
##################################
|
|
|
|
from lib import ail_updates
|
2019-04-11 15:49:20 +00:00
|
|
|
|
2021-01-22 16:03:43 +00:00
|
|
|
def launch_background_upgrade(version, l_script_name):
|
2022-07-08 07:47:47 +00:00
|
|
|
if ail_updates.is_version_in_background_update(version):
|
|
|
|
ail_updates.start_background_update(version)
|
2020-12-11 20:02:07 +00:00
|
|
|
|
2021-01-22 16:03:43 +00:00
|
|
|
for script_name in l_script_name:
|
2022-07-08 07:47:47 +00:00
|
|
|
ail_updates.set_current_background_update_script(script_name)
|
|
|
|
update_file = ail_updates.get_current_background_update_script_path(version, script_name)
|
|
|
|
|
|
|
|
# # TODO: Get error output
|
2022-11-28 14:01:40 +00:00
|
|
|
process = subprocess.run(['python', update_file])
|
2020-12-11 20:02:07 +00:00
|
|
|
|
2022-07-08 07:47:47 +00:00
|
|
|
update_progress = ail_updates.get_current_background_update_progress()
|
|
|
|
if update_progress == 100:
|
|
|
|
ail_updates.end_background_update_script()
|
|
|
|
# # TODO: Create Custom error
|
|
|
|
# 'Please relaunch the bin/update-background.py script'
|
|
|
|
# # TODO: Create Class background update
|
2020-12-11 20:02:07 +00:00
|
|
|
|
2022-11-28 14:01:40 +00:00
|
|
|
ail_updates.end_background_update(version)
|
|
|
|
|
2021-01-22 16:03:43 +00:00
|
|
|
|
2019-04-11 15:49:20 +00:00
|
|
|
if __name__ == "__main__":
|
|
|
|
|
2022-07-08 07:47:47 +00:00
|
|
|
if not ail_updates.exits_background_update_to_launch():
|
|
|
|
ail_updates.clear_background_update()
|
|
|
|
else:
|
2022-11-28 14:01:40 +00:00
|
|
|
launch_background_upgrade('v1.5', ['Update-ARDB_Onions.py', 'Update-ARDB_Metadata.py', 'Update-ARDB_Tags.py',
|
|
|
|
'Update-ARDB_Tags_background.py', 'Update-ARDB_Onions_screenshots.py'])
|
2022-07-08 07:47:47 +00:00
|
|
|
launch_background_upgrade('v2.6', ['Update_screenshots.py'])
|
|
|
|
launch_background_upgrade('v2.7', ['Update_domain_tags.py'])
|
|
|
|
launch_background_upgrade('v3.4', ['Update_domain.py'])
|
|
|
|
launch_background_upgrade('v3.7', ['Update_trackers.py'])
|