初始提交:造价审核系统源码(不含数据库与生成物)
This commit is contained in:
58
release_entry.py
Normal file
58
release_entry.py
Normal file
@@ -0,0 +1,58 @@
|
||||
"""Entry point for the portable Windows distribution."""
|
||||
import os
|
||||
import sqlite3
|
||||
import sys
|
||||
|
||||
|
||||
ROOT = os.path.dirname(os.path.abspath(sys.executable if getattr(sys, "frozen", False) else __file__))
|
||||
APP = os.path.join(ROOT, "造价审核", "app")
|
||||
for part in (APP, os.path.join(APP, "server"), os.path.join(APP, "core")):
|
||||
sys.path.insert(0, part)
|
||||
|
||||
# Explicit imports keep PyInstaller from omitting modules loaded by the launcher.
|
||||
import webview
|
||||
import api_server
|
||||
import shell
|
||||
|
||||
|
||||
def check():
|
||||
data = os.path.join(ROOT, "造价审核", "data")
|
||||
paths = (os.path.join(APP, "ui", "workbench.html"),
|
||||
os.path.join(APP, "store", "schema.sql"),
|
||||
os.path.join(data, "history.db"))
|
||||
for path in paths:
|
||||
if not os.path.isfile(path):
|
||||
raise FileNotFoundError(path)
|
||||
if not os.path.isdir(data):
|
||||
raise FileNotFoundError(data)
|
||||
probe = os.path.join(data, ".write_test")
|
||||
try:
|
||||
with open(probe, "w", encoding="ascii") as f:
|
||||
f.write("ok")
|
||||
os.remove(probe)
|
||||
except Exception as exc:
|
||||
raise OSError("Data directory is not writable: %s" % data) from exc
|
||||
db = sqlite3.connect("file:%s?mode=ro" % paths[-1].replace("\\", "/"), uri=True)
|
||||
try:
|
||||
count = db.execute("SELECT COUNT(*) FROM lmes").fetchone()[0]
|
||||
finally:
|
||||
db.close()
|
||||
print("Package OK; history LME records: %s" % count, flush=True)
|
||||
|
||||
|
||||
def main():
|
||||
if "--check" in sys.argv:
|
||||
check()
|
||||
return
|
||||
if "--serve" in sys.argv:
|
||||
api_server.run()
|
||||
return
|
||||
return shell.main()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
sys.exit(main())
|
||||
except Exception as exc:
|
||||
print("[ERROR] %s" % exc, file=sys.stderr, flush=True)
|
||||
sys.exit(1)
|
||||
Reference in New Issue
Block a user