# coding:utf-8
import socket
import sys
import os
reload(sys)
sys.setdefaultencoding("utf-8")
# set host and port
HOST, PORT = '10.72.80.141', 8088
class SocketFromServer():
def __init__(self):
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.sock.connect((HOST, PORT))
self.msg_incident = []
a = os.popen('whoami /user')
r = a.readlines()
print r
r = r[6].split(' ')[0]
b = r.split('\\')[1]
self.name = b
def get_data_from_server(self):
self.data = "get"
self.sock.sendall(bytes(self.data))
buf = self.sock.recv(131072) # Receive data from the server and shut down
self.msg_incident = []
if buf == 'null':
return [], [], []
if buf == '':
return [], [], []
for i in buf.split('||||'):
self.msg_incident.append(i)
self.res = []
self.IMList = []
self.openByList = []
for i in self.msg_incident:
tmp = []
tmp = i.split(',')[:7]
self.IMList.append(tmp[0])
self.openByList.append(tmp[2])
tmp.append(','.join(i.split(',')[7:]))
self.res.append(tmp)
# print 'success rece data'
self.openByList = list(set(self.openByList))
self.openByList.insert(0, 'All')
return self.res, self.IMList, self.openByList