# Path: extras/python/iotsaControl/consts.py
# class UserIntervention(Exception):
#     pass
# 
# class IotsaError(RuntimeError):
#     pass
# 
# class CoapError(Exception):
#     pass
# 
# VERBOSE=[]


from future import standard_library
from builtins import str
from builtins import object
from .consts import UserIntervention, IotsaError, CoapError, VERBOSE
import sys
import socket
import time
import urllib.parse
import urllib.request
import json as jsonmod
import coapthon.client.helperclient
import coapthon.defines
import requests
import urllib3
            codeName = coapthon.defines.Codes.LIST.get(reply.code, None)
            if codeName:
                codeName = codeName.name
            else:
                codeName = 'unknown'
            raise CoapError('%d.%02d %s' % (codeMajor, codeMinor, codeName))
            
    def get(self, endpoint, json=None):
        assert json is None
        endpoint = self.basePath+endpoint
        if VERBOSE: print('COAP GET coap://%s:%d%s' % (self.client.server[0], self.client.server[1], endpoint))
        rv = self.client.get(endpoint)
        self._raiseIfError(rv)
        if VERBOSE: print('COAP GET returned', rv.code, len(rv.payload), repr(rv.payload))
        return jsonmod.loads(rv.payload)
        
    def put(self, endpoint, json=None):
        assert json is not None
        endpoint = self.basePath+endpoint
        data = jsonmod.dumps(json)
        if VERBOSE: print('COAP PUT coap://%s:%d%s %s' % (self.client.server[0], self.client.server[1], endpoint, data))
        rv = self.client.put(endpoint, (coapthon.defines.Content_types['application/json'], data))
        self._raiseIfError(rv)
        if VERBOSE: print('COAP PUT returned', rv.code, repr(rv.payload))
        return jsonmod.loads(rv.payload)
        
    def post(self, endpoint, json=None, files=None):
        assert json is not None
        assert files is None
        endpoint = self.basePath+endpoint

# Path: extras/python/iotsaControl/consts.py
# class UserIntervention(Exception):
#     pass
# 
# class IotsaError(RuntimeError):
#     pass
# 
# class CoapError(Exception):
#     pass
# 
# VERBOSE=[]


# Path: extras/python/iotsaControl/protocols.py
from future import standard_library
from builtins import str
from builtins import object
from .consts import UserIntervention, IotsaError, CoapError, VERBOSE
import sys
import socket
import time
import urllib.parse
import urllib.request
import json as jsonmod
import coapthon.client.helperclient
import coapthon.defines
import requests
import urllib3

            codeName = coapthon.defines.Codes.LIST.get(reply.code, None)
            if codeName:
                codeName = codeName.name
            else:
                codeName = 'unknown'
            raise CoapError('%d.%02d %s' % (codeMajor, codeMinor, codeName))
            
    def get(self, endpoint, json=None):
        assert json is None
        endpoint = self.basePath+endpoint
        if VERBOSE: print('COAP GET coap://%s:%d%s' % (self.client.server[0], self.client.server[1], endpoint))
        rv = self.client.get(endpoint)
        self._raiseIfError(rv)
        if VERBOSE: print('COAP GET returned', rv.code, len(rv.payload), repr(rv.payload))
        return jsonmod.loads(rv.payload)
        
    def put(self, endpoint, json=None):
        assert json is not None
        endpoint = self.basePath+endpoint
        data = jsonmod.dumps(json)
        if VERBOSE: print('COAP PUT coap://%s:%d%s %s' % (self.client.server[0], self.client.server[1], endpoint, data))
        rv = self.client.put(endpoint, (coapthon.defines.Content_types['application/json'], data))
        self._raiseIfError(rv)
        if VERBOSE: print('COAP PUT returned', rv.code, repr(rv.payload))
        return jsonmod.loads(rv.payload)
        
    def post(self, endpoint, json=None, files=None):
        assert json is not None
        assert files is None
        endpoint = self.basePath+endpoint

        data = jsonmod.dumps(json)