Beispiel #1
0
def channel_notify_save(channel_id):
    from .models import Channel

    logger.info(
        "Notifying save to channel with id {0}"
        .format(channel_id)
    )

    try:
        channel = Channel.objects.get(pk=channel_id)

        sck = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)

        sck.connect(LS_SOCKET_BASE_CHANNEL_PATH.format(channel.pk))

        sck.send(LSTN_CMD_NOTIFY_SAVE.encode(encoding='utf_8'))
        sck.send(LSTN_CMD_EXIT.encode(encoding="utf_8"))

        sck.close()

        logger.info(
            "Notified save to channel with id {0}"
            .format(channel_id)
        )
    except Channel.DoesNotExist:
        logger.info(
            "Channel with id {0} does not exist"
            .format(channel_id)
        )

    return
Beispiel #2
0
def mount_notify_save(mount_id):
    from .models import Mount

    logger.info(
        "Notifying save to mount with id {0}"
        .format(mount_id)
    )

    mount = Mount.objects.get(pk=mount_id)

    sck = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)

    sck.connect(LS_SOCKET_BASE_MOUNT_PATH.format(mount.pk))

    sck.send(LSTN_CMD_NOTIFY_SAVE.encode(encoding='utf_8'))
    sck.send(LSTN_CMD_EXIT.encode(encoding="utf_8"))

    sck.close()

    logger.info(
        "Notified save to mount with id {0}"
        .format(mount_id)
    )
    return