-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bulk update to sync with local changes
- Loading branch information
1 parent
f18bf57
commit 28c526a
Showing
26 changed files
with
16,319 additions
and
532 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 |
---|---|---|
|
@@ -8,19 +8,21 @@ mkdir /teststat | |
cd <YOUR_DEV_ROOT> | ||
# Checkout the repository to TESTstat | ||
git clone https://github.com/bahadirbasaran/TESTstat.git | ||
git clone https://gitlab.ripe.net/rnd/teststat.git | ||
brew install [email protected] | ||
``` | ||
|
||
## Workflow for virtual environment | ||
``` | ||
# Create a virtualenv with the homebrew python | ||
python3 -m venv venv3 | ||
python3.9 -m venv venv | ||
# Activate the virtualenv | ||
source venv3/bin/activate | ||
source venv/bin/activate | ||
# Install the packages inside virtualenv | ||
pip install -r requirements.txt | ||
pip install -r requirements/gui.txt | ||
# Run the app | ||
python main.py | ||
|
@@ -39,10 +41,17 @@ brew install pyqt@5 | |
source teststat_venv/bin/activate | ||
# Install the packages inside virtualenv | ||
pip install -r requirements_M1.txt | ||
pip install -r requirements/gui_M1.txt | ||
# Run the app | ||
python main.py | ||
``` | ||
|
||
## Containerized workflow | ||
|
||
The GitLab Docker [build image](.gitlab/Dockerfile) installs a Python 3.9 virtual environment with all requirements and can be used locally. | ||
|
||
```sh | ||
docker build -t teststat -f .gitlab/Dockerfile . | ||
docker run -v "$(pwd)":/src -it teststat | ||
``` |
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 |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import socket | ||
|
||
|
||
class INRDBSocket: | ||
""" Generic socket wrapper to perform INRDB bulk queries """ | ||
|
||
def __init__(self,host,port): | ||
|
||
self.buffer = '' | ||
self.host = host | ||
self.port = int(port) | ||
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | ||
|
||
try: | ||
self.sock.connect((self.host, self.port)) | ||
except socket.error as error_msg: | ||
self.close_socket( | ||
f"Could not initialize the socket {self.host}:{self.port} - {error_msg}" | ||
) | ||
|
||
self.send_line("-k") | ||
ack = self.receive_line() | ||
if ack != "% This is RIPE NCC's Routing Information Service": | ||
self.close_socket(f"Connection handshake failed. Received: {ack}") | ||
else: | ||
last_line = ack | ||
current_line = self.receive_line() | ||
|
||
while last_line != '' and current_line != '': | ||
last_line = current_line | ||
current_line = self.receive_line() | ||
|
||
def send_line(self, msg): | ||
|
||
current_line = msg + '\n' | ||
total_sent = 0 | ||
while total_sent < len(current_line): | ||
sent = self.sock.send(current_line[total_sent:].encode('utf-8')) | ||
if sent == 0: | ||
self.close_socket(f"Socket connection broken: {self.host}:{self.port}") | ||
total_sent = total_sent + sent | ||
|
||
def receive_line(self): | ||
|
||
index = self.buffer.find("\n") | ||
if index == -1: | ||
# No new line, but potentially still some bytes in buffer | ||
# We still have data from previous call | ||
current_line = self.buffer | ||
new_line = False | ||
else: | ||
current_line = '' | ||
chunk = self.buffer | ||
new_line = True | ||
|
||
while not new_line: | ||
chunk = self.sock.recv(8192).decode("utf-8") | ||
|
||
if chunk == '': | ||
self.close_socket(f"Socket connection broken: {self.host}:{self.port}") | ||
index = chunk.find("\n") | ||
if index == -1: | ||
current_line += chunk | ||
else: | ||
new_line = True | ||
|
||
current_line += chunk[0:index] | ||
self.buffer = chunk[index+1:len(chunk)] | ||
|
||
return current_line | ||
|
||
def close_socket(self, raise_exception_with_msg=""): | ||
|
||
self.sock.shutdown(socket.SHUT_RDWR) | ||
self.sock.close() | ||
|
||
if raise_exception_with_msg: | ||
raise RuntimeError(raise_exception_with_msg) |
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
Oops, something went wrong.