offline-minecraft-launcher/oml/modules/generic.py
2024-06-05 13:14:19 +02:00

38 lines
808 B
Python

global readJsonFile
def readJsonFile(file):
fileh = open(file,"r",encoding="utf-8")
data = fileh.read()
fileh.close()
return json.loads(data)
global whereis
def whereis(cmd):
if lv["osName"] != "windows":
if (
os.path.isfile(cmd) and
os.access(cmd,os.X_OK)
): return cmd
else:
if (
os.path.isfile(cmd)
): return cmd
paths = os.environ["PATH"].split(os.pathsep)
if lv["osName"] == "windows":
pathexts = os.environ["PATHEXT"].split(os.pathsep)
for path in paths:
ffile = os.path.join(path,cmd)
if lv["osName"] == "windows":
for pathext in pathexts:
if (
os.path.isfile(ffile + pathext)
): return ffile + pathext
else:
if (
os.path.isfile(ffile) and
os.access(ffile,os.X_OK)
): return ffile
return None