def run(self): print "tcp handler started" while not self.eq.stop: #try: data=self.socket.recv(32) if not data: break if len(data) < 1: break if len(data)<32: continue m = message.getMsg(data) #if isinstance(m, message.msgMouse): # dx,dy=m.detail() # if dx*dy != 0: # if m.msg[2] != 32: # print "btns %s"%m.msg[2] r = m.response() if r: self.socket.sendall(m.response()) #except: pass print "tcp handler stopped" self.socket.close()
#!/usr/bin/env python from iniparse import INIConfig import feed_handler import connect import message cfg = INIConfig(open('settings.ini')) rsslink = cfg['feeds']['rsslink'] phoneno = cfg['sms']['phoneno'] password = cfg['sms']['password'] groupname = cfg['sms']['groupname'] apiVersion = cfg['api']['version'] countryCode = cfg['api']['countrycode'] feed_item = getRss(rsslink) storeMsg(feed_item) token = connect.tryLogin(salt, challenge, password, phoneno, apiVersion, countryCode) msg = message.getMsg() message.postMsg(msg, groupname, token, apiVersion) connect.tryLogout(token, apiVersion)
def getMsg(self, request, context): response = message_pb2.msg() response.message = message.getMsg(request.message) print(response.message) return response
import time import message import os import logging realPath = os.path.split(os.path.realpath(__file__))[0] logging.basicConfig(level=logging.INFO,#控制台打印的日志级别 filename=realPath+'/new-image-post.log', filemode='a',##模式,有w和a,w就是写模式,每次都会重新写日志,覆盖之前的日志 #a是追加模式,默认如果不写的话,就是追加模式 format= '%(asctime)s - %(pathname)s[line:%(lineno)d] - %(levelname)s: %(message)s' #日志格式 ) msgData = message.getMsg('image-post.txt') index = int(message.getMsg('index.txt')[0]) if len(msgData) < index: exit() currentData = msgData[index].split('|') msg = currentData[0] filePath = currentData[1].strip() # 读取配置 cp = ConfigParser() cp.read(realPath+'/config/user.config') phoneNumber = cp.get('user','phoneNumber') password = cp.get('user','password') chrome_options = webdriver.ChromeOptions() chrome_options.add_argument('--no-sandbox') chrome_options.add_argument('--headless')