def onCancel(client_name): try: socket_id = request.sid session_closed, room_id = matchmake.checkDisconnect(socket_id) if session_closed: session.close(room_id) chat.roomServerMessage( 'Client ' + misc.generateNameTag( socket_id, matchmake.sid_cid_pairs[socket_id]) + ' has left the room', room_id) matchmake.clearRoom(room_id, socket_id) else: room_found, room, index = matchmake.checkObserverDisconnect( socket_id) if room_found: del matchmake._rooms[room]['Viewers'][index] chat.roomServerMessage( 'Client ' + misc.generateNameTag( socket_id, matchmake.sid_cid_pairs[socket_id]) + ' has left the room', room) chat.roomChatInfo(socket_id, matchmake.sid_cid_pairs[socket_id]) print((u'Client canceled: ' + client_name).encode('utf-8')) except Exception: err_log = open('err_log', 'a', encoding='utf-8') err_log.write(traceback.format_exc()) print(traceback.format_exc())
def clearRoom(room_to_clear, sid): emit(u'broken', sid_cid_pairs[sid] + u' has left the room: ' + sid, room=room_to_clear) leave_room(room_to_clear) print(str(_rooms[room_to_clear]['Viewers'])) _rooms[room_to_clear]['Viewers'].pop() if len(_rooms[room_to_clear]['Viewers']) == 0: try: session.close(room_to_clear) del _rooms[room_to_clear] except KeyError: print((u'room ' + room_to_clear + u' already cleared').encode('utf-8'))
def dining(intent): location = intent["currentIntent"]["slots"]["Location"] cuisine = intent["currentIntent"]["slots"]["Cuisine"] dining_date = intent["currentIntent"]["slots"]["Date"] dining_time = intent["currentIntent"]["slots"]["Time"] people = intent["currentIntent"]["slots"]["PeopleNum"] phone = intent["currentIntent"]["slots"]["Phone"] logger.debug(intent["currentIntent"]["slots"]) #send message to sqs import sqs msg_attrs = {} msg_attrs['Location'] = location msg_attrs['Cuisine'] = cuisine msg_attrs['Date'] = dining_date msg_attrs['Time'] = dining_time msg_attrs['PeopleNum'] = people msg_attrs['Phone'] = phone msg_body = "test" sqs.send_message(msg_attrs, msg_body) output_session_attributes = intent['sessionAttributes'] if intent['sessionAttributes'] is not None else {} return session.close(output_session_attributes, 'Fulfilled', { 'contentType': 'PlainText', 'content': 'You’re all set. Expect my recommendations shortly! Have a good day.' } )
def close_spider(self, spider): session.close()
def tearDown(self): """ Test teardown """ session.close() # Remove the tables and their data from the database Base.metadata.drop_all(engine)