mirror of
https://github.com/donaldzou/WGDashboard.git
synced 2024-11-22 07:10:09 +01:00
Update dashboard.py
Instead of catching one sql statement error, I moved the catch statement to `sqlSelect` to prevent all database error
This commit is contained in:
parent
204b995e6c
commit
bb0aba586b
@ -403,13 +403,9 @@ class PeerShareLinks:
|
|||||||
# print(self.Links)
|
# print(self.Links)
|
||||||
def __getSharedLinks(self):
|
def __getSharedLinks(self):
|
||||||
self.Links.clear()
|
self.Links.clear()
|
||||||
try:
|
allLinks = sqlSelect("SELECT * FROM PeerShareLinks WHERE ExpireDate IS NULL OR ExpireDate > datetime('now', 'localtime')").fetchall()
|
||||||
allLinks = sqlSelect("SELECT * FROM PeerShareLinks WHERE ExpireDate IS NULL OR ExpireDate > datetime('now', 'localtime')").fetchall()
|
for link in allLinks:
|
||||||
for link in allLinks:
|
self.Links.append(PeerShareLink(*link))
|
||||||
self.Links.append(PeerShareLink(*link))
|
|
||||||
# temo fix for https://github.com/donaldzou/WGDashboard/issues/432
|
|
||||||
except sqlite3.DatabaseError as e:
|
|
||||||
print(f"Database error occurred: {e}")
|
|
||||||
|
|
||||||
def getLink(self, Configuration: str, Peer: str) -> list[PeerShareLink]:
|
def getLink(self, Configuration: str, Peer: str) -> list[PeerShareLink]:
|
||||||
self.__getSharedLinks()
|
self.__getSharedLinks()
|
||||||
@ -1427,8 +1423,13 @@ cursor = sqldb.cursor()
|
|||||||
|
|
||||||
def sqlSelect(statement: str, paramters: tuple = ()) -> sqlite3.Cursor:
|
def sqlSelect(statement: str, paramters: tuple = ()) -> sqlite3.Cursor:
|
||||||
with sqldb:
|
with sqldb:
|
||||||
cursor = sqldb.cursor()
|
try:
|
||||||
return cursor.execute(statement, paramters)
|
cursor = sqldb.cursor()
|
||||||
|
return cursor.execute(statement, paramters)
|
||||||
|
# temo fix for https://github.com/donaldzou/WGDashboard/issues/432
|
||||||
|
except sqlite3.DatabaseError as e:
|
||||||
|
print(f"Database error occurred: {e}")
|
||||||
|
return []
|
||||||
|
|
||||||
def sqlUpdate(statement: str, paramters: tuple = ()) -> sqlite3.Cursor:
|
def sqlUpdate(statement: str, paramters: tuple = ()) -> sqlite3.Cursor:
|
||||||
with sqldb:
|
with sqldb:
|
||||||
|
Loading…
Reference in New Issue
Block a user