def program_start(program_id): from programs.models import Program from streams.models import Channel logger.info( "Launching program with id {0}" .format(program_id) ) try: program = Program.objects.get(pk=program_id) channel = Channel.objects.get(program=program) sck = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) sck.connect(LS_SOCKET_BASE_CHANNEL_PATH.format(channel.pk)) sck.send( LSTN_CMD_PROGRAM_ADD.format(program_id).encode(encoding='utf_8')) sck.send( LSTN_CMD_EXIT.encode(encoding="utf_8")) sck.close() except Program.DoesNotExist: logger.error( "Program with id {0} does not exist" .format(program_id) ) logger.info( "Launched program with id {0}" .format(program_id) ) return
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
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