Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions iottly_sdk/iottly.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from Queue import Queue, Full

import json
import logging

# Import the SDK version number
from .version import __version__
Expand All @@ -38,6 +39,16 @@
Msg = namedtuple('Msg', ['payload', 'type', 'channel'])


logger = logging.getLogger('iottly-sdk')
logger.setLevel(logging.ERROR)
sh = logging.StreamHandler()
sh.setLevel(logging.ERROR)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
sh.setFormatter(formatter)
logger.addHandler(sh)



class IottlySDK:
"""Class handling interactions with the iottly-agent

Expand Down Expand Up @@ -349,6 +360,13 @@ def _connect_to_agent(self):
s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
try:
s.connect(self._socket_path)

except PermissionError as e:
s.close()
s = None
logger.error("Permission denied, launch with proper permission")
return

except OSError as e:
if e.errno == errno.ECONNREFUSED:
s.close()
Expand Down