mirror of
https://github.com/ail-project/ail-framework.git
synced 2024-11-30 01:37:17 +00:00
chg [Update] update AIL clone and fork
This commit is contained in:
parent
60ff0b9cf7
commit
7aff45c507
1 changed files with 170 additions and 121 deletions
291
bin/Update.py
291
bin/Update.py
|
@ -1,6 +1,14 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# -*-coding:UTF-8 -*
|
# -*-coding:UTF-8 -*
|
||||||
|
|
||||||
|
"""
|
||||||
|
Update AIL
|
||||||
|
============================
|
||||||
|
|
||||||
|
Update AIL clone and fork
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
import configparser
|
import configparser
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
@ -21,14 +29,18 @@ def check_if_files_modified():
|
||||||
if process.returncode == 0:
|
if process.returncode == 0:
|
||||||
modified_files = process.stdout
|
modified_files = process.stdout
|
||||||
if modified_files:
|
if modified_files:
|
||||||
|
print('Modified Files:')
|
||||||
|
print('{}{}{}'.format(TERMINAL_BLUE, modified_files.decode(), TERMINAL_DEFAULT))
|
||||||
return False
|
return False
|
||||||
|
#return True
|
||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
print(TERMINAL_RED+process.stderr.decode()+TERMINAL_DEFAULT)
|
print('{}{}{}'.format(TERMINAL_RED, process.stderr.decode(), TERMINAL_DEFAULT))
|
||||||
return False
|
sys.exit(1)
|
||||||
|
|
||||||
def repo_is_fork():
|
def repo_is_fork():
|
||||||
|
print('Check if this repository is a fork:')
|
||||||
process = subprocess.run(['git', 'ls-remote', '--tags'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
process = subprocess.run(['git', 'ls-remote', '--tags'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
|
||||||
if process.returncode == 0:
|
if process.returncode == 0:
|
||||||
|
@ -38,15 +50,21 @@ def repo_is_fork():
|
||||||
|
|
||||||
if process.returncode == 0:
|
if process.returncode == 0:
|
||||||
ail_remote = process.stdout
|
ail_remote = process.stdout
|
||||||
print(local_remote)
|
|
||||||
print(ail_remote)
|
|
||||||
if local_remote == ail_remote:
|
if local_remote == ail_remote:
|
||||||
|
print(' This repository is a {}clone of {}{}'.format(TERMINAL_BLUE, AIL_REPO, TERMINAL_DEFAULT))
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
|
print(' This repository is a {}fork{}'.format(TERMINAL_BLUE, TERMINAL_DEFAULT))
|
||||||
|
print()
|
||||||
return True
|
return True
|
||||||
|
else:
|
||||||
|
print('{}{}{}'.format(TERMINAL_RED, process.stderr.decode(), TERMINAL_DEFAULT))
|
||||||
|
aborting_update()
|
||||||
|
sys.exit(0)
|
||||||
else:
|
else:
|
||||||
print(TERMINAL_RED+process.stderr.decode()+TERMINAL_DEFAULT)
|
print('{}{}{}'.format(TERMINAL_RED, process.stderr.decode(), TERMINAL_DEFAULT))
|
||||||
return False
|
aborting_update()
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
def is_upstream_created(upstream):
|
def is_upstream_created(upstream):
|
||||||
process = subprocess.run(['git', 'remote', '-v'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
process = subprocess.run(['git', 'remote', '-v'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
@ -57,47 +75,64 @@ def is_upstream_created(upstream):
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
print(process.stderr.decode())
|
print('{}{}{}'.format(TERMINAL_RED, process.stderr.decode(), TERMINAL_DEFAULT))
|
||||||
return None
|
aborting_update()
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
def create_fork_upstream(upstream):
|
def create_fork_upstream(upstream):
|
||||||
|
print('{}... Creating upstream ...{}'.format(TERMINAL_YELLOW, TERMINAL_DEFAULT))
|
||||||
|
print('git remote add {} {}'.format(upstream, AIL_REPO))
|
||||||
process = subprocess.run(['git', 'remote', 'add', upstream, AIL_REPO], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
process = subprocess.run(['git', 'remote', 'add', upstream, AIL_REPO], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
if process.returncode == 0:
|
if process.returncode == 0:
|
||||||
print(process.stdout.decode())
|
print(process.stdout.decode())
|
||||||
if is_upstream_created():
|
if is_upstream_created(upstream):
|
||||||
print('fork created')
|
print('Fork upstream created')
|
||||||
|
print('{}... ...{}'.format(TERMINAL_YELLOW, TERMINAL_DEFAULT))
|
||||||
else:
|
else:
|
||||||
print('error, fork not created')
|
print('Fork not created')
|
||||||
|
aborting_update()
|
||||||
|
sys.exit(0)
|
||||||
else:
|
else:
|
||||||
print(process.stderr.decode())
|
print('{}{}{}'.format(TERMINAL_RED, process.stderr.decode(), TERMINAL_DEFAULT))
|
||||||
return None
|
aborting_update()
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
def update_fork():
|
def update_fork():
|
||||||
|
print('{}... Updating fork ...{}'.format(TERMINAL_YELLOW, TERMINAL_DEFAULT))
|
||||||
if cfg.get('Update', 'update-fork') == 'True' or cfg.get('Update', 'update-fork') == 'true':
|
if cfg.get('Update', 'update-fork') == 'True' or cfg.get('Update', 'update-fork') == 'true':
|
||||||
upstream = cfg.get('Update', 'upstream')
|
upstream = cfg.get('Update', 'upstream')
|
||||||
if not is_upstream_created(upstream):
|
if not is_upstream_created(upstream):
|
||||||
create_fork_upstream(upstream)
|
create_fork_upstream(upstream)
|
||||||
|
print('{}git fetch {}:{}'.format(TERMINAL_YELLOW, upstream, TERMINAL_DEFAULT))
|
||||||
process = subprocess.run(['git', 'fetch', upstream], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
process = subprocess.run(['git', 'fetch', upstream], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
if process.returncode == 0:
|
if process.returncode == 0:
|
||||||
print(process.stdout.decode())
|
print(process.stdout.decode())
|
||||||
|
print('{}git checkout master:{}'.format(TERMINAL_YELLOW, TERMINAL_DEFAULT))
|
||||||
process = subprocess.run(['git', 'checkout', 'master'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
process = subprocess.run(['git', 'checkout', 'master'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
if process.returncode == 0:
|
if process.returncode == 0:
|
||||||
print(process.stdout.decode())
|
print(process.stdout.decode())
|
||||||
|
print('{}git merge {}/master:{}'.format(TERMINAL_YELLOW, upstream, TERMINAL_DEFAULT))
|
||||||
process = subprocess.run(['git', 'merge', '{}/master'.format(upstream)], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
process = subprocess.run(['git', 'merge', '{}/master'.format(upstream)], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
if process.returncode == 0:
|
if process.returncode == 0:
|
||||||
print(process.stdout.decode())
|
print(process.stdout.decode())
|
||||||
|
print('{}... ...{}'.format(TERMINAL_YELLOW, TERMINAL_DEFAULT))
|
||||||
else:
|
else:
|
||||||
print(process.stderr.decode())
|
print('{}{}{}'.format(TERMINAL_RED, process.stderr.decode(), TERMINAL_DEFAULT))
|
||||||
return None
|
aborting_update()
|
||||||
|
sys.exit(1)
|
||||||
else:
|
else:
|
||||||
print(process.stderr.decode())
|
print('{}{}{}'.format(TERMINAL_RED, process.stderr.decode(), TERMINAL_DEFAULT))
|
||||||
return None
|
aborting_update()
|
||||||
|
sys.exit(0)
|
||||||
else:
|
else:
|
||||||
print(process.stderr.decode())
|
print('{}{}{}'.format(TERMINAL_RED, process.stderr.decode(), TERMINAL_DEFAULT))
|
||||||
return None
|
aborting_update()
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print('auto update fork disabled, you can active it in ...')
|
print('{}Fork Auto-Update disabled in config file{}'.format(TERMINAL_YELLOW, TERMINAL_DEFAULT))
|
||||||
|
aborting_update()
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
def get_git_current_tag(current_version_path):
|
def get_git_current_tag(current_version_path):
|
||||||
|
@ -106,58 +141,68 @@ def get_git_current_tag(current_version_path):
|
||||||
version = version.replace(" ", "").splitlines()
|
version = version.replace(" ", "").splitlines()
|
||||||
return version[0]
|
return version[0]
|
||||||
|
|
||||||
'''
|
def get_git_upper_tags_remote(current_tag, is_fork):
|
||||||
process = subprocess.run(['git', 'describe' ,'--tags'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
if is_fork:
|
||||||
|
process = subprocess.run(['git', 'tag'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
if process.returncode == 0:
|
||||||
|
list_all_tags = process.stdout.decode().splitlines()
|
||||||
|
|
||||||
if process.returncode == 0:
|
list_upper_tags = []
|
||||||
current_tag = process.stdout
|
if list_all_tags[-1][1:] == current_tag:
|
||||||
current_tag = current_tag.split(b'-')[0]
|
list_upper_tags.append( (list_all_tags[-1], None) )
|
||||||
return current_tag.decode()
|
return list_upper_tags
|
||||||
else:
|
for tag in list_all_tags:
|
||||||
print(process.stderr.decode())
|
if float(tag[1:]) >= float(current_tag):
|
||||||
return None
|
list_upper_tags.append( (tag, None) )
|
||||||
'''
|
|
||||||
|
|
||||||
def get_git_upper_tags_remote(current_tag):
|
|
||||||
process = subprocess.run(['git', 'ls-remote' ,'--tags'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
||||||
|
|
||||||
if process.returncode == 0:
|
|
||||||
list_all_tags = process.stdout.decode().splitlines()
|
|
||||||
list_all_tags.append('aaaaaaaaaaaaaaaaaaaaaaaaaaaaa\trefs/tags/v1.5')
|
|
||||||
list_all_tags.append('eeeeeeeeeeeeeeeeeeeeeeeeeeee\trefs/tags/v1.5^{}')
|
|
||||||
list_all_tags.append('bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\trefs/tags/v1.6')
|
|
||||||
list_all_tags.append('bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\trefs/tags/v1.6^{}')
|
|
||||||
list_all_tags.append('zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\trefs/tags/v1.7')
|
|
||||||
last_tag = list_all_tags[-1].split('\trefs/tags/')
|
|
||||||
last_commit = last_tag[0]
|
|
||||||
last_tag = last_tag[1].split('^{}')[0]
|
|
||||||
list_upper_tags = []
|
|
||||||
if last_tag[1:] == current_tag:
|
|
||||||
list_upper_tags.append( (last_tag, last_commit) )
|
|
||||||
return list_upper_tags
|
return list_upper_tags
|
||||||
else:
|
else:
|
||||||
for mess_tag in list_all_tags:
|
print('{}{}{}'.format(TERMINAL_RED, process.stderr.decode(), TERMINAL_DEFAULT))
|
||||||
commit, tag = mess_tag.split('\trefs/tags/')
|
aborting_update()
|
||||||
|
sys.exit(0)
|
||||||
# add tag with last commit
|
|
||||||
if float(tag.split('^{}')[0][1:]) >= float(current_tag):
|
|
||||||
if '^{}' in tag:
|
|
||||||
list_upper_tags.append( (tag.split('^{}')[0], commit) )
|
|
||||||
# add last commit
|
|
||||||
if last_tag not in list_upper_tags[-1][0]:
|
|
||||||
list_upper_tags.append( (last_tag, last_commit) )
|
|
||||||
return list_upper_tags
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print(TERMINAL_RED+process.stderr.decode()+TERMINAL_DEFAULT)
|
process = subprocess.run(['git', 'ls-remote' ,'--tags'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
return None
|
|
||||||
|
|
||||||
def update_ail(current_tag, list_upper_tags_remote, current_version_path):
|
if process.returncode == 0:
|
||||||
print('git checkout master:')
|
list_all_tags = process.stdout.decode().splitlines()
|
||||||
|
list_all_tags.append('aaaaaaaaaaaaaaaaaaaaaaaaaaaaa\trefs/tags/v1.5')
|
||||||
|
list_all_tags.append('eeeeeeeeeeeeeeeeeeeeeeeeeeee\trefs/tags/v1.5^{}')
|
||||||
|
list_all_tags.append('bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\trefs/tags/v1.6')
|
||||||
|
list_all_tags.append('bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\trefs/tags/v1.6^{}')
|
||||||
|
#list_all_tags.append('zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\trefs/tags/v1.7')
|
||||||
|
last_tag = list_all_tags[-1].split('\trefs/tags/')
|
||||||
|
last_commit = last_tag[0]
|
||||||
|
last_tag = last_tag[1].split('^{}')[0]
|
||||||
|
list_upper_tags = []
|
||||||
|
if last_tag[1:] == current_tag:
|
||||||
|
list_upper_tags.append( (last_tag, last_commit) )
|
||||||
|
return list_upper_tags
|
||||||
|
else:
|
||||||
|
for mess_tag in list_all_tags:
|
||||||
|
commit, tag = mess_tag.split('\trefs/tags/')
|
||||||
|
|
||||||
|
# add tag with last commit
|
||||||
|
if float(tag.split('^{}')[0][1:]) >= float(current_tag):
|
||||||
|
if '^{}' in tag:
|
||||||
|
list_upper_tags.append( (tag.split('^{}')[0], commit) )
|
||||||
|
# add last commit
|
||||||
|
if last_tag not in list_upper_tags[-1][0]:
|
||||||
|
list_upper_tags.append( (last_tag, last_commit) )
|
||||||
|
return list_upper_tags
|
||||||
|
|
||||||
|
else:
|
||||||
|
print('{}{}{}'.format(TERMINAL_RED, process.stderr.decode(), TERMINAL_DEFAULT))
|
||||||
|
aborting_update()
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
def update_ail(current_tag, list_upper_tags_remote, current_version_path, is_fork):
|
||||||
|
print('{}git checkout master:{}'.format(TERMINAL_YELLOW, TERMINAL_DEFAULT))
|
||||||
process = subprocess.run(['git', 'checkout', 'master'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
process = subprocess.run(['git', 'checkout', 'master'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
#process = subprocess.run(['git', 'status'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
|
||||||
if process.returncode == 0:
|
if process.returncode == 0:
|
||||||
print('git pull:')
|
print(process.stdout.decode())
|
||||||
|
print()
|
||||||
|
print('{}git pull:{}'.format(TERMINAL_YELLOW, TERMINAL_DEFAULT))
|
||||||
process = subprocess.run(['git', 'pull'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
process = subprocess.run(['git', 'pull'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
|
||||||
if process.returncode == 0:
|
if process.returncode == 0:
|
||||||
|
@ -165,8 +210,10 @@ def update_ail(current_tag, list_upper_tags_remote, current_version_path):
|
||||||
print(output)
|
print(output)
|
||||||
|
|
||||||
if len(list_upper_tags_remote) == 1:
|
if len(list_upper_tags_remote) == 1:
|
||||||
print('AIL Updated')
|
print()
|
||||||
# # FIXME: # TODO: exit sucess
|
print('{}**************** AIL Sucessfully Updated *****************{}'.format(TERMINAL_YELLOW, TERMINAL_DEFAULT))
|
||||||
|
print()
|
||||||
|
exit(0)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# map version with roll back commit
|
# map version with roll back commit
|
||||||
|
@ -176,76 +223,78 @@ def update_ail(current_tag, list_upper_tags_remote, current_version_path):
|
||||||
tag = tuple[0]
|
tag = tuple[0]
|
||||||
list_update.append( (tag, previous_commit) )
|
list_update.append( (tag, previous_commit) )
|
||||||
previous_commit = tuple[1]
|
previous_commit = tuple[1]
|
||||||
print(list_update)
|
|
||||||
|
|
||||||
for update in list_update:
|
for update in list_update:
|
||||||
launch_update_version(update[0], update[1], current_version_path, is_fork)
|
launch_update_version(update[0], update[1], current_version_path, is_fork)
|
||||||
|
# Sucess
|
||||||
|
print('{}**************** AIL Sucessfully Updated *****************{}'.format(TERMINAL_YELLOW, TERMINAL_DEFAULT))
|
||||||
|
print()
|
||||||
|
sys.exit(0)
|
||||||
else:
|
else:
|
||||||
print(TERMINAL_RED+process.stderr.decode()+TERMINAL_DEFAULT)
|
print('{}{}{}'.format(TERMINAL_RED, process.stderr.decode(), TERMINAL_DEFAULT))
|
||||||
return None
|
aborting_update()
|
||||||
|
sys.exit(1)
|
||||||
else:
|
else:
|
||||||
print(TERMINAL_RED+process.stderr.decode()+TERMINAL_DEFAULT)
|
print('{}{}{}'.format(TERMINAL_RED, process.stderr.decode(), TERMINAL_DEFAULT))
|
||||||
return None
|
aborting_update()
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
def launch_update_version(version, roll_back_commit, current_version_path, is_fork):
|
def launch_update_version(version, roll_back_commit, current_version_path, is_fork):
|
||||||
update_path = os.path.join(os.environ['AIL_HOME'], 'update', version, 'Update.sh')
|
update_path = os.path.join(os.environ['AIL_HOME'], 'update', version, 'Update.sh')
|
||||||
print('------------------------------------------------------------------')
|
print()
|
||||||
print('- Launching Update: {} -'.format(version))
|
print('{}------------------------------------------------------------------'.format(TERMINAL_YELLOW))
|
||||||
print('------------------------------------------------------------------')
|
print('- Launching Update: {}{}{} -'.format(TERMINAL_BLUE, version, TERMINAL_YELLOW))
|
||||||
|
print('-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --{}'.format(TERMINAL_DEFAULT))
|
||||||
process = subprocess.run(['bash', update_path], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
process = subprocess.run(['bash', update_path], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
if process.returncode == 0:
|
if process.returncode == 0:
|
||||||
output = process.stdout
|
output = process.stdout.decode()
|
||||||
print(output)
|
print(output)
|
||||||
|
|
||||||
with open(current_version_path, 'w') as version_content:
|
with open(current_version_path, 'w') as version_content:
|
||||||
version_content.write(version)
|
version_content.write(version)
|
||||||
|
|
||||||
|
print('{}-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --'.format(TERMINAL_YELLOW))
|
||||||
|
print('- Sucessfully Updated: {}{}{} -'.format(TERMINAL_BLUE, version, TERMINAL_YELLOW))
|
||||||
|
print('------------------------------------------------------------------{}'.format(TERMINAL_DEFAULT))
|
||||||
|
print()
|
||||||
else:
|
else:
|
||||||
print(TERMINAL_RED+process.stderr.decode()+TERMINAL_DEFAULT)
|
print(process.stdout.decode())
|
||||||
|
print('{}{}{}'.format(TERMINAL_RED, process.stderr.decode(), TERMINAL_DEFAULT))
|
||||||
|
print('------------------------------------------------------------------')
|
||||||
|
print(' {}Update Error: {}{}{}'.format(TERMINAL_RED, TERMINAL_BLUE, version, TERMINAL_DEFAULT))
|
||||||
|
print('------------------------------------------------------------------')
|
||||||
if not is_fork:
|
if not is_fork:
|
||||||
roll_back_update(roll_back_commit)
|
roll_back_update(roll_back_commit)
|
||||||
|
else:
|
||||||
|
aborting_update()
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
def roll_back_update(roll_back_commit):
|
def roll_back_update(roll_back_commit):
|
||||||
|
print('Rolling back to safe commit: {}{}{}'.format(TERMINAL_BLUE ,roll_back_commit, TERMINAL_DEFAULT))
|
||||||
process = subprocess.run(['git', 'checkout', roll_back_commit], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
process = subprocess.run(['git', 'checkout', roll_back_commit], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
if process.returncode == 0:
|
if process.returncode == 0:
|
||||||
output = process.stdout
|
output = process.stdout
|
||||||
print(output)
|
print(output)
|
||||||
sys.exit()
|
sys.exit(0)
|
||||||
else:
|
else:
|
||||||
print(TERMINAL_RED+process.stderr.decode()+TERMINAL_DEFAULT)
|
print(TERMINAL_RED+process.stderr.decode()+TERMINAL_DEFAULT)
|
||||||
|
aborting_update()
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
'''
|
def aborting_update():
|
||||||
|
print()
|
||||||
if len(sys.argv) != 2:
|
print('{}Aborting ...{}'.format(TERMINAL_RED, TERMINAL_DEFAULT))
|
||||||
print('usage:', 'Update-conf.py', 'Automatic (boolean)')
|
print('{}******************************************************************'.format(TERMINAL_RED))
|
||||||
exit(1)
|
print('* AIL Not Updated *')
|
||||||
else:
|
print('******************************************************************{}'.format(TERMINAL_DEFAULT))
|
||||||
automatic = sys.argv[1]
|
print()
|
||||||
if automatic == 'True':
|
|
||||||
automatic = True
|
|
||||||
else:
|
|
||||||
automatic = False
|
|
||||||
|
|
||||||
|
|
||||||
if automatic:
|
|
||||||
resp = 'y'
|
|
||||||
else:
|
|
||||||
resp = input("Do you want to auto fix it? [y/n] ")
|
|
||||||
|
|
||||||
if resp != 'y':
|
|
||||||
return False
|
|
||||||
else:
|
|
||||||
if automatic:
|
|
||||||
resp2 = 'y'
|
|
||||||
else:
|
|
||||||
resp2 = input("Do you want to keep a backup of the old configuration file? [y/n] ")
|
|
||||||
'''
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
||||||
TERMINAL_RED = '\033[91m'
|
TERMINAL_RED = '\033[91m'
|
||||||
TERMINAL_YELLOW = '\33[93m'
|
TERMINAL_YELLOW = '\33[93m'
|
||||||
|
TERMINAL_BLUE = '\33[94m'
|
||||||
|
TERMINAL_BLINK = '\33[6m'
|
||||||
TERMINAL_DEFAULT = '\033[0m'
|
TERMINAL_DEFAULT = '\033[0m'
|
||||||
|
|
||||||
AIL_REPO = 'https://github.com/CIRCL/AIL-framework.git'
|
AIL_REPO = 'https://github.com/CIRCL/AIL-framework.git'
|
||||||
|
@ -260,9 +309,9 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
current_version_path = os.path.join(os.environ['AIL_HOME'], 'update/current_version')
|
current_version_path = os.path.join(os.environ['AIL_HOME'], 'update/current_version')
|
||||||
|
|
||||||
print('******************************************************************')
|
print('{}******************************************************************'.format(TERMINAL_YELLOW))
|
||||||
print('* Updating AIL ... *')
|
print('* Updating AIL ... *')
|
||||||
print('******************************************************************')
|
print('******************************************************************{}'.format(TERMINAL_DEFAULT))
|
||||||
|
|
||||||
if auto_update_enabled(cfg):
|
if auto_update_enabled(cfg):
|
||||||
if check_if_files_modified():
|
if check_if_files_modified():
|
||||||
|
@ -271,27 +320,27 @@ if __name__ == "__main__":
|
||||||
update_fork()
|
update_fork()
|
||||||
|
|
||||||
current_tag = get_git_current_tag(current_version_path)
|
current_tag = get_git_current_tag(current_version_path)
|
||||||
print('Current Version: {}'.format(current_tag))
|
|
||||||
print()
|
print()
|
||||||
list_upper_tags_remote = get_git_upper_tags_remote(current_tag[1:])
|
print('Current Version: {}{}{}'.format( TERMINAL_YELLOW, current_tag, TERMINAL_DEFAULT))
|
||||||
|
print()
|
||||||
|
list_upper_tags_remote = get_git_upper_tags_remote(current_tag[1:], is_fork)
|
||||||
# new realease
|
# new realease
|
||||||
if len(list_upper_tags_remote) > 1:
|
if len(list_upper_tags_remote) > 1:
|
||||||
print('New Releases:')
|
print('New Releases:')
|
||||||
for upper_tag in list_upper_tags_remote:
|
if is_fork:
|
||||||
print(' {}{}{}: {}'.format(TERMINAL_YELLOW, upper_tag[0], TERMINAL_DEFAULT, upper_tag[1]))
|
for upper_tag in list_upper_tags_remote:
|
||||||
|
print(' {}{}{}'.format(TERMINAL_BLUE, upper_tag[0], TERMINAL_DEFAULT))
|
||||||
|
else:
|
||||||
|
for upper_tag in list_upper_tags_remote:
|
||||||
|
print(' {}{}{}: {}'.format(TERMINAL_BLUE, upper_tag[0], TERMINAL_DEFAULT, upper_tag[1]))
|
||||||
print()
|
print()
|
||||||
update_ail(current_tag, list_upper_tags_remote, current_version_path, is_fork)
|
update_ail(current_tag, list_upper_tags_remote, current_version_path, is_fork)
|
||||||
#else:
|
|
||||||
# print('your fork is outdated')
|
|
||||||
else:
|
else:
|
||||||
print('please commit your change')
|
print('Please, commit your changes or stash them before you can update AIL')
|
||||||
|
aborting_update()
|
||||||
|
sys.exit(0)
|
||||||
else:
|
else:
|
||||||
print(' AIL Auto update is disabled')
|
print(' {}AIL Auto update is disabled{}'.format(TERMINAL_RED, TERMINAL_DEFAULT))
|
||||||
print(' AIL not Updated')
|
aborting_update()
|
||||||
print('******************************************************************')
|
sys.exit(0)
|
||||||
'''
|
|
||||||
if main():
|
|
||||||
sys.exit()
|
|
||||||
else:
|
|
||||||
sys.exit(1)
|
|
||||||
'''
|
|
||||||
|
|
Loading…
Reference in a new issue