Updated lib to not display debug when there is no error

fetchIP
E. Almqvist 4 years ago
parent c434aae77e
commit 31553db02e
  1. 17
      hue_controller.py
  2. 8
      hue_remote.py

@ -20,15 +20,11 @@ class APIrequest:
async def get( dest: str="", payload: str="" ):
try:
apiReq = req.get( genUrl(dest), data = payload )
return apiReq
except req.exceptions.RequestException as err:
print(err)
if( apiReq.status_code != 200 ): # print out the error if the status code is not 200
print(apiReq)
print(apiReq.text)
# POST Req
async def post( dest: str="", payload: str="" ):
try:
apiReq = req.post( genUrl(params), data = payload )
return apiReq
except req.exceptions.RequestException as err:
@ -38,8 +34,11 @@ class APIrequest:
async def put( dest: str="", payload: str="" ):
try:
apiReq = req.put( genUrl(dest), data = payload ) # send the payload
print(apiReq)
print(apiReq.text)
if( apiReq.status_code != 200 ):
print(apiReq)
print(apiReq.text)
return apiReq
except req.exceptions.RequestException as err:

@ -29,6 +29,8 @@ boolConvert = {
"off": False
}
# this is the most spaghetti-ish code I have ever written but it works
def parseCommand( cmd:list, pos:int, i=-1 ):
index = int(i)
try:
@ -83,9 +85,9 @@ def parseCommand( cmd:list, pos:int, i=-1 ):
help() # display the help page if parameters are missing (it will give out an IndexError)
def parseCommandline(): # this is the most spaghetti code I have ever written but it works and I do not intend to fix
def parseCommandline():
cmd = sys.argv
print(cmd)
if( len(cmd) > 1 ):
if( cmd[1] == "light" ):
parseCommand( cmd, 3, cmd[2] )
@ -101,4 +103,4 @@ def init():
parseCommandline()
hue.controller.end() # also to end it
init()
init() # actually call the init function

Loading…
Cancel
Save