mirror of
https://github.com/ParisNeo/lollms-webui.git
synced 2024-12-19 20:37:51 +00:00
updated
This commit is contained in:
parent
ea66b5f30d
commit
6e7ec0ad8e
52
app.py
52
app.py
@ -94,7 +94,6 @@ except Exception as ex:
|
||||
trace_exception(ex)
|
||||
run_update_script()
|
||||
|
||||
|
||||
try:
|
||||
import mimetypes
|
||||
mimetypes.add_type('application/javascript', '.js')
|
||||
@ -102,6 +101,37 @@ try:
|
||||
except:
|
||||
ASCIIColors.yellow("Couldn't set mimetype")
|
||||
|
||||
def check_update_(branch_name="main"):
|
||||
try:
|
||||
# Open the repository
|
||||
repo_path = str(Path(__file__).parent)
|
||||
ASCIIColors.yellow(f"Checking for updates from {repo_path}")
|
||||
repo = git.Repo(repo_path)
|
||||
|
||||
# Fetch updates from the remote for the specified branch
|
||||
repo.remotes.origin.fetch(refspec=f"refs/heads/{branch_name}:refs/remotes/origin/{branch_name}")
|
||||
|
||||
# Compare the local and remote commit IDs for the specified branch
|
||||
local_commit = repo.head.commit
|
||||
remote_commit = repo.remotes.origin.refs[branch_name].commit
|
||||
|
||||
# Check if the local branch is behind the remote branch
|
||||
is_behind = repo.is_ancestor(local_commit, remote_commit)
|
||||
|
||||
ASCIIColors.yellow(f"update availability: {not is_behind}")
|
||||
|
||||
# Return True if the local branch is behind the remote branch
|
||||
return is_behind
|
||||
except Exception as e:
|
||||
# Handle any errors that may occur during the fetch process
|
||||
# trace_exception(e)
|
||||
return False
|
||||
|
||||
if check_update_():
|
||||
run_update_script()
|
||||
|
||||
|
||||
|
||||
|
||||
log = logging.getLogger('werkzeug')
|
||||
log.setLevel(logging.ERROR)
|
||||
@ -138,27 +168,7 @@ def get_ip_address():
|
||||
sock.close()
|
||||
|
||||
|
||||
def check_update_(branch_name="main"):
|
||||
try:
|
||||
# Open the repository
|
||||
repo_path = str(Path(__file__).parent)
|
||||
ASCIIColors.yellow(f"Checking for updates from {repo_path}")
|
||||
repo = git.Repo(repo_path)
|
||||
|
||||
# Fetch updates from the remote for the specified branch
|
||||
repo.remotes.origin.fetch(refspec=f"refs/heads/{branch_name}:refs/remotes/origin/{branch_name}")
|
||||
|
||||
# Compare the local and remote commit IDs for the specified branch
|
||||
local_commit = repo.head.commit
|
||||
remote_commit = repo.remotes.origin.refs[branch_name].commit
|
||||
|
||||
ASCIIColors.yellow(f"update availability: {local_commit != remote_commit}")
|
||||
# Return True if there are updates, False otherwise
|
||||
return local_commit != remote_commit
|
||||
except Exception as e:
|
||||
# Handle any errors that may occur during the fetch process
|
||||
# trace_exception(e)
|
||||
return False
|
||||
|
||||
|
||||
def run_restart_script(args):
|
||||
|
@ -4,14 +4,18 @@ import sys
|
||||
import git
|
||||
import subprocess
|
||||
import argparse
|
||||
from pathlib import Path
|
||||
|
||||
def run_git_pull():
|
||||
try:
|
||||
repo = git.Repo(".")
|
||||
print("----------------> Updating the code <-----------------------")
|
||||
repo = git.Repo(Path(__file__).parent)
|
||||
origin = repo.remotes.origin
|
||||
origin.pull()
|
||||
return True
|
||||
except git.GitCommandError as e:
|
||||
print(f"Error during git pull: {e}")
|
||||
return False
|
||||
|
||||
def install_requirements():
|
||||
try:
|
||||
|
Loading…
Reference in New Issue
Block a user