From c869532d0f4597be5b0d4134801166f93012990e Mon Sep 17 00:00:00 2001 From: Calin Crisan Date: Sat, 5 Jul 2014 20:56:05 +0300 Subject: [PATCH] smb mounts fixes --- motioneye.py | 4 ++-- src/config.py | 10 +--------- src/smbctl.py | 4 ++-- static/js/main.js | 2 +- 4 files changed, 6 insertions(+), 14 deletions(-) diff --git a/motioneye.py b/motioneye.py index c6d2a1e..0b13270 100755 --- a/motioneye.py +++ b/motioneye.py @@ -29,8 +29,6 @@ import settings sys.path.append(os.path.join(getattr(settings, 'PROJECT_PATH', os.path.dirname(sys.argv[0])), 'src')) -import smbctl - VERSION = '0.12' @@ -326,6 +324,8 @@ def _start_thumbnailer(): if __name__ == '__main__': cmd = _configure_settings() + import smbctl + if not _test_requirements(): sys.exit(-1) diff --git a/src/config.py b/src/config.py index ecfedc0..fd379fb 100644 --- a/src/config.py +++ b/src/config.py @@ -201,7 +201,7 @@ def get_network_shares(): mounts = [] for camera in cameras: - if camera['@storage_device'] != 'network-share': + if camera.get('@storage_device') != 'network-share': continue mounts.append({ @@ -338,14 +338,6 @@ def set_camera(camera_id, camera_config): set_main(main_config) - # try to create the target_dir - try: - os.makedirs(camera_config['target_dir']) - - except OSError as e: - if e.errno != errno.EEXIST: - logging.warn('failed to create target directory: %(msg)s' % {'msg': unicode(e)}) - # read the actual configuration from file config_file_path = os.path.join(settings.CONF_PATH, _CAMERA_CONFIG_FILE_NAME) % {'id': camera_id} if os.path.isfile(config_file_path): diff --git a/src/smbctl.py b/src/smbctl.py index 43a9787..8c1f729 100644 --- a/src/smbctl.py +++ b/src/smbctl.py @@ -187,9 +187,9 @@ def update_mounts(): should_start = False # unmount the no longer necessary mounts - for (network_share['server'], network_share['share'], network_share['username']), required in mounts.items(): + for (server, share, username), required in mounts.items(): if not required: - umount(network_share['server'], network_share['share'], network_share['username']) + umount(server, share, username) should_stop = True return (should_stop, should_start) diff --git a/static/js/main.js b/static/js/main.js index d94a8d6..9dd29cb 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -727,7 +727,7 @@ function dict2CameraUi(dict) { /* file storage */ $('#storageDeviceSelect').empty(); dict['available_disks'] = dict['available_disks'] || []; - var storageDeviceOptions = {}; + var storageDeviceOptions = {'network-share': true}; dict['available_disks'].forEach(function (disk) { disk.partitions.forEach(function (partition) { var target = partition.target.replaceAll('/', '-'); -- 2.39.5