summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEugene Triguba <eugenetriguba@gmail.com>2020-10-03 22:01:27 -0500
committerEugene Triguba <eugenetriguba@gmail.com>2020-10-03 22:01:27 -0500
commit27ff9a966cf17a483a0bcbd35d685eb195ebd3eb (patch)
treefad6be3c780526a75e3931dd32df9decf00077f9
parentRemove transitions (diff)
downloadlirc-27ff9a966cf17a483a0bcbd35d685eb195ebd3eb.zip
Fix default connection when running on Windows
An error is thrown because the unix socket was being created. It is now in an `if` check.
-rw-r--r--lirc/connection/default_connection.py19
1 files changed, 9 insertions, 10 deletions
diff --git a/lirc/connection/default_connection.py b/lirc/connection/default_connection.py
index e471fc7..04b8123 100644
--- a/lirc/connection/default_connection.py
+++ b/lirc/connection/default_connection.py
@@ -9,16 +9,15 @@ class DefaultConnection:
@property
def socket(self) -> stdlib_socket.socket:
- unix_socket = stdlib_socket.socket(
- stdlib_socket.AF_UNIX, stdlib_socket.SOCK_STREAM
- )
- tcp_socket = stdlib_socket.socket(
- stdlib_socket.AF_INET, stdlib_socket.SOCK_STREAM
- )
-
- return {"Linux": unix_socket, "Darwin": unix_socket, "Windows": tcp_socket}[
- self.__operating_system
- ]
+ if self.__operating_system == "Linux" or self.__operating_system == "Darwin":
+ return stdlib_socket.socket(
+ stdlib_socket.AF_UNIX, stdlib_socket.SOCK_STREAM
+ )
+
+ if self.__operating_system == "Windows":
+ return stdlib_socket.socket(
+ stdlib_socket.AF_INET, stdlib_socket.SOCK_STREAM
+ )
@property
def address(self) -> Union[str, Tuple[str, int]]: