示例#1
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("序列号位数不对")
示例#2
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)