-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add status command and Docker HEALTHCHECK
- Loading branch information
Showing
5 changed files
with
114 additions
and
22 deletions.
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
**/.DS_Store | ||
**/__pycache__ | ||
**/.venv | ||
**/.classpath | ||
**/.env | ||
**/.envrc |
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
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
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
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,32 @@ | ||
import platform | ||
from pathlib import Path | ||
from typing import Dict | ||
import json | ||
|
||
|
||
def getStatusFilePath() -> Path: | ||
"""Determine the appropriate status file path based on the OS.""" | ||
if platform.system() == "Darwin": # macOS | ||
base_dir = Path.home() / "Library" / "Application Support" / "check-mate" | ||
else: # Linux and others | ||
base_dir = Path.home() / ".local" / "share" / "check-mate" | ||
|
||
base_dir.mkdir(parents=True, exist_ok=True) | ||
return base_dir / "status.json" | ||
|
||
|
||
STATUS_FILE = getStatusFilePath() | ||
|
||
|
||
def writeStatus(status: Dict[str, any]): | ||
"""Write the current status to the status file.""" | ||
with open(STATUS_FILE, "w") as f: | ||
json.dump(status, f) | ||
|
||
|
||
def readStatus() -> Dict[str, any]: | ||
"""Read the current status from the status file.""" | ||
if not STATUS_FILE.exists(): | ||
return {"status": "unknown"} | ||
with open(STATUS_FILE, "r") as f: | ||
return json.load(f) |