コード例 #1
0
ファイル: tweetProducer.py プロジェクト: rgasper/kafka_tweets
def delivery_report(err, msg):
    """ Called once for each message produced to indicate delivery result.
        Triggered by poll() or flush(). """
    if err is not None:
        log.info('Message delivery failed: {}'.format(err))
    else:
        log.info('Message delivered to {} [{}]'.format(msg.topic(),
                                                       msg.partition()))
コード例 #2
0
ファイル: bet.py プロジェクト: lijinzhou2016/jiuzhoubet
    def xiadan(self, code_data, gid, amt):
        ''' 投注

        :return: 响应json

        '''
        log.info(gid)
        peilv_data = self.get_peilv()
        if peilv_data is None:
            peilv_data = self.get_default_peilv_map()
        post_data = self.format_24_197_post_data(code_data, peilv_data, gid,
                                                 amt)
        post_url = settings.XIAZHU_URL
        # print(post_data)
        post_headers = self.get_headers()
        # time.sleep(3)
        return self._post(post_url, data=post_data, headers=post_headers)
コード例 #3
0
ファイル: tweetProducer.py プロジェクト: rgasper/kafka_tweets
    """ Called once for each message produced to indicate delivery result.
        Triggered by poll() or flush(). """
    if err is not None:
        log.info('Message delivery failed: {}'.format(err))
    else:
        log.info('Message delivered to {} [{}]'.format(msg.topic(),
                                                       msg.partition()))


if __name__ == '__main__':
    # log into twitter api
    api = twitter.Api(consumer_key=CONSUMER_API_KEY,
                      consumer_secret=CONSUMER_API_SECRET_KEY,
                      access_token_key=ACCESS_TOKEN,
                      access_token_secret=ACCESS_TOKEN_SECRET)
    log.info("Connected to Twitter API!")
    prod = Producer({'bootstrap.servers': '127.0.0.1:9092'})
    log.info("Producer connected to Python Server")
    # log some tweet dumps
    max_tweets = 5
    count = 0
    for tweet in api.GetStreamFilter(track=USERS, languages=LANGUAGES):
        count += 1
        data_str = tweet['text']
        log.info(data_str)
        prod.produce('tweets',
                     data_str.encode('utf-8'),
                     callback=delivery_report)
        if count >= max_tweets:
            log.info('done logging tweets, hit max count')
            break
コード例 #4
0
ファイル: testcase.py プロジェクト: Amyli0601/python
"""
============================
Author:柠檬班-木森
Time:2019/8/27
E-mail:[email protected]
Company:湖南零檬信息技术有限公司
============================
"""

# import mylogger
#
#
# log = mylogger.MyLogger()

from mylogger import log

