hotfix update system one more time
This commit is contained in:
@@ -161,7 +161,7 @@ def check_git_update(script_dir):
|
|||||||
else:
|
else:
|
||||||
git_update = {
|
git_update = {
|
||||||
"installed_ver": config.version,
|
"installed_ver": config.version,
|
||||||
"new_ver": check_git_version_remote(script_dir),
|
"new_ver": update.check_git_version_remote(script_dir),
|
||||||
}
|
}
|
||||||
|
|
||||||
return(json.dumps(git_update))
|
return(json.dumps(git_update))
|
||||||
@@ -173,11 +173,7 @@ def check_git_version(script_dir):
|
|||||||
return(git_version)
|
return(git_version)
|
||||||
|
|
||||||
|
|
||||||
def check_git_version_remote(script_dir):
|
|
||||||
full_cmd = "git -C {} ls-remote --tags origin | awk -F'/' '{{print $3}}' | sort -V | tail -n 1".format(script_dir)
|
|
||||||
result = subprocess.Popen(full_cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[0].decode("utf-8")
|
|
||||||
latest_tag = result.strip()
|
|
||||||
return latest_tag if latest_tag else None
|
|
||||||
|
|
||||||
def get_network_ip():
|
def get_network_ip():
|
||||||
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||||
@@ -477,7 +473,7 @@ def parse_arguments():
|
|||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
if args.update:
|
if args.update:
|
||||||
version = check_git_version_remote(script_dir).strip()
|
version = update.check_git_version_remote(script_dir).strip()
|
||||||
git_update = check_git_update(script_dir)
|
git_update = check_git_update(script_dir)
|
||||||
|
|
||||||
if git_update == 'on':
|
if git_update == 'on':
|
||||||
@@ -485,13 +481,13 @@ def parse_arguments():
|
|||||||
else:
|
else:
|
||||||
git_update = False
|
git_update = False
|
||||||
|
|
||||||
update.do_update(version, git_update)
|
update.do_update(script_dir, version, git_update)
|
||||||
|
|
||||||
exit()
|
exit()
|
||||||
|
|
||||||
if args.version:
|
if args.version:
|
||||||
installed_version = check_git_version(script_dir).strip()
|
installed_version = check_git_version(script_dir).strip()
|
||||||
latest_versino = check_git_version_remote(script_dir).strip()
|
latest_versino = update.check_git_version_remote(script_dir).strip()
|
||||||
print("Installed version: " + installed_version)
|
print("Installed version: " + installed_version)
|
||||||
print("Latest version: " + latest_versino)
|
print("Latest version: " + latest_versino)
|
||||||
if installed_version != latest_versino:
|
if installed_version != latest_versino:
|
||||||
@@ -560,15 +556,15 @@ def on_message(client, userdata, msg):
|
|||||||
global exit_flag
|
global exit_flag
|
||||||
print("Received message: ", msg.payload.decode())
|
print("Received message: ", msg.payload.decode())
|
||||||
if msg.payload.decode() == "install":
|
if msg.payload.decode() == "install":
|
||||||
version = check_git_version_remote(script_dir).strip()
|
version = update.check_git_version_remote(script_dir).strip()
|
||||||
update.do_update(version, git_update=True, config_update=True)
|
update.do_update(script_dir, version, git_update=True, config_update=True)
|
||||||
print("Update completed. Setting exit flag...")
|
print("Update completed. Setting exit flag...")
|
||||||
exit_flag = True
|
exit_flag = True
|
||||||
|
|
||||||
exit_flag = False
|
exit_flag = False
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
script_dir = os.path.dirname(os.path.realpath(__file__))
|
script_dir = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
if __name__ == '__main__':
|
||||||
|
|
||||||
args = parse_arguments();
|
args = parse_arguments();
|
||||||
|
|
||||||
if args.service:
|
if args.service:
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import os
|
|||||||
import subprocess
|
import subprocess
|
||||||
import config
|
import config
|
||||||
|
|
||||||
|
|
||||||
def get_assignments(filename):
|
def get_assignments(filename):
|
||||||
with open(filename) as f:
|
with open(filename) as f:
|
||||||
tree = ast.parse(f.read(), filename)
|
tree = ast.parse(f.read(), filename)
|
||||||
@@ -39,6 +38,13 @@ def display_config_differences(current_config, example_config, display=True):
|
|||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def check_git_version_remote(script_dir):
|
||||||
|
full_cmd = "git -C {} ls-remote --tags origin | awk -F'/' '{{print $3}}' | sort -V | tail -n 1".format(script_dir)
|
||||||
|
result = subprocess.Popen(full_cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[0].decode("utf-8")
|
||||||
|
latest_tag = result.strip()
|
||||||
|
return latest_tag if latest_tag else None
|
||||||
|
|
||||||
|
|
||||||
def update_config_version(version, script_dir):
|
def update_config_version(version, script_dir):
|
||||||
with open(script_dir + '/config.py', 'r') as f:
|
with open(script_dir + '/config.py', 'r') as f:
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
@@ -52,11 +58,10 @@ def update_config_version(version, script_dir):
|
|||||||
f.write(line)
|
f.write(line)
|
||||||
|
|
||||||
|
|
||||||
def do_update(version=config.version, git_update=True, config_update=True):
|
def do_update(script_dir, version=config.version, git_update=True, config_update=True):
|
||||||
script_dir = os.path.dirname(os.path.realpath(__file__))
|
|
||||||
print("Current version: {}".format(config.version))
|
print("Current version: {}".format(config.version))
|
||||||
if git_update:
|
if git_update:
|
||||||
print(":: Updating git repository")
|
print(":: Updating git repository", script_dir)
|
||||||
result = subprocess.run(['git', '-C', script_dir, 'pull'], check=True, universal_newlines=True, stdout=subprocess.PIPE)
|
result = subprocess.run(['git', '-C', script_dir, 'pull'], check=True, universal_newlines=True, stdout=subprocess.PIPE)
|
||||||
print(result.stdout)
|
print(result.stdout)
|
||||||
|
|
||||||
@@ -69,4 +74,5 @@ def do_update(version=config.version, git_update=True, config_update=True):
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
do_update()
|
script_dir = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
do_update(script_dir,check_git_version_remote(script_dir))
|
||||||
Reference in New Issue
Block a user