File tree Expand file tree Collapse file tree 4 files changed +27
-15
lines changed
Expand file tree Collapse file tree 4 files changed +27
-15
lines changed Original file line number Diff line number Diff line change @@ -17,10 +17,10 @@ jobs:
1717
1818 steps :
1919 - name : Checkout repository
20- uses : actions/checkout@v3
20+ uses : actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
2121
2222 - name : Set up Python
23- uses : actions/setup-python@v4
23+ uses : actions/setup-python@7f4fc3e22c37d6ff65e88745f38bd3157c663f7c # v4
2424 with :
2525 python-version : ' 3.10'
2626
Original file line number Diff line number Diff line change @@ -14,10 +14,10 @@ jobs:
1414
1515 steps :
1616 - name : Checkout repository
17- uses : actions/checkout@v3
17+ uses : actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
1818
1919 - name : Set up Python
20- uses : actions/setup-python@v4
20+ uses : actions/setup-python@7f4fc3e22c37d6ff65e88745f38bd3157c663f7c # v4
2121 with :
2222 python-version : " 3.10"
2323
Original file line number Diff line number Diff line change @@ -14,10 +14,10 @@ jobs:
1414
1515 steps :
1616 - name : Checkout repository
17- uses : actions/checkout@v3
17+ uses : actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
1818
1919 - name : Set up Python
20- uses : actions/setup-python@v4
20+ uses : actions/setup-python@7f4fc3e22c37d6ff65e88745f38bd3157c663f7c # v4
2121 with :
2222 python-version : " 3.10"
2323
Original file line number Diff line number Diff line change @@ -24,17 +24,29 @@ def _default_log_path() -> str:
2424
2525def _resolve_log_path () -> str :
2626 log_path = _default_log_path ()
27- log_dir = Path (log_path ).parent
28- try :
29- log_dir .mkdir (parents = True , exist_ok = True )
27+ if _ensure_writable_log_path (log_path ):
3028 return log_path
29+
30+ if platform .system () == "Darwin" :
31+ fallback_dir = Path .home () / "Library" / "Logs" / "whispr"
32+ else :
33+ fallback_dir = Path .home () / ".local" / "state" / "whispr"
34+ fallback_path = str (fallback_dir / "access.log" )
35+ if _ensure_writable_log_path (fallback_path ):
36+ return fallback_path
37+
38+ return str (Path .cwd () / "whispr_access.log" )
39+
40+
41+ def _ensure_writable_log_path (log_path : str ) -> bool :
42+ log_file = Path (log_path )
43+ try :
44+ log_file .parent .mkdir (parents = True , exist_ok = True )
45+ with log_file .open ("a" , encoding = "utf-8" ):
46+ pass
47+ return True
3148 except OSError :
32- if platform .system () == "Darwin" :
33- fallback_dir = Path .home () / "Library" / "Logs" / "whispr"
34- else :
35- fallback_dir = Path .home () / ".local" / "state" / "whispr"
36- fallback_dir .mkdir (parents = True , exist_ok = True )
37- return str (fallback_dir / "access.log" )
49+ return False
3850
3951
4052def setup_structlog () -> structlog .BoundLogger :
You can’t perform that action at this time.
0 commit comments