Skip to content

Commit

Permalink
Merge pull request #201 from dianzrong/update
Browse files Browse the repository at this point in the history
Implement Updating
  • Loading branch information
abrichr authored Jun 25, 2023
2 parents 495a280 + a87e202 commit 27b89b7
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
3 changes: 2 additions & 1 deletion openadapt/app/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from openadapt.app.main import run_app

run_app()
if __name__ == "__main__":
run_app()
33 changes: 33 additions & 0 deletions openadapt/start.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""
Implements the code needed to update the OpenAdapt app if needed.
Usage:
python3 -m openadapt.start
"""
from loguru import logger
import subprocess

from openadapt.app.main import run_app


def main() -> None:
"""
The main function which runs the OpenAdapt app when it is updated.
"""
result = subprocess.run(["git", "status"], capture_output=True, text=True)

if "unmerged" in result.stdout:
logger.info("Please fix merge conflicts and try again")
return

subprocess.run(["git", "stash"])

if "git pull" in result.stdout:
subprocess.run(["git", "pull", "-q"])
logger.info("Updated the OpenAdapt App")

run_app() # start gui


if __name__ == "__main__":
main()

0 comments on commit 27b89b7

Please sign in to comment.