gramps/aio/grampsaiow.py

43 lines
1.1 KiB
Python
Raw Normal View History

2023-06-10 18:43:28 +05:30
#!/usr/bin/env python3
2023-07-31 19:10:59 +05:30
"""
2023-06-10 18:43:28 +05:30
grampsw.exe
2023-07-31 19:10:59 +05:30
"""
2023-06-10 18:43:28 +05:30
import os
from os import environ
from os.path import join
import sys
import site
2023-07-31 19:10:59 +05:30
if getattr(sys, "frozen", False):
2023-06-10 18:43:28 +05:30
aio = os.path.dirname(sys.executable)
sys.path.insert(1, aio)
2023-07-31 19:10:59 +05:30
sys.path.insert(1, os.path.join(aio, "lib"))
2023-06-10 18:43:28 +05:30
sys.path.insert(1, site.getusersitepackages())
2023-07-31 19:10:59 +05:30
environ["SSL_CERT_FILE"] = join(aio, "ssl/certs/ca-bundle.trust.crt")
environ["GI_TYPELIB_PATH"] = join(aio, "lib/girepository-1.0")
environ["G_ENABLE_DIAGNOSTIC"] = "0"
environ["G_PARAM_DEPRECATED"] = "0"
environ["GRAMPS_RESOURCES"] = join(aio, "share")
environ["PATH"] = aio + ";" + aio + "\lib;" + environ["PATH"]
2023-06-10 18:43:28 +05:30
import atexit
import ctypes
2023-07-31 19:10:59 +05:30
2023-06-10 18:43:28 +05:30
def close():
2023-07-31 19:10:59 +05:30
"""Show warning dialog if Gramps is already running"""
sys.exit("Gramps is already running!")
2023-06-10 18:43:28 +05:30
HANDLE = ctypes.windll.kernel32.CreateMutexW(None, 1, "org.gramps-project.gramps")
ERROR = ctypes.GetLastError()
2023-07-31 19:10:59 +05:30
if ERROR == 183: # ERROR_ALREADY_EXISTS:
2023-06-10 18:43:28 +05:30
close()
atexit.register(ctypes.windll.kernel32.CloseHandle, HANDLE)
atexit.register(ctypes.windll.kernel32.ReleaseMutex, HANDLE)
import gramps.grampsapp as app
2023-07-31 19:10:59 +05:30
2023-06-10 18:43:28 +05:30
app.main()