self.finish_json(ui_config)
- else: # remote camera
+ elif utils.remote_camera(local_config):
def on_response(remote_ui_config=None, error=None):
if error:
return self.finish_json({'error': 'Failed to get remote camera configuration for %(url)s: %(msg)s.' % {
self.finish_json(remote_ui_config)
remote.get_config(local_config, on_response)
+
+ else: # assuming simple mjpeg camera
+ pass # TODO implement me
else:
logging.debug('getting main config')
on_finish(None, True) # (no error, motion needs restart)
- else: # remote camera
+ elif utils.remote_camera(local_config):
# update the camera locally
local_config['@enabled'] = ui_config['enabled']
config.set_camera(camera_id, local_config)
# and no useful fields (such as "name"),
# the camera was probably disabled due to errors
on_finish(None, False)
+
+ else: # assuming simple mjpeg camera
+ pass # TODO implement me
def set_main_config(ui_config):
logging.debug('setting main config...')
cameras.append(ui_config)
check_finished()
- else: # remote camera
+ elif utils.remote_camera(local_config):
if local_config.get('@enabled') or self.get_argument('force', None) == 'true':
remote.get_config(local_config, on_response_builder(camera_id, local_config))
else: # don't try to reach the remote of the camera is disabled
on_response_builder(camera_id, local_config)(error=True)
+
+ else: # assuming simple mjpeg camera
+ pass # TODO implement me
if length[0] == 0:
self.finish_json({'cameras': []})
raise
- camera_id, camera_config = config.add_camera(device_details)
- camera_config['@id'] = camera_id
+ camera_config = config.add_camera(device_details)
if utils.local_motion_camera(camera_config):
motionctl.stop()
self.finish_json(ui_config)
- else: # remote camera
+ elif utils.remote_camera(camera_config):
def on_response(remote_ui_config=None, error=None):
if error:
return self.finish_json({'error': error})
self.finish_json(remote_ui_config)
remote.get_config(camera_config, on_response)
+
+ else: # assuming simple mjpeg camera
+ #ui_config = config.camera_dict_to_ui(camera_config)
+ # TODO use a special mjpeg function to generate ui_config
+ self.finish_json(ui_config)
@BaseHandler.auth(admin=True)
def rem_camera(self, camera_id):
return self.finish_json()
if not utils.local_motion_camera(camera_config):
- logging.warn('ignoring event for remote camera with id %s' % camera_id)
+ logging.warn('ignoring event for non-local camera with id %s' % camera_id)
return self.finish_json()
if event == 'start':
self.set_cookie('motion_detected_' + str(camera_id), str(motionctl.is_motion_detected(camera_id)).lower())
self.try_finish(picture)
- else: # remote camera
+ elif utils.remote_camera(camera_config):
def on_response(motion_detected=False, picture=None, error=None):
if sequence and picture:
mediafiles.set_picture_cache(camera_id, sequence, width, picture)
self.try_finish(picture)
remote.get_current_picture(camera_config, width=width, height=height, callback=on_response)
+
+ else: # assuming simple mjpeg camera
+ raise HTTPError(400, 'unknown operation')
+
@BaseHandler.auth()
def list(self, camera_id):
mediafiles.list_media(camera_config, media_type='picture',
callback=on_media_list, prefix=self.get_argument('prefix', None))
- else: # remote camera
+ elif utils.remote_camera(camera_config):
def on_response(remote_list=None, error=None):
if error:
return self.finish_json({'error': 'Failed to get picture list for %(url)s: %(msg)s.' % {
remote.list_media(camera_config, media_type='picture', prefix=self.get_argument('prefix', None), callback=on_response)
+ else: # assuming simple mjpeg camera
+ raise HTTPError(400, 'unknown operation')
+
def frame(self, camera_id):
camera_config = config.get_camera(camera_id)
title=self.get_argument('title', camera_config.get('@name', '')),
admin_username=config.get_main().get('@admin_username'))
- else: # remote camera, we need to fetch remote config
+ elif utils.remote_camera(camera_config):
def on_response(remote_ui_config=None, error=None):
if error:
return self.render('main.html',
admin_username=config.get_main().get('@admin_username'))
remote.get_config(camera_config, on_response)
-
+
+ else: # assuming simple mjpeg camera
+ pass # TODO implement me
@BaseHandler.auth()
def download(self, camera_id, filename):
self.finish(content)
- else: # remote camera
+ elif utils.remote_camera(camera_config):
def on_response(response=None, error=None):
if error:
return self.finish_json({'error': 'Failed to download picture from %(url)s: %(msg)s.' % {
remote.get_media_content(camera_config, filename=filename, media_type='picture', callback=on_response)
+ else: # assuming simple mjpeg camera
+ raise HTTPError(400, 'unknown operation')
+
@BaseHandler.auth()
def preview(self, camera_id, filename):
logging.debug('previewing picture %(filename)s of camera %(id)s' % {
self.finish(content)
- else:
+ elif utils.remote_camera(camera_config):
def on_response(content=None, error=None):
if content:
self.set_header('Content-Type', 'image/jpeg')
width=self.get_argument('width', None),
height=self.get_argument('height', None),
callback=on_response)
+
+ else: # assuming simple mjpeg camera
+ raise HTTPError(400, 'unknown operation')
@BaseHandler.auth(admin=True)
def delete(self, camera_id, filename):
except Exception as e:
self.finish_json({'error': unicode(e)})
- else: # remote camera
+ elif utils.remote_camera(camera_config):
def on_response(response=None, error=None):
if error:
return self.finish_json({'error': 'Failed to delete picture from %(url)s: %(msg)s.' % {
remote.del_media_content(camera_config, filename=filename, media_type='picture', callback=on_response)
+ else: # assuming simple mjpeg camera
+ raise HTTPError(400, 'unknown operation')
+
@BaseHandler.auth()
def zipped(self, camera_id, group):
key = self.get_argument('key', None)
logging.error('prepared cache data for key "%s" does not exist' % key)
raise HTTPError(404, 'no such key')
-
- camera_config = config.get_camera(camera_id)
- if utils.local_motion_camera(camera_config):
- pretty_filename = camera_config['@name'] + '_' + group
- pretty_filename = re.sub('[^a-zA-Z0-9]', '_', pretty_filename)
+
+ pretty_filename = camera_config['@name'] + '_' + group
+ pretty_filename = re.sub('[^a-zA-Z0-9]', '_', pretty_filename)
- else: # remote camera
- pretty_filename = re.sub('[^a-zA-Z0-9]', '_', group)
-
self.set_header('Content-Type', 'application/zip')
self.set_header('Content-Disposition', 'attachment; filename=' + pretty_filename + '.zip;')
self.finish(data)
- else: # remote camera
+ elif utils.remote_camera(camera_config):
def on_response(response=None, error=None):
if error:
return self.finish_json({'error': 'Failed to download zip file from %(url)s: %(msg)s.' % {
remote.get_zipped_content(camera_config, media_type='picture', key=key, group=group, callback=on_response)
+ else: # assuming simple mjpeg camera
+ raise HTTPError(400, 'unknown operation')
+
else: # prepare
logging.debug('preparing zip file for group %(group)s of camera %(id)s' % {
'group': group, 'id': camera_id})
mediafiles.get_zipped_content(camera_config, media_type='picture', group=group, callback=on_zip)
- else: # remote camera
+ elif utils.remote_camera(camera_config):
def on_response(response=None, error=None):
if error:
return self.finish_json({'error': 'Failed to make zip file at %(url)s: %(msg)s.' % {
remote.make_zipped_content(camera_config, media_type='picture', group=group, callback=on_response)
+ else: # assuming simple mjpeg camera
+ raise HTTPError(400, 'unknown operation')
+
@BaseHandler.auth()
def timelapse(self, camera_id, group):
key = self.get_argument('key', None)
raise HTTPError(404, 'no such key')
- camera_config = config.get_camera(camera_id)
- if utils.local_motion_camera(camera_config):
- pretty_filename = camera_config['@name'] + '_' + group
- pretty_filename = re.sub('[^a-zA-Z0-9]', '_', pretty_filename)
+ pretty_filename = camera_config['@name'] + '_' + group
+ pretty_filename = re.sub('[^a-zA-Z0-9]', '_', pretty_filename)
- else: # remote camera
- pretty_filename = re.sub('[^a-zA-Z0-9]', '_', group)
-
self.set_header('Content-Type', 'video/x-msvideo')
self.set_header('Content-Disposition', 'attachment; filename=' + pretty_filename + '.avi;')
self.finish(data)
- else: # remote camera
+ elif utils.remote_camera(camera_config):
def on_response(response=None, error=None):
if error:
return self.finish_json({'error': 'Failed to download timelapse movie from %(url)s: %(msg)s.' % {
remote.get_timelapse_movie(camera_config, key, group=group, callback=on_response)
+ else: # assuming simple mjpeg camera
+ raise HTTPError(400, 'unknown operation')
+
elif check:
logging.debug('checking timelapse movie status for group %(group)s of camera %(id)s' % {
'group': group, 'id': camera_id})
else:
self.finish_json(status)
- else: # remote camera
+ elif utils.remote_camera(camera_config):
def on_response(response=None, error=None):
if error:
return self.finish_json({'error': 'Failed to check timelapse movie progress at %(url)s: %(msg)s.' % {
remote.check_timelapse_movie(camera_config, group=group, callback=on_response)
+ else: # assuming simple mjpeg camera
+ raise HTTPError(400, 'unknown operation')
+
else: # start timelapse
interval = int(self.get_argument('interval'))
framerate = int(self.get_argument('framerate'))
mediafiles.make_timelapse_movie(camera_config, framerate, interval, group=group)
self.finish_json({'progress': -1})
- else: # remote camera
+ elif utils.remote_camera(camera_config):
def on_status(response=None, error=None):
if error:
return self.finish_json({'error': 'Failed to make timelapse movie at %(url)s: %(msg)s.' % {
remote.check_timelapse_movie(camera_config, group=group, callback=on_status)
+ else: # assuming simple mjpeg camera
+ raise HTTPError(400, 'unknown operation')
@BaseHandler.auth(admin=True)
def delete_all(self, camera_id, group):
except Exception as e:
self.finish_json({'error': unicode(e)})
- else: # remote camera
+ elif utils.remote_camera(camera_config):
def on_response(response=None, error=None):
if error:
return self.finish_json({'error': 'Failed to delete picture group from %(url)s: %(msg)s.' % {
remote.del_media_group(camera_config, group=group, media_type='picture', callback=on_response)
+ else: # assuming simple mjpeg camera
+ raise HTTPError(400, 'unknown operation')
+
def try_finish(self, content):
try:
self.finish(content)
mediafiles.list_media(camera_config, media_type='movie',
callback=on_media_list, prefix=self.get_argument('prefix', None))
- else:
+ elif utils.remote_camera(camera_config):
def on_response(remote_list=None, error=None):
if error:
return self.finish_json({'error': 'Failed to get movie list for %(url)s: %(msg)s.' % {
self.finish_json(remote_list)
remote.list_media(camera_config, media_type='movie', prefix=self.get_argument('prefix', None), callback=on_response)
-
+
+ else: # assuming simple mjpeg camera
+ raise HTTPError(400, 'unknown operation')
+
@BaseHandler.auth()
def download(self, camera_id, filename):
logging.debug('downloading movie %(filename)s of camera %(id)s' % {
self.finish(content)
- else:
+ elif utils.remote_camera(camera_config):
def on_response(response=None, error=None):
if error:
return self.finish_json({'error': 'Failed to download movie from %(url)s: %(msg)s.' % {
remote.get_media_content(camera_config, filename=filename, media_type='movie', callback=on_response)
+ else: # assuming simple mjpeg camera
+ raise HTTPError(400, 'unknown operation')
+
@BaseHandler.auth()
def preview(self, camera_id, filename):
logging.debug('previewing movie %(filename)s of camera %(id)s' % {
self.finish(content)
- else:
+ elif utils.remote_camera(camera_config):
def on_response(content=None, error=None):
if content:
self.set_header('Content-Type', 'image/jpeg')
height=self.get_argument('height', None),
callback=on_response)
+ else: # assuming simple mjpeg camera
+ raise HTTPError(400, 'unknown operation')
+
@BaseHandler.auth(admin=True)
def delete(self, camera_id, filename):
logging.debug('deleting movie %(filename)s of camera %(id)s' % {
except Exception as e:
self.finish_json({'error': unicode(e)})
- else: # remote camera
+ elif utils.remote_camera(camera_config):
def on_response(response=None, error=None):
if error:
return self.finish_json({'error': 'Failed to delete movie from %(url)s: %(msg)s.' % {
remote.del_media_content(camera_config, filename=filename, media_type='movie', callback=on_response)
+ else: # assuming simple mjpeg camera
+ raise HTTPError(400, 'unknown operation')
+
@BaseHandler.auth(admin=True)
def delete_all(self, camera_id, group):
logging.debug('deleting movie group %(group)s of camera %(id)s' % {
except Exception as e:
self.finish_json({'error': unicode(e)})
- else: # remote camera
+ elif utils.remote_camera(camera_config):
def on_response(response=None, error=None):
if error:
return self.finish_json({'error': 'Failed to delete movie group from %(url)s: %(msg)s.' % {
remote.del_media_group(camera_config, group=group, media_type='movie', callback=on_response)
+ else: # assuming simple mjpeg camera
+ raise HTTPError(400, 'unknown operation')
+
class LogHandler(BaseHandler):
LOGS = {