Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
theyosh committed Dec 8, 2018
1 parent a28cdb5 commit 2c6f9f2
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions terrariumWebcam.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,23 +555,19 @@ def rotate_image(self):

def get_raw_data(self):
logger.debug('Using Raspberry PI Cam device: %s' % (self.location,))
readok = False
stream = BytesIO()
camera = None

try:
cmd = 'ffmpeg -hide_banner -loglevel panic -i http://localhost:8090/{}/{}/stream.m3u8 -vframes 1 -f image2 -'.format(terrariumWebcamSource.TILE_LOCATION,
self.get_id())
cmd = shlex.split(cmd)
with subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) as proc:
out, err = proc.communicate()
self.raw_image = BytesIO(out)

proc = subprocess.Popen(cmd.split(' '), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = proc.communicate()
self.raw_image = BytesIO(out)
return True
except Exception as ex:
print(ex)
logger.exception('Error getting raw Raspberry PI Cam image from webcam \'%s\' with error message:' % (self.get_name(),))
logger.exception('Error getting raw Raspberry PI Cam image from webcam \'%s\' with error message: {}'.format(self.get_name(),ex))

print('Return false webcam')
return False

def get_type(self):
Expand Down

0 comments on commit 2c6f9f2

Please sign in to comment.