Skip to content

Commit

Permalink
appempt to fix looped problem in getattr
Browse files Browse the repository at this point in the history
  • Loading branch information
kdschlosser committed Feb 2, 2019
1 parent 197ae47 commit 24acd9c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 22 deletions.
14 changes: 2 additions & 12 deletions samsungctl/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,12 @@
from . import exceptions
from .remote_legacy import RemoteLegacy
from .remote_websocket import RemoteWebsocket
from .remote_encrypted import RemoteEncrypted
from .config import Config
from .key_mappings import KEYS
from .upnp import UPNPTV
from .upnp.discover import discover

try:
from .remote_encrypted import RemoteEncrypted
except ImportError:
RemoteEncrypted = None


class KeyWrapper(object):
def __init__(self, remote, key):
Expand All @@ -36,12 +32,6 @@ def __call__(cls, conf):
elif conf.method == "websocket":
remote = RemoteWebsocket
elif conf.method == "encrypted":
if RemoteEncrypted is None:
raise RuntimeError(
'Python 2 is not currently supported '
'for H and J model year TV\'s'
)

remote = RemoteEncrypted
else:
raise exceptions.ConfigUnknownMethod()
Expand All @@ -51,7 +41,7 @@ class RemoteWrapper(remote, UPNPTV):

def __init__(self, config):
self.__name__ = config.name

for name, key in KEYS.items():
self.__dict__[name] = KeyWrapper(self, key)

Expand Down
12 changes: 3 additions & 9 deletions samsungctl/upnp/UPNP_Device/upnp_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@


class UPNPObject(object):
ip_address = None
_devices = {}
_services = {}

def __init__(self, ip, locations, dump=''):
self.ip_address = ip

cls_name = None
self._devices = {}
self._services = {}
for location in locations:
Expand Down Expand Up @@ -116,13 +117,6 @@ def __init__(self, ip, locations, dump=''):
)
self._devices[device.__name__] = device

if cls_name is None:
cls_name = node.find('modelName')
if cls_name is not None and cls_name.text:
cls_name = cls_name.text.replace(' ', '_').replace('-', '')

self.__name__ = cls_name

def __getattr__(self, item):
if item in self.__dict__:
return self.__dict__[item]
Expand Down
6 changes: 6 additions & 0 deletions samsungctl/upnp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@


class UPNPTV(UPNPObject):
_dtv_information = None
_tv_options = None
name = None
ip_address = None
_connected = False
_locations = None

def __init__(self, ip, locations):
self._dtv_information = None
Expand Down
9 changes: 8 additions & 1 deletion samsungctl/websocket_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,14 @@

class WebSocketBase(object):
"""Base class for TV's with websocket connection."""

config = None
sock = None
_loop_event = None
_registered_callbacks = None
_starting = False
_running = None
_thread = None

@LogIt
def __init__(self, config):
"""
Expand Down

0 comments on commit 24acd9c

Please sign in to comment.