-
-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #201 from dianzrong/update
Implement Updating
- Loading branch information
Showing
2 changed files
with
35 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |