You've already forked my-video-workflow
初次提交
This commit is contained in:
29
util/system.py
Normal file
29
util/system.py
Normal file
@ -0,0 +1,29 @@
|
||||
import os
|
||||
import platform
|
||||
import subprocess
|
||||
from typing import Union
|
||||
|
||||
|
||||
def check_exec(name: Union[os.PathLike[str], str]) -> bool:
|
||||
if is_windows():
|
||||
check_process = subprocess.Popen([
|
||||
"where.exe", name
|
||||
], stdout=subprocess.PIPE)
|
||||
check_process.wait()
|
||||
return len(check_process.stdout.readlines()) > 0
|
||||
elif is_linux():
|
||||
check_process = subprocess.Popen([
|
||||
"which", name
|
||||
])
|
||||
check_process.wait()
|
||||
return check_process.returncode == 0
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
def is_windows() -> bool:
|
||||
return platform.system().lower() == "windows"
|
||||
|
||||
|
||||
def is_linux() -> bool:
|
||||
return platform.system().lower() == "linux"
|
Reference in New Issue
Block a user