camera_ids = get_camera_ids()
cameras = [get_camera(camera_id) for camera_id in camera_ids]
- return [c for c in cameras if c.get('@enabled') and utils.local_motion_camera(c)]
+ return [c for c in cameras if c.get('@enabled') and utils.is_local_motion_camera(c)]
def get_network_shares():
'@network_username', '@network_password', '@storage_device',
'@upload_server', '@upload_username', '@upload_password'])
- if utils.local_motion_camera(camera_config):
+ if utils.is_local_motion_camera(camera_config):
# determine the enabled status
main_config = get_main()
threads = main_config.get('thread', [])
_set_default_motion_camera(camera_id, camera_config)
- elif utils.remote_camera(camera_config):
+ elif utils.is_remote_camera(camera_config):
pass
- elif utils.simple_mjpeg_camera(camera_config):
+ elif utils.is_simple_mjpeg_camera(camera_config):
_get_additional_config(camera_config, camera_id=camera_id)
_set_default_simple_mjpeg_camera(camera_id, camera_config)
camera_config = dict(camera_config)
- if utils.local_motion_camera(camera_config):
+ if utils.is_local_motion_camera(camera_config):
old_config_format = motionctl.has_old_config_format()
# adapt directives to old configuration, if needed
set_main(main_config)
_set_additional_config(camera_config, camera_id=camera_id)
- elif utils.remote_camera(camera_config):
+ elif utils.is_remote_camera(camera_config):
pass
- elif utils.simple_mjpeg_camera(camera_config):
+ elif utils.is_simple_mjpeg_camera(camera_config):
_set_additional_config(camera_config, camera_id=camera_id)
# read the actual configuration from file
camera_config['@proto'] = 'mjpeg'
camera_config['@url'] = device_details['url']
- if utils.local_motion_camera(camera_config):
+ if utils.is_local_motion_camera(camera_config):
_set_default_motion_camera(camera_id, camera_config)
# go through the config conversion functions back and forth once
camera_config = motion_camera_ui_to_dict(motion_camera_dict_to_ui(camera_config), camera_config)
- elif utils.simple_mjpeg_camera(camera_config):
+ elif utils.is_simple_mjpeg_camera(camera_config):
_set_default_simple_mjpeg_camera(camera_id, camera_config)
# go through the config conversion functions back and forth once
'on_picture_save': ''
}
- if utils.v4l2_camera(old_config):
+ if utils.is_v4l2_camera(old_config):
proto = 'v4l2'
else:
'sunday_from': '', 'sunday_to': ''
}
- if utils.net_camera(data):
+ if utils.is_net_camera(data):
ui['device_url'] = data['netcam_url']
ui['proto'] = 'netcam'
data.setdefault('@name', 'Camera' + str(camera_id))
data.setdefault('@id', camera_id)
- if not utils.net_camera(data):
+ if not utils.is_net_camera(data):
data.setdefault('videodevice', '/dev/video0')
data.setdefault('brightness', 0)
data.setdefault('contrast', 0)
raise HTTPError(404, 'no such camera')
local_config = config.get_camera(camera_id)
- if utils.local_motion_camera(local_config):
+ if utils.is_local_motion_camera(local_config):
ui_config = config.motion_camera_dict_to_ui(local_config)
self.finish_json(ui_config)
- elif utils.remote_camera(local_config):
+ elif utils.is_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.' % {
raise HTTPError(404, 'no such camera')
local_config = config.get_camera(camera_id)
- if utils.local_motion_camera(local_config):
+ if utils.is_local_motion_camera(local_config):
local_config = config.motion_camera_ui_to_dict(ui_config, local_config)
config.set_camera(camera_id, local_config)
on_finish(None, True) # (no error, motion needs restart)
- elif utils.remote_camera(local_config):
+ elif utils.is_remote_camera(local_config):
# update the camera locally
local_config['@enabled'] = ui_config['enabled']
config.set_camera(camera_id, local_config)
# reconfigure all local cameras to update the stream authentication options
for camera_id in config.get_camera_ids():
local_config = config.get_camera(camera_id)
- if not utils.local_motion_camera(local_config):
+ if not utils.is_local_motion_camera(local_config):
continue
ui_config = config.motion_camera_dict_to_ui(local_config)
raise
camera_config = config.get_camera(camera_id)
- if utils.v4l2_camera(camera_config):
+ if utils.is_v4l2_camera(camera_config):
device = camera_config['videodevice']
if 'brightness' in controls:
self.finish_json({})
- elif utils.remote_camera(camera_config):
+ elif utils.is_remote_camera(camera_config):
def on_response(error=None):
if error:
self.finish_json({'error': error})
configured_devices = set()
for camera_id in config.get_camera_ids():
data = config.get_camera(camera_id)
- if utils.v4l2_camera(data):
+ if utils.is_v4l2_camera(data):
configured_devices.add(data['videodevice'])
cameras = [{'id': d[1], 'name': d[2]} for d in v4l2ctl.list_devices()
if local_config is None:
continue
- if utils.local_motion_camera(local_config):
+ if utils.is_local_motion_camera(local_config):
ui_config = config.motion_camera_dict_to_ui(local_config)
cameras.append(ui_config)
check_finished()
- elif utils.remote_camera(local_config):
+ elif utils.is_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))
camera_config = config.add_camera(device_details)
- if utils.local_motion_camera(camera_config):
+ if utils.is_local_motion_camera(camera_config):
motionctl.stop()
if settings.SMB_SHARES:
self.finish_json(ui_config)
- elif utils.remote_camera(camera_config):
+ elif utils.is_remote_camera(camera_config):
def on_response(remote_ui_config=None, error=None):
if error:
return self.finish_json({'error': error})
def rem_camera(self, camera_id):
logging.debug('removing camera %(id)s' % {'id': camera_id})
- local = utils.local_motion_camera(config.get_camera(camera_id))
+ local = utils.is_local_motion_camera(config.get_camera(camera_id))
config.rem_camera(camera_id)
if local:
data = self.get_all_arguments()
camera_config = config.get_camera(camera_id)
- if utils.local_motion_camera(camera_config):
+ if utils.is_local_motion_camera(camera_config):
if what == 'upload_service':
service_name = data['service']
ConfigHandler._upload_service_test_info = (self, service_name)
else:
raise HTTPError(400, 'unknown test %s' % what)
- elif utils.remote_camera(camera_config):
+ elif utils.is_remote_camera(camera_config):
def on_response(result=None, error=None):
if result is True:
self.finish_json()
camera_id_str = str(camera_id)
camera_config = config.get_camera(camera_id)
- if utils.local_motion_camera(camera_config):
+ if utils.is_local_motion_camera(camera_config):
picture = mediafiles.get_current_picture(camera_config,
width=width,
height=height)
self.try_finish(picture)
- elif utils.remote_camera(camera_config):
+ elif utils.is_remote_camera(camera_config):
def on_response(motion_detected=False, capture_fps=None, monitor_info=None, picture=None, error=None):
if error:
return self.try_finish(None)
logging.debug('listing pictures for camera %(id)s' % {'id': camera_id})
camera_config = config.get_camera(camera_id)
- if utils.local_motion_camera(camera_config):
+ if utils.is_local_motion_camera(camera_config):
def on_media_list(media_list):
if media_list is None:
return self.finish_json({'error': 'Failed to get pictures list.'})
mediafiles.list_media(camera_config, media_type='picture',
callback=on_media_list, prefix=self.get_argument('prefix', None))
- elif utils.remote_camera(camera_config):
+ elif utils.is_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.' % {
def frame(self, camera_id):
camera_config = config.get_camera(camera_id)
- if utils.local_motion_camera(camera_config) or utils.simple_mjpeg_camera(camera_config) or self.get_argument('title', None) is not None:
+ if utils.is_local_motion_camera(camera_config) or utils.is_simple_mjpeg_camera(camera_config) or self.get_argument('title', None) is not None:
self.render('main.html',
frame=True,
camera_id=camera_id,
title=self.get_argument('title', camera_config.get('@name', '')),
admin_username=config.get_main().get('@admin_username'))
- elif utils.remote_camera(camera_config):
+ elif utils.is_remote_camera(camera_config):
def on_response(remote_ui_config=None, error=None):
if error:
return self.render('main.html',
'filename': filename, 'id': camera_id})
camera_config = config.get_camera(camera_id)
- if utils.local_motion_camera(camera_config):
+ if utils.is_local_motion_camera(camera_config):
content = mediafiles.get_media_content(camera_config, filename, 'picture')
pretty_filename = camera_config['@name'] + '_' + os.path.basename(filename)
self.finish(content)
- elif utils.remote_camera(camera_config):
+ elif utils.is_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.' % {
'filename': filename, 'id': camera_id})
camera_config = config.get_camera(camera_id)
- if utils.local_motion_camera(camera_config):
+ if utils.is_local_motion_camera(camera_config):
content = mediafiles.get_media_preview(camera_config, filename, 'picture',
width=self.get_argument('width', None),
height=self.get_argument('height', None))
self.finish(content)
- elif utils.remote_camera(camera_config):
+ elif utils.is_remote_camera(camera_config):
def on_response(content=None, error=None):
if content:
self.set_header('Content-Type', 'image/jpeg')
'filename': filename, 'id': camera_id})
camera_config = config.get_camera(camera_id)
- if utils.local_motion_camera(camera_config):
+ if utils.is_local_motion_camera(camera_config):
try:
mediafiles.del_media_content(camera_config, filename, 'picture')
self.finish_json()
except Exception as e:
self.finish_json({'error': unicode(e)})
- elif utils.remote_camera(camera_config):
+ elif utils.is_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.' % {
logging.debug('serving zip file for group "%(group)s" of camera %(id)s with key %(key)s' % {
'group': group or 'ungrouped', 'id': camera_id, 'key': key})
- if utils.local_motion_camera(camera_config):
+ if utils.is_local_motion_camera(camera_config):
data = mediafiles.get_prepared_cache(key)
if not data:
logging.error('prepared cache data for key "%s" does not exist' % key)
self.set_header('Content-Disposition', 'attachment; filename=' + pretty_filename + '.zip;')
self.finish(data)
- elif utils.remote_camera(camera_config):
+ elif utils.is_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.' % {
logging.debug('preparing zip file for group "%(group)s" of camera %(id)s' % {
'group': group or 'ungrouped', 'id': camera_id})
- if utils.local_motion_camera(camera_config):
+ if utils.is_local_motion_camera(camera_config):
def on_zip(data):
if data is None:
return self.finish_json({'error': 'Failed to create zip file.'})
mediafiles.get_zipped_content(camera_config, media_type='picture', group=group, callback=on_zip)
- elif utils.remote_camera(camera_config):
+ elif utils.is_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.' % {
logging.debug('serving timelapse movie for group "%(group)s" of camera %(id)s with key %(key)s' % {
'group': group or 'ungrouped', 'id': camera_id, 'key': key})
- if utils.local_motion_camera(camera_config):
+ if utils.is_local_motion_camera(camera_config):
data = mediafiles.get_prepared_cache(key)
if data is None:
logging.error('prepared cache data for key "%s" does not exist' % key)
self.set_header('Content-Disposition', 'attachment; filename=' + pretty_filename + ';')
self.finish(data)
- elif utils.remote_camera(camera_config):
+ elif utils.is_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.' % {
logging.debug('checking timelapse movie status for group "%(group)s" of camera %(id)s' % {
'group': group or 'ungrouped', 'id': camera_id})
- if utils.local_motion_camera(camera_config):
+ if utils.is_local_motion_camera(camera_config):
status = mediafiles.check_timelapse_movie()
if status['progress'] == -1 and status['data']:
key = mediafiles.set_prepared_cache(status['data'])
else:
self.finish_json(status)
- elif utils.remote_camera(camera_config):
+ elif utils.is_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.' % {
logging.debug('preparing timelapse movie for group "%(group)s" of camera %(id)s with rate %(framerate)s/%(int)s' % {
'group': group or 'ungrouped', 'id': camera_id, 'framerate': framerate, 'int': interval})
- if utils.local_motion_camera(camera_config):
+ if utils.is_local_motion_camera(camera_config):
status = mediafiles.check_timelapse_movie()
if status['progress'] != -1:
self.finish_json({'progress': status['progress']}) # timelapse already active
mediafiles.make_timelapse_movie(camera_config, framerate, interval, group=group)
self.finish_json({'progress': -1})
- elif utils.remote_camera(camera_config):
+ elif utils.is_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.' % {
'group': group or 'ungrouped', 'id': camera_id})
camera_config = config.get_camera(camera_id)
- if utils.local_motion_camera(camera_config):
+ if utils.is_local_motion_camera(camera_config):
try:
mediafiles.del_media_group(camera_config, group, 'picture')
self.finish_json()
except Exception as e:
self.finish_json({'error': unicode(e)})
- elif utils.remote_camera(camera_config):
+ elif utils.is_remote_camera(camera_config):
def on_response(response=None, error=None):
if error:
return self.finish_json({'error': 'Failed to delete picture group at %(url)s: %(msg)s.' % {
logging.debug('listing movies for camera %(id)s' % {'id': camera_id})
camera_config = config.get_camera(camera_id)
- if utils.local_motion_camera(camera_config):
+ if utils.is_local_motion_camera(camera_config):
def on_media_list(media_list):
if media_list is None:
return self.finish_json({'error': 'Failed to get movies list.'})
mediafiles.list_media(camera_config, media_type='movie',
callback=on_media_list, prefix=self.get_argument('prefix', None))
- elif utils.remote_camera(camera_config):
+ elif utils.is_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.' % {
'filename': filename, 'id': camera_id})
camera_config = config.get_camera(camera_id)
- if utils.local_motion_camera(camera_config):
+ if utils.is_local_motion_camera(camera_config):
content = mediafiles.get_media_content(camera_config, filename, 'movie')
pretty_filename = camera_config['@name'] + '_' + os.path.basename(filename)
self.finish(content)
- elif utils.remote_camera(camera_config):
+ elif utils.is_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.' % {
'filename': filename, 'id': camera_id})
camera_config = config.get_camera(camera_id)
- if utils.local_motion_camera(camera_config):
+ if utils.is_local_motion_camera(camera_config):
content = mediafiles.get_media_preview(camera_config, filename, 'movie',
width=self.get_argument('width', None),
height=self.get_argument('height', None))
self.finish(content)
- elif utils.remote_camera(camera_config):
+ elif utils.is_remote_camera(camera_config):
def on_response(content=None, error=None):
if content:
self.set_header('Content-Type', 'image/jpeg')
'filename': filename, 'id': camera_id})
camera_config = config.get_camera(camera_id)
- if utils.local_motion_camera(camera_config):
+ if utils.is_local_motion_camera(camera_config):
try:
mediafiles.del_media_content(camera_config, filename, 'movie')
self.finish_json()
except Exception as e:
self.finish_json({'error': unicode(e)})
- elif utils.remote_camera(camera_config):
+ elif utils.is_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.' % {
'group': group or 'ungrouped', 'id': camera_id})
camera_config = config.get_camera(camera_id)
- if utils.local_motion_camera(camera_config):
+ if utils.is_local_motion_camera(camera_config):
try:
mediafiles.del_media_group(camera_config, group, 'movie')
self.finish_json()
except Exception as e:
self.finish_json({'error': unicode(e)})
- elif utils.remote_camera(camera_config):
+ elif utils.is_remote_camera(camera_config):
def on_response(response=None, error=None):
if error:
return self.finish_json({'error': 'Failed to delete movie group at %(url)s: %(msg)s.' % {
raise HTTPError(404, 'no such camera')
local_config = config.get_camera(camera_id)
- if utils.remote_camera(local_config):
+ if utils.is_remote_camera(local_config):
def on_response(error=None):
if error:
return self.finish_json({'error': 'Failed to execute action on remote camera at %(url)s: %(msg)s.' % {
'event': event, 'id': thread_id, 'cid': camera_id})
camera_config = config.get_camera(camera_id)
- if not utils.local_motion_camera(camera_config):
+ if not utils.is_local_motion_camera(camera_config):
logging.warn('ignoring event for non-local camera with id %s' % camera_id)
return self.finish_json()