-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a786670
commit bd3993d
Showing
9 changed files
with
134 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -125,4 +125,5 @@ docker/runLocal.sh | |
docker/cleanupUntagged.sh | ||
docker/cleanupExited.sh | ||
|
||
log/*.log | ||
log/*.log | ||
fixname.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +0,0 @@ | ||
""" | ||
LEGION (https://govanguard.com) | ||
Copyright (c) 2020 GoVanguard | ||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public | ||
License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later | ||
version. | ||
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied | ||
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||
details. | ||
You should have received a copy of the GNU General Public License along with this program. | ||
If not, see <http://www.gnu.org/licenses/>. | ||
Author(s): Dmitriy Dubson (d.dubson@gmail.com) | ||
""" | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
""" | ||
LEGION (https://govanguard.io) | ||
Copyright (c) 2019 GoVanguard | ||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public | ||
License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later | ||
version. | ||
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied | ||
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||
details. | ||
You should have received a copy of the GNU General Public License along with this program. | ||
If not, see <http://www.gnu.org/licenses/>. | ||
Author(s): Dmitriy Dubson (d.dubson@gmail.com) | ||
""" | ||
|
||
from PyQt5.QtCore import QSemaphore | ||
import time | ||
from random import randint | ||
|
||
from sqlalchemy import create_engine | ||
from sqlalchemy.orm import sessionmaker | ||
from sqlalchemy.orm.scoping import scoped_session | ||
|
||
from app.logging.legionLog import getDbLogger | ||
|
||
|
||
class Database: | ||
def __init__(self, user: str, passw: str, db: str, host='localhost', port=5432): | ||
from db.database import Base | ||
self.log = getDbLogger() | ||
self.base = Base | ||
try: | ||
self.establishSqliteConnection(user, passw. db. host, port) | ||
except Exception as e: | ||
self.log.error('Could not create SQLite database. Please try again.') | ||
self.log.info(e) | ||
|
||
def openDB(self, dbfilename): | ||
try: | ||
self.log.error('Not implemented for Postgres yet.') | ||
except: | ||
self.log.error('Could not open SQLite database file. Is the file corrupted?') | ||
|
||
def establishSqliteConnection(self, user: str, passw: str, db: str, host='localhost', port=5432): | ||
self.name = db | ||
self.port = port | ||
self.host = host | ||
self.user = user | ||
self.passw = passw | ||
self.dbsemaphore = QSemaphore(1) # to control concurrent write access to db | ||
url = 'postgresql://{}:{}@{}:{}/{}' | ||
url = url.format(user, password, host, port, db) | ||
# The return value of create_engine() is our connection object | ||
self.engine = sqlalchemy.create_engine( | ||
url, client_encoding='utf8') | ||
# We then bind the connection to MetaData() | ||
#meta = sqlalchemy.MetaData(bind=con, reflect=True) | ||
self.session = scoped_session(sessionmaker()) | ||
self.session.configure(bind=self.engine, autoflush=False) | ||
self.metadata = self.base.metadata | ||
self.metadata.create_all(self.engine) | ||
self.metadata.echo = True | ||
self.metadata.bind = self.engine | ||
self.log.info(f"Established SQLite connection on file '{dbFileName}'") | ||
|
||
def commit(self): | ||
self.dbsemaphore.acquire() | ||
self.log.debug("DB lock acquired") | ||
try: | ||
session = self.session() | ||
rnd = float(randint(1, 99)) / 100.00 | ||
self.log.debug("Waiting {0}s before commit...".format(str(rnd))) | ||
time.sleep(rnd) | ||
session.commit() | ||
except Exception as e: | ||
self.log.error("DB Commit issue") | ||
self.log.error(str(e)) | ||
try: | ||
rnd = float(randint(1, 99)) / 100.00 | ||
time.sleep(rnd) | ||
self.log.debug("Waiting {0}s before commit...".format(str(rnd))) | ||
session.commit() | ||
except Exception as e: | ||
self.log.error("DB Commit issue on retry") | ||
self.log.error(str(e)) | ||
pass | ||
self.dbsemaphore.release() | ||
self.log.debug("DB lock released") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/sh | ||
|
||
git filter-branch -f --env-filter ' | ||
OLD_NAME="sscottgvit" | ||
OLD_EMAIL="sscottgvit@govanguard.com" | ||
CORRECT_NAME="sscottgvit" | ||
CORRECT_EMAIL="sscott@govanguard.com" | ||
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ] | ||
then | ||
export GIT_COMMITTER_NAME="$CORRECT_NAME" | ||
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL" | ||
fi | ||
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ] | ||
then | ||
export GIT_AUTHOR_NAME="$CORRECT_NAME" | ||
export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL" | ||
fi | ||
if [ "$GIT_AUTHOR_NAME" = "$OLD_NAME" ] | ||
then | ||
export GIT_AUTHOR_NAME="$CORRECT_NAME" | ||
export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL" | ||
fi | ||
if [ "$GIT_COMMITTER_NAME" = "$OLD_NAME" ] | ||
then | ||
export GIT_COMMITTER_NAME="$CORRECT_NAME" | ||
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL" | ||
fi | ||
#if [ "$GIT_COMMITTER_NAME" != "$GIT_AUTHOR_NAME" ] | ||
#then | ||
# export GIT_AUTHOR_NAME="$GIT_COMMITTER_NAME" | ||
# export GIT_AUTHOR_EMAIL="$GIT_COMMITTER_EMAIL" | ||
#fi | ||
' --tag-name-filter cat -- --branches --tags | ||
|
||
git push --force --tags origin 'refs/heads/*' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1 @@ | ||
""" | ||
LEGION (https://govanguard.com) | ||
Copyright (c) 2020 GoVanguard | ||
|
||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public | ||
License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later | ||
version. | ||
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied | ||
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||
details. | ||
You should have received a copy of the GNU General Public License along with this program. | ||
If not, see <http://www.gnu.org/licenses/>. | ||
Author(s): Dmitriy Dubson (d.dubson@gmail.com) | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +0,0 @@ | ||
""" | ||
LEGION (https://govanguard.io) | ||
Copyright (c) 2019 GoVanguard | ||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public | ||
License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later | ||
version. | ||
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied | ||
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||
details. | ||
You should have received a copy of the GNU General Public License along with this program. | ||
If not, see <http://www.gnu.org/licenses/>. | ||
Author(s): Dmitriy Dubson (d.dubson@gmail.com) | ||
""" | ||