Skip to content

Commit

Permalink
Merge pull request #29 from epics-extensions/cleanup
Browse files Browse the repository at this point in the history
Some cleanup
  • Loading branch information
minijackson authored Oct 11, 2023
2 parents b27b87d + dcc4c92 commit 14b3f86
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 28 deletions.
2 changes: 1 addition & 1 deletion ioc/modules/devshell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ in {
# set to empty if unset
: "''${EPICS_COMPONENTS=}"
IFS=: read -ra components <<<$EPICS_COMPONENTS
IFS=: read -ra components <<<"$EPICS_COMPONENTS"
for component in "''${components[@]}"; do
echo "$component"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
import sys
"""A simple server mocking an ASCII communication."""

import sys

__version__ = '0.1.0'
__version__ = "0.1.0"


def log(*args, **kwargs):
def log(*args: str, **kwargs: str) -> None:
"""Print a message to stderr."""
print(*args, file=sys.stderr, **kwargs)


def send(*args, **kwargs):
print(*args, end='\r\n', flush=True, **kwargs)
def send(*args: str, **kwargs: str) -> None:
"""Send a message."""
print(*args, end="\r\n", flush=True, **kwargs)


def main():
log('received connection')
def main() -> None:
"""Start the mock server."""
log("received connection")

varfloat = 0.
varfloat = 0.0
scalc = ""

while True:
Expand All @@ -24,20 +28,23 @@ def main():
if not data:
break

log('received command:', data)

if data == 'FLOAT':
send('42.1234')
elif data == 'FLOAT_WITH_PREFIX':
send('VALUE: 69.1337')
elif data == 'ENUM':
send('TWO')
elif data.startswith('SET_VARFLOAT '):
varfloat = float(data.split(' ', maxsplit=1)[1])
elif data == 'GET_VARFLOAT':
log("received command:", data)

# TODO(minijackson): change that with a command-line parsing tool?

if data == "FLOAT":
send("42.1234")
elif data == "FLOAT_WITH_PREFIX":
send("VALUE: 69.1337")
elif data == "ENUM":
send("TWO")
elif data.startswith("SET_VARFLOAT "):
varfloat = float(data.split(" ", maxsplit=1)[1])
elif data == "GET_VARFLOAT":
send(str(varfloat))
elif data == "REGEX_TITLE":
send("""<!DOCTYPE html>
send(
"""<!DOCTYPE html>
<html>
<head>
<title>Hello, World!</title>
Expand All @@ -46,13 +53,14 @@ def main():
<p>Hello, World!</p>
</body>
</html>
""")
""",
)
elif data == "REGEX_SUB":
send("abcabcabcabc")
elif data.startswith('SET_SCALC '):
send('sent')
scalc = data.split(' ', maxsplit=1)[1]
elif data == 'GET_SCALC':
elif data.startswith("SET_SCALC "):
send("sent")
scalc = data.split(" ", maxsplit=1)[1]
elif data == "GET_SCALC":
send(scalc)
else:
log('unknown command')
log("unknown command")
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ mock_server = "mock_server:main"
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.ruff]
select = ["ALL"]
1 change: 0 additions & 1 deletion pkgs/epnix/support/calc/default.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
lib,
epnixLib,
mkEpicsPackage,
fetchFromGitHub,
Expand Down

0 comments on commit 14b3f86

Please sign in to comment.