Skip to content

Commit

Permalink
Update GoProCamera.py
Browse files Browse the repository at this point in the history
modified infoCamera function to return parsed data 
#an error is raised in take_photo if no value is returned
  • Loading branch information
cedricbellec authored Dec 8, 2017
1 parent 88e0dc1 commit aa7055a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion goprocam/GoProCamera.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ def infoCamera(self, option=""):
info=urllib.request.urlopen('http://10.5.5.9/gp/gpControl', timeout=5)
data = info.read()
encoding = info.info().get_content_charset('utf-8')

parse_read = json.loads(data.decode(encoding))
parsed_info = ""
if option == "":
Expand All @@ -250,6 +251,7 @@ def infoCamera(self, option=""):
data = info.read()
parsed=re.sub(r'\W+', '', str(data))
print(parsed)
return parsed #an error is raised in take_photo if no value is returned
except (HTTPError, URLError) as error:
return ""
print("Error code:" + str(error.code) + "\nMake sure the connection to the WiFi camera is still active.")
Expand All @@ -262,6 +264,7 @@ def infoCamera(self, option=""):
data = info.read()
parsed=re.sub(r'\W+', '', str(data))
print(parsed)
return parsed #an error is raised in take_photo if no value is returned
except (HTTPError, URLError) as error:
return ""
print("Error code:" + str(error.code) + "\nMake sure the connection to the WiFi camera is still active.")
Expand Down Expand Up @@ -1035,4 +1038,4 @@ def overview(self):
print("current timelapse interval: " + self.parse_value(constants.Hero3Status.TimeLapseInterval,self.getStatus(constants.Hero3Status.TimeLapseInterval)))
print("current video Fov: " + self.parse_value(constants.Hero3Status.FOV,self.getStatus(constants.Hero3Status.FOV)))
print("status lights: " + self.parse_value(constants.Hero3Status.LED,self.getStatus(constants.Hero3Status.LED)))
print("recording: " + self.parse_value(constants.Hero3Status.IsRecording,self.getStatus(constants.Hero3Status.IsRecording)))
print("recording: " + self.parse_value(constants.Hero3Status.IsRecording,self.getStatus(constants.Hero3Status.IsRecording)))

0 comments on commit aa7055a

Please sign in to comment.