示例#1
0
 def __init__(self, ip, port):
     #本机IP
     self.ip = ip
     #本机端口
     self.port = port
     #self.hosts = serialize.all_host_configs()
     self.redis = RedisHelper()
示例#2
0
def flush_all_host_configs_into_redis():
    applied_hosts = []
    redis = RedisHelper()
    for group in hosts.monitored_groups:
        applied_hosts.extend(group.hosts)
    applied_hosts = set(applied_hosts)

    for host_ip in applied_hosts:
        host_config = host_config_serializer(host_ip)
        key = 'HostConfig::%s' % host_ip
        redis.set(key, pickle.dumps(host_config))
    return True
示例#3
0
def flush_all_host_configs_into_redis():  #把所有配置刷到redis
    applied_hosts = []
    redis = RedisHelper()
    for group in monitored_groups:
        applied_hosts.extend(group.hosts)
    applied_hosts = set(applied_hosts)

    for host_ip in applied_hosts:
        host_config = host_config_serializer(host_ip)
        # 序列化字典后存入redis
        key = 'HostConfig::%s' % host_ip
        redis.set(key, pickle.dumps(host_config))
示例#4
0
def init_all_host_configs_into_client():
    applied_hosts = []
    redis = RedisHelper()
    for group in hosts.monitored_groups:
        applied_hosts.extend(group.hosts)
    applied_hosts = set(applied_hosts)

    configs = {'configs': {}}
    for host_ip in applied_hosts:
        host_config = host_config_serializer(host_ip)
        key = 'HostConfig::%s' % host_ip

        configs['configs'][key] = pickle.dumps(host_config)

    return configs
示例#5
0
    def on_click(self):
        input_value = self.textbox.text()
        # print(type(input_value))
        if self.pattern.match(input_value):

            textboxValue = input_value
            print(textboxValue)
            #发布到redis
            obj = RedisHelper()
            for i in range(1, 8):
                obj.publish({
                    "type": "add_sn",
                    "sn": textboxValue,
                    "complete": 1,
                    "station": 'ST' + str(i) + '0'
                })  #发布

            rd = obj.get_redis()
            while True:
                now_time = int(time.time())
                if rd.sadd("option_sets", now_time):
                    rd.hset(
                        "option_hashes", now_time,
                        '{"method": "write_complete", "params": "%s"}' %
                        "ST10")
                    rd.publish("START", now_time)
                    print('station_name complete')
                    break

            #结果存到label中
            self.lb1.setText(textboxValue)
            self.lb1.adjustSize()
            """打印完毕之后清空文本框"""
            self.textbox.setText('')
        else:
            self.textbox.setText('')
            print("序列号位数不对")
示例#6
0
#!/usr/bin/env python
# -*- coding:utf-8 -*-
''''订阅方'''
import sys

reload(sys)

sys.setdefaultencoding('utf-8')
from redishelper import RedisHelper

obj = RedisHelper()
redis_sub = obj.subscribe(channel='liyanliang')

while True:
    msg = redis_sub.parse_response()
    print('接收:'.decode(), msg)
示例#7
0
 def __init__(self, ip, port):
     self.ip = ip
     self.port = port
     self.hosts = serialize.all_host_configs()
     self.redis = RedisHelper()
示例#8
0
 def __init__(self):
     self.hosts = serialize.all_host_configs()
     self.redis = RedisHelper()
示例#9
0
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
__author__ = "Sigai"

from redishelper import RedisHelper

subscriber = RedisHelper()

sub = subscriber.subscribe()

while True:
    msg = sub.parse_response()
    print(msg)
示例#10
0
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
__author__ = "Sigai"

from redishelper import RedisHelper
import time

publisher = RedisHelper()
result = publisher.publish(time.ctime())
print(result)
示例#11
0
 def __init__(self, server, port):
     self.server = server
     self.port = port
     self.configs = {}
     self.lock = threading.Lock()
     self.redis = RedisHelper()
示例#12
0
 def __init__(self, server, port):
     self.server = server
     self.port = port
     self.configs = {}
     self.redis = RedisHelper()  #建立redis链接