def test_ping_WebServer(): """ Start services and send Ping to WebServer. Then terminate the WebServer and verify that the ping fails. """ # Convenience. WSClient = azrael.wsclient.WSClient ip, port = config.addr_webserver, config.port_webserver # Start the services. clerk = azrael.clerk.Clerk() web = azrael.web.WebServer() clerk.start() web.start() # Create a Websocket client. client = azrael.wsclient.WSClient(ip=ip, port=port, timeout=1) # Ping Clerk via WebServer. assert client.ping() assert client.pingWebserver().ok # Terminate the services. clerk.terminate() web.terminate() clerk.join() web.join() # Ping must now be impossible. with pytest.raises(ConnectionRefusedError): WSClient(ip=ip, port=port, timeout=1) assert not client.pingWebserver().ok
def process(get) : url = '/zong' number = get.get_argument("number") text = get.get_argument("text") sender = get.get_argument("sender") if text != None and sender != None: num = number print(num) #op = 'zong' subtxt = text #subtxt =subtxt.replace("'",'') # meta_data = get['meta_data'] # smpp = ''meta_data.split('?') # print('smpp - split length' + len(smpp)) append_to_log('/mmatcher/sms/log/' + url + '.log', sender + ' - ' + text) print(subtxt) subtxt = subtxt.lower() if subtxt == 'sub m' : subtxt = subtxt.replace('sub m','sub bus') elif subtxt == 'sub off' : subtxt = subtxt.replace('sub off','unsub') elif subtxt == 'sub free off' : subtxt = subtxt.replace('sub free off','unsub') elif subtxt == 'off sub' : subtxt = subtxt.replace('off sub','unsub') elif subtxt == 'sub' : subtxt = subtxt.replace('sub','sub bus') print(subtxt) body = web.start(subtxt, sender.replace('+',''), url.replace('/','')) logBody = body filename = datetime.now().strftime('/log/' + url + '_sms_usage-%Y%m%U%d.log') append_to_log('/mmatcher/sms' + filename, sender + ' !|! ' + subtxt + ' !|! ' + logBody + ' !|! '+num) else: body = 'The command was not recognized. To sell, send SELL<space> your item to 289. To buy, send BUY<space>your item to 289. Send H to 289 for help.' print(body)
def process(get): url = '/zong' number = get.get_argument("number") text = get.get_argument("text") sender = get.get_argument("sender") if text != None and sender != None: num = number print(num) #op = 'zong' subtxt = text #subtxt =subtxt.replace("'",'') # meta_data = get['meta_data'] # smpp = ''meta_data.split('?') # print('smpp - split length' + len(smpp)) append_to_log('/mmatcher/sms/log/' + url + '.log', sender + ' - ' + text) print(subtxt) subtxt = subtxt.lower() if subtxt == 'sub m': subtxt = subtxt.replace('sub m', 'sub bus') elif subtxt == 'sub off': subtxt = subtxt.replace('sub off', 'unsub') elif subtxt == 'sub free off': subtxt = subtxt.replace('sub free off', 'unsub') elif subtxt == 'off sub': subtxt = subtxt.replace('off sub', 'unsub') elif subtxt == 'sub': subtxt = subtxt.replace('sub', 'sub bus') print(subtxt) body = web.start(subtxt, sender.replace('+', ''), url.replace('/', '')) logBody = body filename = datetime.now().strftime('/log/' + url + '_sms_usage-%Y%m%U%d.log') append_to_log( '/mmatcher/sms' + filename, sender + ' !|! ' + subtxt + ' !|! ' + logBody + ' !|! ' + num) else: body = 'The command was not recognized. To sell, send SELL<space> your item to 289. To buy, send BUY<space>your item to 289. Send H to 289 for help.' print(body)
# self.streams.difference_update([self.streamUpdate]) # self.finish() def on_connection_close(self): print("Closed connection with %s".format(self.request.remote_ip)) #self.streams.difference_update([self.streamUpdate]) class TimeStream(tornado.web.RequestHandler): @tornado.web.asynchronous def initialize(self): self.scheduler = tornado.ioloop.PeriodicCallback(self.sendTime,1000 ) self.scheduler.start() def get(self): self.write(":TimeSync\n\n") self.set_header('Content-Type', 'text/event-stream') self.flush def sendTime(self): self.write("data:%s\n\n" % json.dumps(time.time())) self.flush() def on_connection_close(self): self.scheduler.stop() if __name__ == "__main__": web = Server() web.start()