From 290efdbf16686826033017eb602ce22804ec5acc Mon Sep 17 00:00:00 2001 From: Calin Crisan Date: Sun, 30 Aug 2015 14:50:41 +0300 Subject: [PATCH] motion and ffmpeg are no longer required (the add camera dialog behaves accordingly) --- extra/motioneye.conf.sample | 2 +- motioneye/handlers.py | 4 ++-- motioneye/mediafiles.py | 2 +- motioneye/meyectl.py | 4 ++-- motioneye/motionctl.py | 2 +- motioneye/remote.py | 9 ++++++++- motioneye/server.py | 10 +++++++--- motioneye/static/js/main.js | 7 ++++--- motioneye/templates/main.html | 2 ++ 9 files changed, 28 insertions(+), 14 deletions(-) diff --git a/extra/motioneye.conf.sample b/extra/motioneye.conf.sample index 98b3b4d..56f4414 100644 --- a/extra/motioneye.conf.sample +++ b/extra/motioneye.conf.sample @@ -5,7 +5,7 @@ #static_url '/static/' # path to the configuration directory (must be writable by motionEye) -conf_path /etc/motioneye +#conf_path /etc/motioneye # path to the directory where pid files go (must be writable by motionEye) #run_path /var/run diff --git a/motioneye/handlers.py b/motioneye/handlers.py index 120d481..29393e5 100644 --- a/motioneye/handlers.py +++ b/motioneye/handlers.py @@ -158,7 +158,8 @@ class MainHandler(BaseHandler): hostname=socket.gethostname(), title=self.get_argument('title', None), admin_username=config.get_main().get('@admin_username'), - old_motion=config.is_old_motion()) + old_motion=config.is_old_motion(), + has_motion=bool(motionctl.find_motion())) class ConfigHandler(BaseHandler): @@ -491,7 +492,6 @@ class ConfigHandler(BaseHandler): self.finish_json({'error': error}) else: - cameras = [c for c in cameras if c.get('enabled')] self.finish_json({'cameras': cameras}) remote.list(self.get_data(), on_response) diff --git a/motioneye/mediafiles.py b/motioneye/mediafiles.py index c4f615e..88252b4 100644 --- a/motioneye/mediafiles.py +++ b/motioneye/mediafiles.py @@ -153,7 +153,7 @@ def _remove_older_files(dir, moment, exts): def find_ffmpeg(): try: - return subprocess.check_output('which ffmpeg', shell=True).strip() + return subprocess.check_output('which ffmpeg', stderr=open('/dev/null'), shell=True).strip() except subprocess.CalledProcessError: # not found return None diff --git a/motioneye/meyectl.py b/motioneye/meyectl.py index 98782cb..823b13f 100755 --- a/motioneye/meyectl.py +++ b/motioneye/meyectl.py @@ -117,10 +117,10 @@ def load_settings(): def configure_logging(cmd, log_to_file=False): if log_to_file or cmd != 'motioneye': - format = '%(asctime)s: [{cmd}] %(levelname)s: %(message)s'.format(cmd=cmd) + format = '%(asctime)s: [{cmd}] %(levelname)7s: %(message)s'.format(cmd=cmd) else: - format = '%(levelname)s: %(message)s'.format(cmd=cmd) + format = '%(levelname)7s: %(message)s'.format(cmd=cmd) for h in logging.getLogger().handlers: logging.getLogger().removeHandler(h) diff --git a/motioneye/motionctl.py b/motioneye/motionctl.py index df27ae6..1809eeb 100644 --- a/motioneye/motionctl.py +++ b/motioneye/motionctl.py @@ -52,7 +52,7 @@ def find_motion(): else: # autodetect motion binary path try: - binary = subprocess.check_output('which motion', shell=True).strip() + binary = subprocess.check_output('which motion', stderr=open('/dev/null'), shell=True).strip() except subprocess.CalledProcessError: # not found return None diff --git a/motioneye/remote.py b/motioneye/remote.py index a10599a..374e410 100644 --- a/motioneye/remote.py +++ b/motioneye/remote.py @@ -120,6 +120,12 @@ def list(local_config, callback): request = _make_request(scheme, host, port, username, password, uri + '/config/list/') def on_response(response): + def make_camera_response(c): + return { + 'id': c['id'], + 'name': c['name'] + } + if response.error: logging.error('failed to list remote cameras on %(url)s: %(msg)s' % { 'url': pretty_camera_url(local_config, camera=False), @@ -140,7 +146,8 @@ def list(local_config, callback): cameras = response['cameras'] # filter out simple mjpeg cameras - cameras = [c for c in cameras if c['proto'] != 'mjpeg'] + cameras = [make_camera_response(c) for c in cameras + if c['proto'] != 'mjpeg' and c.get('enabled')] callback(cameras) diff --git a/motioneye/server.py b/motioneye/server.py index 1e138d0..42696e2 100644 --- a/motioneye/server.py +++ b/motioneye/server.py @@ -276,7 +276,11 @@ def test_requirements(): sys.exit(-1) if not has_ffmpeg: - logging.info('ffmpeg not installed') + if has_motion: + logging.warn('you have motion installed, but no ffmpeg') + + else: + logging.info('ffmpeg not installed') if not has_motion: logging.info('motion not installed') @@ -350,10 +354,10 @@ def run(): import tornado.ioloop configure_signals() - test_requirements() - logging.info('hello! this is motionEye server %s' % motioneye.VERSION) + test_requirements() + if settings.SMB_SHARES: stop, start = smbctl.update_mounts() # @UnusedVariable diff --git a/motioneye/static/js/main.js b/motioneye/static/js/main.js index 1048701..ebaca5b 100644 --- a/motioneye/static/js/main.js +++ b/motioneye/static/js/main.js @@ -2672,8 +2672,8 @@ function runAddCameraDialog() { '' + 'Camera Type' + '' + @@ -2910,7 +2910,6 @@ function runAddCameraDialog() { urlEntry.change(updateUi); usernameEntry.change(updateUi); passwordEntry.change(updateUi); - updateUi(); runModalDialog({ title: 'Add Camera...', @@ -2972,6 +2971,8 @@ function runAddCameraDialog() { }); } }); + + updateUi(); } function runTimelapseDialog(cameraId, groupKey, group) { diff --git a/motioneye/templates/main.html b/motioneye/templates/main.html index 199e08f..393ab51 100644 --- a/motioneye/templates/main.html +++ b/motioneye/templates/main.html @@ -68,6 +68,8 @@ var adminUsername = '{{admin_username}}'; var frame = {% if frame %}true{% else %}false{% endif %}; var baseUri = null; + var hasLocalCamSupport = {% if has_motion %}true{% else %}false{% endif %}; + var hasNetCamSupport = {% if has_motion %}true{% else %}false{% endif %}; {% endblock %} -- 2.39.5