Skip to content

Commit

Permalink
refactored slac package name to pyslac (#26)
Browse files Browse the repository at this point in the history
* refactored slac package name to pyslac as 'slac' is not available to be used in pypi

* removed reference to switch pypi server

* refactored the tests

* removed unused env from README

* updated readme

* refactored a bit the README
  • Loading branch information
tropxy authored May 24, 2022
1 parent b380802 commit 23e41a8
Show file tree
Hide file tree
Showing 25 changed files with 75 additions and 76 deletions.
7 changes: 1 addition & 6 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,7 @@ jobs:
- name: Code Quality Check
shell: bash
run: |
poetry config http-basic.pypi-switch $PYPI_USER $PYPI_PASS
poetry update
poetry install
poetry run pytest tests
poetry run black --check --diff --line-length=88 slac tests
env:
TAG_VERSION: ${{ steps.context.outputs.TAG_VERSION }}
PYPI_USER: ${{ secrets.PYPI_USER }}
PYPI_PASS: ${{ secrets.PYPI_PASS }}
poetry run black --check --diff --line-length=88 pyslac tests
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed
- switched the package upload to public pypi server by @tropxy in https://github.com/SwitchEV/slac/pull/24
- refactored the package name to pyslac by @tropxy in https://github.com/SwitchEV/pyslac/pull/26

## [0.7.1] - 2022-04-28

Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ RUN poetry install --no-interaction --no-ansi
# Run the tests and linting for slac (as we are not using poetry venv, we are
# not running it with RUN poetry run pytest...)
RUN pytest -vv --cov-config .coveragerc --cov-report term-missing --durations=3 --cov=.
RUN flake8 --config .flake8 slac tests
RUN flake8 --config .flake8 pyslac tests


# Generate the wheel to be used by next stage
Expand All @@ -49,10 +49,10 @@ WORKDIR /usr/src/app
RUN python -m venv /venv

COPY --from=build /usr/src/app/dist/ dist/
COPY --from=build /usr/src/app/slac/examples/cs_configuration.json .
COPY --from=build /usr/src/app/pyslac/examples/cs_configuration.json .


# This will install the wheel in the venv
RUN /venv/bin/pip install dist/*.whl

CMD /venv/bin/python3 /venv/lib/python3.10/site-packages/slac/examples/single_slac_session.py
CMD /venv/bin/python3 /venv/lib/python3.10/site-packages/pyslac/examples/single_slac_session.py
20 changes: 10 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ help:
@echo " run-local runs the app locally with prod settings"
@echo " run-local-sudo runs the app locally using prod settings and root privileges"
@echo " poetry-update updates the dependencies in poetry.lock"
@echo " install-local installs slac into the current environment"
@echo " install-local installs pyslac into the current environment"
@echo " tests run all the tests"
@echo " reformat reformats the code, using Black"
@echo " flake8 flakes8 the code"
Expand Down Expand Up @@ -61,31 +61,31 @@ install-local:
pip install .

run-local-single:
python slac/examples/single_slac_session.py
python pyslac/examples/single_slac_session.py

run-local-multiple:
python slac/examples/multiple_slac_sessions.py
python pyslac/examples/multiple_slac_sessions.py

run-local-sudo-single:
sudo $(shell which python) slac/examples/single_slac_session.py
sudo $(shell which python) pyslac/examples/single_slac_session.py

run-local-sudo-multiple:
sudo $(shell which python) slac/examples/multiple_slac_sessions.py
sudo $(shell which python) pyslac/examples/multiple_slac_sessions.py

run-ev-slac:
sudo $(shell which python) slac/examples/ev_slac_scapy.py
sudo $(shell which python) pyslac/examples/ev_slac_scapy.py

mypy:
mypy --config-file mypy.ini slac tests
mypy --config-file mypy.ini pyslac tests

reformat:
isort slac tests && black --exclude --line-length=88 slac tests
isort pyslac tests && black --exclude --line-length=88 pyslac tests

black:
black --exclude --check --diff --line-length=88 slac tests
black --exclude --check --diff --line-length=88 pyslac tests

flake8:
flake8 --config .flake8 slac tests
flake8 --config .flake8 pyslac tests

code-quality: reformat mypy black flake8

Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ fails the attempt.
That task includes calls to two stub methods `notify_matching_ongoing` and
`notify_matching_failed`, which can be used by the end user to notify other services
of the current SLAC matching state ("ongoing" or "failed"). This can be useful
for the use case defined in ISO 15118-3, section 7, where different strategies need
for the use case defined in ISO 15118-3, section 7, where different strategies need to
be carried on, depending on if SLAC matching has started after or before EIM
authentication was completed.

Expand All @@ -114,7 +114,7 @@ brokers.

In that case, the user would have some external service monitoring the Control Pilot
state, which would send the state to the SLAC application. The Slac Handler would then
be waiting, listening for the Control Pilot state notification and on reception of it,
await, listening for the Control Pilot state notification and upon its reception,
would call the `process_cp_state`, which in its turn would spawn a matching process task.


Expand Down Expand Up @@ -154,7 +154,7 @@ The key-value pairs defined in the `.env` file directly affect the settings pres

Any of those variables can also be set by exporting their value in the env:

`$ export NETWORK_INTERFACE=eth1`
`$ export LOG_LEVEL=DEBUG`



Expand Down Expand Up @@ -183,8 +183,8 @@ To start the test, you may need root privileges and to start in the following
order:

```bash
$ sudo $(shell which python) slac/examples/single_slac_session.py
$ sudo $(shell which python) slac/examples/ev_slac_scapy.py
$ sudo $(shell which python) pyslac/examples/single_slac_session.py
$ sudo $(shell which python) pyslac/examples/ev_slac_scapy.py
```

This integration test was tested under:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tool.poetry]
name = "slac"
name = "pyslac"
version = "0.8.0"
description = "SLAC Protocol implementation, defined in ISO15118-3"
authors = ["André Duarte <andre@switch-ev.com, andre14x@gmail.com>"]
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion slac/environment.py → pyslac/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import environs

from slac.enums import Timers
from pyslac.enums import Timers

logger = logging.getLogger(__name__)

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
sendp,
)

from slac.enums import (
from pyslac.enums import (
CM_ATTEN_CHAR,
CM_ATTEN_PROFILE,
CM_MNBC_SOUND,
Expand All @@ -27,7 +27,7 @@
MMTYPE_RSP,
SLAC_SETTLE_TIME,
)
from slac.utils import get_if_hwaddr
from pyslac.utils import get_if_hwaddr

BROADCAST_ADDR = "FF:FF:FF:FF:FF:FF"
ATHEROS_CHIP_MAC = "00:b0:52:00:00:01"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from slac.utils import is_distro_linux
from pyslac.utils import is_distro_linux

if not is_distro_linux():
raise EnvironmentError("Non-Linux systems are not supported")
Expand All @@ -10,9 +10,9 @@
import os
from typing import List, Optional

from slac.environment import Config
from slac.session import SlacEvseSession, SlacSessionController
from slac.utils import wait_till_finished
from pyslac.environment import Config
from pyslac.session import SlacEvseSession, SlacSessionController
from pyslac.utils import wait_till_finished

logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__file__)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from slac.utils import is_distro_linux
from pyslac.utils import is_distro_linux

if not is_distro_linux():
raise EnvironmentError("Non-Linux systems are not supported")
Expand All @@ -9,9 +9,9 @@
import os
from typing import List, Optional

from slac.environment import Config
from slac.session import SlacEvseSession, SlacSessionController
from slac.utils import wait_till_finished
from pyslac.environment import Config
from pyslac.session import SlacEvseSession, SlacSessionController
from pyslac.utils import wait_till_finished

logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__file__)
Expand Down
2 changes: 1 addition & 1 deletion slac/layer_2_headers.py → pyslac/layer_2_headers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from dataclasses import dataclass

from slac.enums import ETH_TYPE_HPAV, HOMEPLUG_FMID, HOMEPLUG_FMSN, HOMEPLUG_MMV
from pyslac.enums import ETH_TYPE_HPAV, HOMEPLUG_FMID, HOMEPLUG_FMSN, HOMEPLUG_MMV


@dataclass
Expand Down
2 changes: 1 addition & 1 deletion slac/messages.py → pyslac/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from dataclasses import dataclass
from typing import List

from slac.enums import (
from pyslac.enums import (
BROADCAST_ADDR,
CM_SET_CCO_CAPAB,
CM_SET_KEY_MY_NONCE,
Expand Down
18 changes: 9 additions & 9 deletions slac/session.py → pyslac/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from os import urandom
from typing import List, Optional, Union

from slac.enums import (
from pyslac.enums import (
ATTEN_RESULTS_TIMEOUT,
CM_ATTEN_CHAR,
CM_ATTEN_PROFILE,
Expand Down Expand Up @@ -38,9 +38,9 @@

# This timeout is imported from the environment file, because it makes it
# easier to use it with the dev compose file for dev and debugging reasons
from slac.environment import Config
from slac.layer_2_headers import EthernetHeader, HomePlugHeader
from slac.messages import (
from pyslac.environment import Config
from pyslac.layer_2_headers import EthernetHeader, HomePlugHeader
from pyslac.messages import (
AtennChar,
AtennCharRsp,
AttenProfile,
Expand All @@ -53,15 +53,15 @@
SlacParmReq,
StartAtennChar,
)
from slac.sockets.async_linux_socket import (
from pyslac.sockets.async_linux_socket import (
create_socket,
readeth,
send_recv_eth,
sendeth,
)
from slac.utils import cancel_task, generate_nid, get_if_hwaddr
from slac.utils import half_round as hw
from slac.utils import task_callback, time_now_ms
from pyslac.utils import cancel_task, generate_nid, get_if_hwaddr
from pyslac.utils import half_round as hw
from pyslac.utils import task_callback, time_now_ms

logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger("slac_session")
Expand Down Expand Up @@ -294,7 +294,7 @@ async def evse_set_key(self) -> bytes:
The only secure way to remove a STA from an AVLN is to change the NMK
"""
logger.debug("CM_SET_KEY: Started...")
# for each new set_key message sent (or slac session),
# for each new set_key message sent (or pyslac session),
# a new pair of NID (Network ID) and NMK (Network Mask) shall be
# generated
nmk = urandom(16)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
from struct import pack
from typing import Optional

from slac.enums import BUFF_MAX_SIZE, Timers
from slac.sockets.enums import (
from pyslac.enums import BUFF_MAX_SIZE, Timers
from pyslac.sockets.enums import (
BPF_ABS,
BPF_H,
BPF_JEQ,
Expand All @@ -29,7 +29,7 @@
ETH_P_HPAV,
SO_ATTACH_FILTER,
)
from slac.utils import time_now_ms
from pyslac.utils import time_now_ms

logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger("async_linux_socket")
Expand Down
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import pytest

from slac.environment import Config
from slac.session import SlacEvseSession
from pyslac.environment import Config
from pyslac.session import SlacEvseSession

EVSE_ID = "DE*12*122333"
IFACE = "en0"
Expand All @@ -21,8 +21,8 @@ def evse_mac():

@pytest.fixture
def evse_slac_session(dummy_config, evse_mac):
with patch("slac.session.get_if_hwaddr", new=Mock(return_value=evse_mac)):
with patch("slac.session.create_socket", new=Mock()):
with patch("pyslac.session.get_if_hwaddr", new=Mock(return_value=evse_mac)):
with patch("pyslac.session.create_socket", new=Mock()):
evse_session = SlacEvseSession(EVSE_ID, IFACE, dummy_config)
evse_session.reset_socket = Mock()

Expand Down
4 changes: 2 additions & 2 deletions tests/test_slac_messages.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from slac.enums import (
from pyslac.enums import (
BROADCAST_ADDR,
CM_SET_CCO_CAPAB,
CM_SET_KEY_MY_NONCE,
Expand All @@ -14,7 +14,7 @@
SLAC_RESP_TYPE,
SLAC_SECURITY_TYPE,
)
from slac.messages import (
from pyslac.messages import (
AtennChar,
AtennCharRsp,
AttenProfile,
Expand Down
Loading

0 comments on commit 23e41a8

Please sign in to comment.