Skip to content

Commit

Permalink
added documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
dianzrong committed Jun 19, 2023
1 parent b961eab commit ed26aad
Showing 1 changed file with 29 additions and 12 deletions.
41 changes: 29 additions & 12 deletions openadapt/start.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
"""
Implements the code needed to update the OpenAdapt app
if needed.
Usage:
python3 -m openadapt.start
"""

import subprocess

from openadapt.app.main import run_app


def changes_needed(result: str) -> bool:
""" Checks if git stash needs to be run.
"""Checks if git stash needs to be run.
Assumes result is the result of git status.
"""
if "Changes to be committed:" in result:
Expand All @@ -15,15 +24,23 @@ def changes_needed(result: str) -> bool:
return True
return False

result = subprocess.run(["git", "status"], capture_output=True, text=True)

if "branch is up to date" not in result.stdout:

if changes_needed(result.stdout):
subprocess.run(["git", "stash"])
print("Changes stashed")

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

if "branch is up to date" not in result.stdout:
if changes_needed(result.stdout):
subprocess.run(["git", "stash"])
print("Changes stashed")

subprocess.run(["git", "pull"])
print("Updated the OpenAdapt App")

run_app() # start gui


run_app() # start gui
if __name__ == "__main__":
start_openadapt_app()

0 comments on commit ed26aad

Please sign in to comment.