-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy path__init__.py
52 lines (38 loc) · 1.32 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
"""Starts the protonfix module and runs fixes after pre-flight-checks"""
import os
import sys
import traceback
from . import fix
from .logger import log
sys.path.insert(
0,
f'{os.path.dirname(os.path.realpath(__file__))}/_vendor', # noqa: PTH120
)
def check_conditions() -> bool:
"""Determine, if the actual game was executed and protonfixes isn't deactivated.
Returns:
bool: True, if the fix should be executed.
"""
return (
len(sys.argv) >= 1
and 'STEAM_COMPAT_DATA_PATH' in os.environ
and 'PROTONFIXES_DISABLE' not in os.environ
and 'waitforexitandrun' in sys.argv[1]
)
def check_iscriptevaluator() -> bool:
"""Determine, if we were invoked while running "iscriptevaluator.exe".
Returns:
bool: True, if we were invoked while running "iscriptevaluator.exe".
"""
return len(sys.argv) >= 3 and 'iscriptevaluator.exe' in sys.argv[2]
if check_iscriptevaluator():
log.debug('Skipping fix execution. We are running "iscriptevaluator.exe".')
elif not check_conditions():
log.warn('Skipping fix execution. We are probably running an unit test.')
else:
try:
fix.main()
# Catch any exceptions and print a traceback
except Exception:
sys.stderr.write('ProtonFixes ' + traceback.format_exc())
sys.stderr.flush()