示例#1
0
def pre_delete_emission(sender, **kwargs):

    obj = kwargs['instance']

    """
    check if emission is in a critical range (eg it should start soon)
    """
    SCHEDULE_AHEAD = 60 * 60 * 3 # seconds
    range_start = datetime.datetime.now()
    range_end = datetime.datetime.now() + datetime.timedelta(seconds=SCHEDULE_AHEAD)

    # TODO: think about calculation
    # if obj.time_start > range_start and obj.time_start < range_end:

    if not obj or not obj.time_end or not obj.time_start:
        return

    if obj.time_end > range_start and obj.time_start < range_end:
        # notify pypy
        #print 'emission in critical range: notify pypo'
        from base.pypo.gateway import send as pypo_send
        from abcast.util import scheduler
        data = scheduler.get_schedule_for_pypo(range_start=range_start, range_end=range_end, exclude=[obj.pk])

        message = {
            'event_type': 'update_schedule',
            'schedule': {'media': data},
        }
        pypo_send(message)
    else:
        pass
示例#2
0
    def run(self):

        translation.activate('en')

        if self.action == 'update_schedule':

            range_start = datetime.datetime.now()
            range_end = datetime.datetime.now() + datetime.timedelta(seconds=60*60*6)
            data = scheduler.get_schedule_for_pypo(range_start, range_end)

            pg = PypoGateway()
            message = {
                'event_type': 'update_schedule',
                'schedule': {'media': data},
            }
            pg.send(message)

        if self.action == 'reset_schedule':

            message = {
                'event_type': 'update_schedule',
                'schedule': {'media': []},
            }
            pypo_send(message)

        if self.action == 'custom_message':

            message = {
                'event_type': '%s' % self.message,
                'schedule': {'media': []},
            }
            pypo_send(message)
def pre_delete_emission(sender, **kwargs):

    obj = kwargs['instance']
    """
    check if emission is in a critical range (eg it should start soon)
    """
    SCHEDULE_AHEAD = 60 * 60 * 3  # seconds
    range_start = datetime.datetime.now()
    range_end = datetime.datetime.now() + datetime.timedelta(
        seconds=SCHEDULE_AHEAD)

    # TODO: think about calculation
    # if obj.time_start > range_start and obj.time_start < range_end:

    if not obj or not obj.time_end or not obj.time_start:
        return

    if obj.time_end > range_start and obj.time_start < range_end:
        # notify pypy
        #print 'emission in critical range: notify pypo'
        from base.pypo.gateway import send as pypo_send
        from abcast.util import scheduler
        data = scheduler.get_schedule_for_pypo(range_start=range_start,
                                               range_end=range_end,
                                               exclude=[obj.pk])

        message = {
            'event_type': 'update_schedule',
            'schedule': {
                'media': data
            },
        }
        pypo_send(message)
    else:
        pass
def post_save_emission_task(obj):
    """
        check if emission is in a critical range (eg it should start soon)
        """
    SCHEDULE_AHEAD = 60 * 60 * 3  # seconds
    range_start = datetime.datetime.now()
    range_end = datetime.datetime.now() + datetime.timedelta(
        seconds=SCHEDULE_AHEAD)

    # TODO: think about calculation
    # if obj.time_start > range_start and obj.time_start < range_end:
    if obj.time_end > range_start and obj.time_start < range_end:
        # notify pypy
        log.debug(
            'Emission in critical range ({:} - {:}) - will notify pypo'.format(
                range_start, range_end))
        from base.pypo.gateway import send as pypo_send
        from abcast.util import scheduler
        data = scheduler.get_schedule_for_pypo(range_start=range_start,
                                               range_end=range_end)

        message = {
            'event_type': 'update_schedule',
            'schedule': {
                'media': data
            },
        }
        pypo_send(message)
示例#5
0
    def get_schedule(self, request, **kwargs):

        channel_uuid = request.GET.get('channel_id', None)

        if channel_uuid:
            channel = get_object_or_404(Channel, uuid=channel_uuid)
        else:
            channel = None

        range_start = datetime.datetime.now()
        range_end = datetime.datetime.now() + datetime.timedelta(seconds=SCHEDULE_AHEAD)

        # TODO: it would be possible to implement multi-channel way here
        media = scheduler.get_schedule_for_pypo(range_start, range_end, channel=channel)
        # map
        data = {'media': media}

        return self.json_response(request, data)
示例#6
0
    def get_schedule(self, request, **kwargs):

        channel_uuid = request.GET.get('channel_id', None)

        if channel_uuid:
            channel = get_object_or_404(Channel, uuid=channel_uuid)
        else:
            channel = None

        range_start = datetime.datetime.now()
        range_end = datetime.datetime.now() + datetime.timedelta(seconds=SCHEDULE_AHEAD)

        # TODO: it would be possible to implement multi-channel way here
        media = scheduler.get_schedule_for_pypo(range_start, range_end, channel=channel)
        # map
        data = {'media': media}

        return self.json_response(request, data)
示例#7
0
def post_save_emission_task(obj):

        """
        check if emission is in a critical range (eg it should start soon)
        """
        SCHEDULE_AHEAD = 60 * 60 * 3 # seconds
        range_start = datetime.datetime.now()
        range_end = datetime.datetime.now() + datetime.timedelta(seconds=SCHEDULE_AHEAD)


        # TODO: think about calculation
        # if obj.time_start > range_start and obj.time_start < range_end:
        if obj.time_end > range_start and obj.time_start < range_end:
            # notify pypy
            log.debug('Emission in critical range ({:} - {:}) - will notify pypo'.format(range_start, range_end))
            from base.pypo.gateway import send as pypo_send
            from abcast.util import scheduler
            data = scheduler.get_schedule_for_pypo(range_start=range_start, range_end=range_end)

            message = {
                'event_type': 'update_schedule',
                'schedule': {'media': data},
            }
            pypo_send(message)