Skip to content
This repository has been archived by the owner on Dec 2, 2019. It is now read-only.

Commit

Permalink
Merge pull request #1 from pschmitt/master
Browse files Browse the repository at this point in the history
Support user-defined key file path location
  • Loading branch information
TheRealLink authored Feb 3, 2017
2 parents 249c359 + 8b65d35 commit c1bb0eb
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions pylgtv/webos_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ def __init__(self, id, message):


class WebOsClient(object):
def __init__(self, ip):
def __init__(self, ip, key_file_path=None):
"""Initialize the client."""
self.ip = ip
self.port = 3000
self.key_file_path = key_file_path
self.client_key = None
self.web_socket = None
self.command_count = 0
Expand All @@ -41,7 +42,10 @@ def _get_key_file_path():
def load_key_file(self):
"""Try to load the client key for the current ip."""
self.client_key = None
key_file_path = self._get_key_file_path()
if self.key_file_path:
key_file_path = self.key_file_path
else:
key_file_path = self._get_key_file_path()
key_dict = {}

if os.path.isfile(key_file_path):
Expand All @@ -58,7 +62,10 @@ def save_key_file(self):
if self.client_key is None:
return

key_file_path = self._get_key_file_path()
if self.key_file_path:
key_file_path = self.key_file_path
else:
key_file_path = self._get_key_file_path()

with open(key_file_path, 'w+') as f:
raw_data = f.read()
Expand Down

0 comments on commit c1bb0eb

Please sign in to comment.