Skip to content

Commit e4da504

Browse files
committed
move db_path into run_server function
1 parent cdbcfe1 commit e4da504

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ propcache~=0.4
4444
# via
4545
# aiohttp
4646
# yarl
47-
pyparsing~=3.3
47+
pyparsing~=3.2
4848
# via matplotlib
4949
python-dateutil==2.9.0.post0
5050
# via matplotlib

src/opengeodeweb_viewer/vtkw_server.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,6 @@ def initialize(self):
7878
self.registerVtkWebProtocol(publisher)
7979
self.setSharedObject("db", dict())
8080
self.setSharedObject("publisher", publisher)
81-
db_path = os.environ.get("DATABASE_PATH")
82-
if db_path:
83-
db_full_path = os.path.join(db_path, "project.db")
84-
connection.init_database(db_full_path)
8581

8682
# Custom API
8783
mesh_protocols = VtkMeshView()
@@ -149,9 +145,20 @@ def run_server(Server=_Server):
149145
if not args.database_path:
150146
args.database_path = args.data_folder_path
151147
os.environ["DATABASE_PATH"] = args.data_folder_path
148+
else:
149+
os.environ["DATABASE_PATH"] = args.database_path
150+
151+
db_path = os.environ.get("DATABASE_PATH")
152+
if db_path:
153+
db_full_path = os.path.join(db_path, "project.db")
154+
connection.init_database(db_full_path)
155+
print(f"Viewer database initialized at: {db_full_path}", flush=True)
156+
else:
157+
print("WARNING: No DATABASE_PATH set, database not initialized!", flush=True)
152158

153159
print(f"{args=}", flush=True)
154160
Server.configure(args)
161+
155162
server.start_webserver(options=args, protocol=Server)
156163

157164

0 commit comments

Comments
 (0)