示例#1
0
    def deal_with(self, data_list):
        """
        :param data_list: list
        :param partition:
        :return: None
        """
        for data in data_list:
            body = data.get('body', 'Error:no body keyword').replace('\\', '')
            offset = data.get('offset', 'Error: no offset keyword')

            try:
                body_dict = json.loads(body)

                bodyTimeYmd = tools.timeFormat(
                    "%Y%m%d", int(body_dict.get("EndTime", int(time.time()))))
                path = "/".join([dataRootPath, mq_topic])
                fileName = bodyTimeYmd
                self.saveToLocal(path, fileName, body)

            except Exception as e:
                print(e)
示例#2
0
# coding=utf-8
from __future__ import print_function

import json
import os
import threading
import time

from servers.mq.RtmpFluenceAPI import mqAPI as MQAPI
from servers.config import rtmpFluence_conf as conf
from servers.utils import tools

PARTITION_NUM = conf.PARTITION_NUM
LOG_PATH = conf.log_producer_Path
TIMESTAMP = tools.timeFormat('%Y%m%d', int(time.time()))
mq_topic = conf.MQ_TOPIC
dataRootPath = conf.dataRootPath


class RtmpProducer(threading.Thread):
    def __init__(self, start_partition, stop_partition):
        super(RtmpProducer, self).__init__()
        self.daemon = True
        if start_partition < 0 and stop_partition < PARTITION_NUM:
            raise ValueError("start_partition or stop_partition error ")
        self.partition_range = (start_partition, stop_partition + 1)

    def run(self):
        self.response()

    def response(self):