Exemple #1
0
def update_mounts():
    network_shares = config.get_network_shares()
    
    mounts = list_mounts()
    mounts = dict(((m['server'], m['share'], m['username'] or ''), False) for m in mounts)
    
    should_stop = False # indicates that motion should be stopped immediately
    should_start = True # indicates that motion can be started afterwards
    for network_share in network_shares:
        key = (network_share['server'], network_share['share'], network_share['username'] or '')
        if key in mounts: # found
            mounts[key] = True
        
        else: # needs to be mounted
            should_stop = True
            if not _mount(network_share['server'], network_share['share'], network_share['username'], network_share['password']):
                should_start = False
    
    # unmount the no longer necessary mounts
    for (server, share, username), required in mounts.items():
        if not required:
            _umount(server, share, username)
            should_stop = True
    
    return (should_stop, should_start)
Exemple #2
0
def update_mounts():
    network_shares = config.get_network_shares()

    mounts = list_mounts()
    mounts = dict(((m['server'], m['share'], m['username'] or ''), False)
                  for m in mounts)

    should_stop = False  # indicates that motion should be stopped immediately
    should_start = True  # indicates that motion can be started afterwards
    for network_share in network_shares:
        key = (network_share['server'], network_share['share'],
               network_share['username'] or '')
        if key in mounts:  # found
            mounts[key] = True

        else:  # needs to be mounted
            should_stop = True
            if not _mount(network_share['server'], network_share['share'],
                          network_share['username'],
                          network_share['password']):
                should_start = False

    # unmount the no longer necessary mounts
    for (server, share, username), required in mounts.items():
        if not required:
            _umount(server, share, username)
            should_stop = True

    return (should_stop, should_start)