Skip to content

Commit

Permalink
dbhandle: fix PEP686 fedora inconsistencies
Browse files Browse the repository at this point in the history
This patch fixes a bug causing inconsistency between platforms. On PyPI mysql-connector, a fetchall with nothing to return yields an empty iterator. However, Fedora's PEP686 mysql-connector throws mysql.connector.errors.InterfaceError, preventing ssvp-interval from running correctly. This is mitigated with this patch.

Signed-off-by: Amy Parker <amy@amyip.net>
  • Loading branch information
amyipdev committed Aug 14, 2023
1 parent 16ce02c commit 6ea44fa
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
19 changes: 18 additions & 1 deletion srv/dbhandle.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
# https://www.gnu.org/licenses/agpl-3.0.en.html.

import datetime

import psycopg2
import mysql.connector


def unimplemented():
Expand Down Expand Up @@ -187,6 +189,8 @@ def _hdr(self, srv: str, st: int, conn) -> int:
curr.fetchall()
except psycopg2.ProgrammingError:
pass
except mysql.connector.errors.InterfaceError:
pass
conn.commit()
curr.close()
conn.close()
Expand All @@ -202,6 +206,8 @@ def _iil(self, srv: str, status: int, conn) -> None:
curr.fetchall()
except psycopg2.ProgrammingError:
pass
except mysql.connector.errors.InterfaceError:
pass
conn.commit()
curr.close()
conn.close()
Expand All @@ -228,7 +234,12 @@ def _ucs(self, srv: str, st: int, conn) -> None:
currentStatus = %s\
where serverName = %s;"
curr.execute(self._treat_sql(sql), (srv, srv, srv, st, srv))
curr.fetchall()
try:
curr.fetchall()
except psycopg2.ProgrammingError:
pass
except mysql.connector.errors.InterfaceError:
pass
conn.commit()
curr.close()
conn.close()
Expand All @@ -243,6 +254,8 @@ def _ics(self, srv: str, conn) -> None:
curr.fetchall()
except psycopg2.ProgrammingError:
pass
except mysql.connector.errors.InterfaceError:
pass
conn.commit()
curr.close()
conn.close()
Expand Down Expand Up @@ -274,6 +287,8 @@ def _fev(self, lim: int, page: int, conn) -> list:
} for x in curr.fetchall()]
except psycopg2.ProgrammingError:
pass
except mysql.connector.errors.InterfaceError:
pass
curr.close()
conn.close()
return res
Expand All @@ -288,6 +303,8 @@ def _sev(self, conn) -> int:
res = curr.fetchone()[0]
except psycopg2.ProgrammingError:
pass
except mysql.connector.errors.InterfaceError:
pass
curr.close()
conn.close()
return res
1 change: 1 addition & 0 deletions ssvp.spec.fmt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Source0: %{name}-%{version}.tar.gz

BuildRequires: nodejs nodejs-npm make
Requires: bash python3 python3-gunicorn python3-mysqlclient python3-psycopg2 python3-pyOpenSSL python3-requests python3-flask jq
BuildArch: noarch

%description
SSVP - the Server Statistics Viewer Project
Expand Down

0 comments on commit 6ea44fa

Please sign in to comment.