summaryrefslogtreecommitdiff
path: root/kvmd
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2018-11-06 01:55:13 +0300
committerDevaev Maxim <[email protected]>2018-11-06 01:55:13 +0300
commitf0ae427d8e4bbd82653abdb8e2aef8ffe32fc732 (patch)
tree44192d6bce4cc80db95532df2888e0764f63d58d /kvmd
parent1ac968e92411409413ed4555eed6c2944b38de0d (diff)
refactoring
Diffstat (limited to 'kvmd')
-rw-r--r--kvmd/__init__.py86
-rw-r--r--kvmd/apps/__init__.py (renamed from kvmd/extras/__init__.py)0
-rw-r--r--kvmd/apps/cleanup/__init__.py (renamed from kvmd/extras/cleanup/__init__.py)0
-rw-r--r--kvmd/apps/cleanup/__main__.py (renamed from kvmd/__main__.py)0
-rw-r--r--kvmd/apps/kvmd/__init__.py81
-rw-r--r--kvmd/apps/kvmd/__main__.py (renamed from kvmd/extras/cleanup/__main__.py)0
-rw-r--r--kvmd/apps/kvmd/atx.py (renamed from kvmd/atx.py)6
-rw-r--r--kvmd/apps/kvmd/hid.py (renamed from kvmd/hid.py)6
-rw-r--r--kvmd/apps/kvmd/msd.py (renamed from kvmd/msd.py)6
-rw-r--r--kvmd/apps/kvmd/server.py (renamed from kvmd/server.py)14
-rw-r--r--kvmd/apps/kvmd/streamer.py (renamed from kvmd/streamer.py)4
-rw-r--r--kvmd/apps/wscli/__init__.py (renamed from kvmd/extras/wscli/__init__.py)0
-rw-r--r--kvmd/apps/wscli/__main__.py (renamed from kvmd/extras/wscli/__main__.py)0
13 files changed, 99 insertions, 104 deletions
diff --git a/kvmd/__init__.py b/kvmd/__init__.py
index 5f308bba..84885136 100644
--- a/kvmd/__init__.py
+++ b/kvmd/__init__.py
@@ -1,85 +1 @@
-import asyncio
-
-from .application import init
-from .logging import get_logger
-from .logging import Log
-
-from .hid import Hid
-from .atx import Atx
-from .msd import MassStorageDevice
-from .streamer import Streamer
-from .server import Server
-
-from . import gpio
-
-
-# =====
-from .server import __version__ # noqa: F401
-
-
-# =====
-def main() -> None:
- config = init()
- with gpio.bcm():
- loop = asyncio.get_event_loop()
-
- log = Log(
- services=list(config["log"]["services"]),
- loop=loop,
- )
-
- hid = Hid(
- reset=int(config["hid"]["pinout"]["reset"]),
- device_path=str(config["hid"]["device"]),
- speed=int(config["hid"]["speed"]),
- reset_delay=float(config["hid"]["reset_delay"]),
- )
-
- atx = Atx(
- power_led=int(config["atx"]["pinout"]["power_led"]),
- hdd_led=int(config["atx"]["pinout"]["hdd_led"]),
- power_switch=int(config["atx"]["pinout"]["power_switch"]),
- reset_switch=int(config["atx"]["pinout"]["reset_switch"]),
- click_delay=float(config["atx"]["click_delay"]),
- long_click_delay=float(config["atx"]["long_click_delay"]),
- )
-
- msd = MassStorageDevice(
- target=int(config["msd"]["pinout"]["target"]),
- reset=int(config["msd"]["pinout"]["reset"]),
- device_path=str(config["msd"]["device"]),
- init_delay=float(config["msd"]["init_delay"]),
- reset_delay=float(config["msd"]["reset_delay"]),
- write_meta=bool(config["msd"]["write_meta"]),
- loop=loop,
- )
-
- streamer = Streamer(
- cap_power=int(config["streamer"]["pinout"]["cap"]),
- conv_power=int(config["streamer"]["pinout"]["conv"]),
- sync_delay=float(config["streamer"]["sync_delay"]),
- init_delay=float(config["streamer"]["init_delay"]),
- init_restart_after=float(config["streamer"]["init_restart_after"]),
- quality=int(config["streamer"]["quality"]),
- soft_fps=int(config["streamer"]["soft_fps"]),
- cmd=list(map(str, config["streamer"]["cmd"])),
- loop=loop,
- )
-
- Server(
- log=log,
- hid=hid,
- atx=atx,
- msd=msd,
- streamer=streamer,
- heartbeat=float(config["server"]["heartbeat"]),
- atx_state_poll=float(config["atx"]["state_poll"]),
- streamer_shutdown_delay=float(config["streamer"]["shutdown_delay"]),
- msd_chunk_size=int(config["msd"]["chunk_size"]),
- loop=loop,
- ).run(
- host=str(config["server"]["host"]),
- port=int(config["server"]["port"]),
- )
-
- get_logger().info("Bye-bye")
+__version__ = "0.86"
diff --git a/kvmd/extras/__init__.py b/kvmd/apps/__init__.py
index e69de29b..e69de29b 100644
--- a/kvmd/extras/__init__.py
+++ b/kvmd/apps/__init__.py
diff --git a/kvmd/extras/cleanup/__init__.py b/kvmd/apps/cleanup/__init__.py
index 60446c2b..60446c2b 100644
--- a/kvmd/extras/cleanup/__init__.py
+++ b/kvmd/apps/cleanup/__init__.py
diff --git a/kvmd/__main__.py b/kvmd/apps/cleanup/__main__.py
index 031df43e..031df43e 100644
--- a/kvmd/__main__.py
+++ b/kvmd/apps/cleanup/__main__.py
diff --git a/kvmd/apps/kvmd/__init__.py b/kvmd/apps/kvmd/__init__.py
new file mode 100644
index 00000000..b58b6df3
--- /dev/null
+++ b/kvmd/apps/kvmd/__init__.py
@@ -0,0 +1,81 @@
+import asyncio
+
+from ...application import init
+from ...logging import get_logger
+from ...logging import Log
+
+from ... import gpio
+
+from .hid import Hid
+from .atx import Atx
+from .msd import MassStorageDevice
+from .streamer import Streamer
+from .server import Server
+
+
+# =====
+def main() -> None:
+ config = init()
+ with gpio.bcm():
+ loop = asyncio.get_event_loop()
+
+ log = Log(
+ services=list(config["log"]["services"]),
+ loop=loop,
+ )
+
+ hid = Hid(
+ reset=int(config["hid"]["pinout"]["reset"]),
+ device_path=str(config["hid"]["device"]),
+ speed=int(config["hid"]["speed"]),
+ reset_delay=float(config["hid"]["reset_delay"]),
+ )
+
+ atx = Atx(
+ power_led=int(config["atx"]["pinout"]["power_led"]),
+ hdd_led=int(config["atx"]["pinout"]["hdd_led"]),
+ power_switch=int(config["atx"]["pinout"]["power_switch"]),
+ reset_switch=int(config["atx"]["pinout"]["reset_switch"]),
+ click_delay=float(config["atx"]["click_delay"]),
+ long_click_delay=float(config["atx"]["long_click_delay"]),
+ )
+
+ msd = MassStorageDevice(
+ target=int(config["msd"]["pinout"]["target"]),
+ reset=int(config["msd"]["pinout"]["reset"]),
+ device_path=str(config["msd"]["device"]),
+ init_delay=float(config["msd"]["init_delay"]),
+ reset_delay=float(config["msd"]["reset_delay"]),
+ write_meta=bool(config["msd"]["write_meta"]),
+ loop=loop,
+ )
+
+ streamer = Streamer(
+ cap_power=int(config["streamer"]["pinout"]["cap"]),
+ conv_power=int(config["streamer"]["pinout"]["conv"]),
+ sync_delay=float(config["streamer"]["sync_delay"]),
+ init_delay=float(config["streamer"]["init_delay"]),
+ init_restart_after=float(config["streamer"]["init_restart_after"]),
+ quality=int(config["streamer"]["quality"]),
+ soft_fps=int(config["streamer"]["soft_fps"]),
+ cmd=list(map(str, config["streamer"]["cmd"])),
+ loop=loop,
+ )
+
+ Server(
+ log=log,
+ hid=hid,
+ atx=atx,
+ msd=msd,
+ streamer=streamer,
+ heartbeat=float(config["server"]["heartbeat"]),
+ atx_state_poll=float(config["atx"]["state_poll"]),
+ streamer_shutdown_delay=float(config["streamer"]["shutdown_delay"]),
+ msd_chunk_size=int(config["msd"]["chunk_size"]),
+ loop=loop,
+ ).run(
+ host=str(config["server"]["host"]),
+ port=int(config["server"]["port"]),
+ )
+
+ get_logger().info("Bye-bye")
diff --git a/kvmd/extras/cleanup/__main__.py b/kvmd/apps/kvmd/__main__.py
index 031df43e..031df43e 100644
--- a/kvmd/extras/cleanup/__main__.py
+++ b/kvmd/apps/kvmd/__main__.py
diff --git a/kvmd/atx.py b/kvmd/apps/kvmd/atx.py
index 9ce97386..d49708e0 100644
--- a/kvmd/atx.py
+++ b/kvmd/apps/kvmd/atx.py
@@ -2,10 +2,10 @@ import asyncio
from typing import Dict
-from .logging import get_logger
+from ...logging import get_logger
-from . import aioregion
-from . import gpio
+from ... import aioregion
+from ... import gpio
# =====
diff --git a/kvmd/hid.py b/kvmd/apps/kvmd/hid.py
index 776e6f0e..d7eb47cf 100644
--- a/kvmd/hid.py
+++ b/kvmd/apps/kvmd/hid.py
@@ -14,14 +14,14 @@ import yaml
import serial
import setproctitle
-from . import gpio
+from ...logging import get_logger
-from .logging import get_logger
+from ... import gpio
# =====
def _get_keymap() -> Dict[str, int]:
- return yaml.load(pkgutil.get_data(__name__, "data/keymap.yaml").decode()) # type: ignore
+ return yaml.load(pkgutil.get_data("kvmd", "data/keymap.yaml").decode()) # type: ignore
_KEYMAP = _get_keymap()
diff --git a/kvmd/msd.py b/kvmd/apps/kvmd/msd.py
index 575f8ffb..2cdb9050 100644
--- a/kvmd/msd.py
+++ b/kvmd/apps/kvmd/msd.py
@@ -15,10 +15,10 @@ import pyudev
import aiofiles
import aiofiles.base
-from . import aioregion
-from . import gpio
+from ...logging import get_logger
-from .logging import get_logger
+from ... import aioregion
+from ... import gpio
# =====
diff --git a/kvmd/server.py b/kvmd/apps/kvmd/server.py
index 93e74fb1..8522cb16 100644
--- a/kvmd/server.py
+++ b/kvmd/apps/kvmd/server.py
@@ -13,7 +13,12 @@ from typing import Optional
import aiohttp.web
import setproctitle
-from .aioregion import RegionIsBusyError
+from ...logging import get_logger
+from ...logging import Log
+
+from ...aioregion import RegionIsBusyError
+
+from ... import __version__
from .hid import Hid
@@ -24,13 +29,6 @@ from .msd import MassStorageDevice
from .streamer import Streamer
-from .logging import get_logger
-from .logging import Log
-
-
-# =====
-__version__ = "0.86"
-
# =====
def _system_task(method: Callable) -> Callable:
diff --git a/kvmd/streamer.py b/kvmd/apps/kvmd/streamer.py
index e9cbf0e6..bfb77d28 100644
--- a/kvmd/streamer.py
+++ b/kvmd/apps/kvmd/streamer.py
@@ -6,9 +6,9 @@ from typing import List
from typing import Dict
from typing import Optional
-from .logging import get_logger
+from ...logging import get_logger
-from . import gpio
+from ... import gpio
# =====
diff --git a/kvmd/extras/wscli/__init__.py b/kvmd/apps/wscli/__init__.py
index 19d3181b..19d3181b 100644
--- a/kvmd/extras/wscli/__init__.py
+++ b/kvmd/apps/wscli/__init__.py
diff --git a/kvmd/extras/wscli/__main__.py b/kvmd/apps/wscli/__main__.py
index 031df43e..031df43e 100644
--- a/kvmd/extras/wscli/__main__.py
+++ b/kvmd/apps/wscli/__main__.py