-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathget_wfactions_path.py
36 lines (33 loc) · 1.27 KB
/
get_wfactions_path.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
import os
import platform
import subprocess
# Determine where WFActions.plist is
# Supported platforms: macOS, iOS, iSH on iOS
WFACTIONS = "WFActions.plist"
WFKIT_PATH = "/System/Library/PrivateFrameworks/WorkflowKit.framework"
OS_NAME = platform.system()
def get_path():
'''Return the path to WFActions.plist or exit the program depending on the platform.'''
if OS_NAME == "Darwin":
ios_wfactions_path = os.path.join(WFKIT_PATH, WFACTIONS)
if os.path.exists(ios_wfactions_path):
# Environment is iOS
return ios_wfactions_path
else:
# Environment is macOS
return os.path.join(WFKIT_PATH, "Resources", WFACTIONS)
elif OS_NAME == "Linux":
# Assume environment is iSH on iOS for now
mount_directory = "/mnt"
subprocess.run(["mount", "-t", "real", "/", mount_directory])
wfactions_path = os.path.join(mount_directory, WFKIT_PATH, WFACTIONS)
if os.path.exists(wfactions_path):
return wfactions_path
else:
# Linux but not iSH, so do not proceed
print("The only supported Linux environment for this script is iSH on iOS.")
quit()
else:
# Unsupported OS
print("This OS is not supported.")
quit()