log.debug('python')
log.info('这个时info')
コード例 #5
0
ファイル: run_test.py プロジェクト: OMEN001/Python_Basic
Company:湖南零檬信息技术有限公司
============================
"""
import unittest
import test_cases
from HTMLTestRunnerNew import HTMLTestRunner
from mylogger import log, MyLogger

# 不要重复去创建日志收集器,创建对各收集器,日志会重复收集
# log2 = MyLogger.create_logger()
# log3 = MyLogger.create_logger()

# 创建测试套件
suite = unittest.TestSuite()

log.info("测试套件创建成功")

# 加载用例用例到套件
loader = unittest.TestLoader()
suite.addTest(loader.loadTestsFromModule(test_cases))

log.info("测试套件加载完毕")

with open('zy_report.html', 'wb') as fb:
    # 创建测试运行程序
    runner = HTMLTestRunner(stream=fb,
                            title='柠檬班测试报告',
                            description='这是我们23期的第一份报告作业',
                            tester='MuSen')
    # 执行测试套件中的用例
    runner.run(suite)
コード例 #6
0
ファイル: bet.py プロジェクト: lijinzhou2016/jiuzhoubet
    def format_24_197_post_data(self, code_data, peilv_data, gid, amt):
        '''

        :return:
        '''
        fifth = []
        fourth = []
        third = []
        second = []
        first = []

        fifth_name = []
        fourth_name = []
        third_name = []
        second_name = []
        first_name = []

        fifth_odds = []
        fourth_odds = []
        third_odds = []
        second_odds = []
        first_odds = []

        encode_switch_map = self.get_switch_xiazhu_type_map()

        for data in code_data[settings.POSITON_FIFTH]:  # 万位投注号码列表
            if data[settings.XIAZHU_CODE_MONEY_KEY] == amt:
                fifth.append(
                    encode_switch_map[data[settings.XIAZHU_CODE_TYPE_KEY]])
                fifth_name.append(data[settings.XIAZHU_CODE_TYPE_KEY])

        for data in code_data[settings.POSTION_FOURTH]:  # 千位投注号码列表
            if data[settings.XIAZHU_CODE_MONEY_KEY] == amt:
                fourth.append(
                    encode_switch_map[data[settings.XIAZHU_CODE_TYPE_KEY]])
                fourth_name.append(data[settings.XIAZHU_CODE_TYPE_KEY])

        for data in code_data[settings.POSTION_THIRD]:  # 百位投注号码列表
            if data[settings.XIAZHU_CODE_MONEY_KEY] == amt:
                third.append(
                    encode_switch_map[data[settings.XIAZHU_CODE_TYPE_KEY]])
                third_name.append(data[settings.XIAZHU_CODE_TYPE_KEY])

        for data in code_data[settings.POSTION_SECOND]:  # 十位投注号码列表
            if data[settings.XIAZHU_CODE_MONEY_KEY] == amt:
                second.append(
                    encode_switch_map[data[settings.XIAZHU_CODE_TYPE_KEY]])
                second_name.append(data[settings.XIAZHU_CODE_TYPE_KEY])

        for data in code_data[settings.POSTION_FIRST]:  # 个位投注号码列表
            if data[settings.XIAZHU_CODE_MONEY_KEY] == amt:
                first.append(
                    encode_switch_map[data[settings.XIAZHU_CODE_TYPE_KEY]])
                first_name.append(data[settings.XIAZHU_CODE_TYPE_KEY])

        for num in fifth:  # 万位投注号码赔率
            fifth_odds.append(
                str(peilv_data[settings.POSITON_FIFTH_ODDS + num]))

        for num in fourth:  # 千位投注号码赔率
            fourth_odds.append(
                str(peilv_data[settings.POSITON_FIFTH_ODDS + num]))

        for num in third:  # 百位投注号码赔率
            third_odds.append(
                str(peilv_data[settings.POSITON_FIFTH_ODDS + num]))

        for num in second:  # 十位投注号码赔率
            second_odds.append(
                str(peilv_data[settings.POSITON_FIFTH_ODDS + num]))

        for num in first:  # 个位投注号码赔率
            first_odds.append(
                str(peilv_data[settings.POSITON_FIFTH_ODDS + num]))

        # print(fifth)
        # print(fifth_odds)
        # print(fourth)
        # print(fourth_odds)
        # print(third)
        # print(third_odds)
        # print(second)
        # print(second_odds)
        # print(first)
        # print(first_odds)

        bType = ';'.join([
            ','.join(fifth), ','.join(fourth), ','.join(third),
            ','.join(second), ','.join(first)
        ])

        wOdds = ';'.join([
            ','.join(fifth_odds), ','.join(fourth_odds), ','.join(third_odds),
            ','.join(second_odds), ','.join(first_odds)
        ])

        bType_name = ';'.join([
            ','.join(fifth_name), ','.join(fourth_name), ','.join(third_name),
            ','.join(second_name), ','.join(first_name)
        ])

        log_info = bType_name + " " + str(amt)
        log.info(log_info)

        data = {
            "gid": gid,
            "gType": self._gType,
            "kType": self._kType,
            "lType": self._lType,
            "spType": "oneStar",
            "count": 1,
            "delGid": "",
            "bType": bType,
            "wOdds": wOdds,
            "amt": amt,
            "betTime": self.format_post_time()
        }

        return {'betData': str(data)}
コード例 #7
0
ファイル: bet.py プロジェクト: lijinzhou2016/jiuzhoubet
                    print("request code success")
                    break
                else:
                    if t == REQUESTS_TIMES - 1:
                        send_msg(sendermsg.MSG_REQUESTS_CODE_ERROR)
                        break
                    delay.delay(10)
                    continue
            else:  # 请求发号器接口失败
                print(u"请求发号器接口失败")
                send_msg(str(gid)[-3:] + ":" + "请求FHQ接口失败")
                delay.delay(10)

        # code_data = bets.get_propery_code_data()
        if not code_data["isbet"]:
            log.info(str(gid) + " Not buy")
            continue

        amt_list = code_data[settings.XIAZHU_CODE_MONEY_KEY]
        for amt in amt_list:
            for i in range(3):
                money = bets.get_money()
                if money:
                    log.info("Before Bet Money: " + str(money))
                    break
                if i == 2:
                    log.error("Get Money Failed")
                time.sleep(3)

            for loop in range(4):
                try:
コード例 #8
0
ファイル: tweetConsumer.py プロジェクト: rgasper/kafka_tweets
from confluent_kafka import Consumer, KafkaException
import sys
from mylogger import log
import json
import logging

if __name__ == '__main__':

    topics = ["tweets"]

    # Consumer configuration
    log.info("Setting up the configs")
    conf = {
        'bootstrap.servers': "127.0.0.1",
        'group.id': "group_test",
        'session.timeout.ms': 7000,
        'auto.offset.reset': 'earliest'
    }

    # Create logger for consumer (logs will be emitted when poll() is called)
    log.info("Creating a consumer on the basis of configs")
    logger = logging.getLogger('consumer')
    logger.setLevel(logging.DEBUG)
    handler = logging.StreamHandler()
    handler.setFormatter(
        logging.Formatter('%(asctime)-15s %(levelname)-8s %(message)s'))
    logger.addHandler(handler)

    # Create Consumer instance
    # Hint: try debug='fetch' to generate some log messages
    c = Consumer(conf, logger=logger)