Ejemplo n.º 1
0
 def listening(self, queue):
     assert isinstance(queue, Queue.Queue)
     inputs = [self.server]
     while inputs:
         rs, ws, es = select.select(inputs, [], [], 5)
         for r in rs:
             if r is self.server:
                 clientsock, clientaddr = r.accept()
                 inputs.append(clientsock)
             else:
                 data = r.recv(2048)
                 #if not data:
                 #inputs.remove(r)
                 if data:
                     print data, 'Incomming from ', clientaddr
                     queue.put(data)
                     data_config = GPRS_data_operator.read_config()
                     data_time = time.strftime('%Y%m%d')
                     #data_operator = GPRS_data_operator(os.path.join(data_config['data_dir'],data_time+'.txt'))
                     data_operator = GPRS_data_operator(
                         os.path.join(data_config['data_dir'],
                                      data_time + '.dat'))
                     data_operator.write_data(data)
                 else:
                     print 'no data comming, closing'
                     inputs.remove(r)
Ejemplo n.º 2
0
 def handle_read(self):
     data = self.recv(1024)
     if data:
         print data
     GPRS_handler.current_data = data
     GPRS_handler.current_flag = time.strftime('%Y-%m-%d:%H:%M%S')
     data_config = GPRS_data_operator.read_config()
     data_time = time.strftime('%Y-%m-%d')
     data_operator = GPRS_data_operator(
         os.path.join(data_config['data_dir'], data_time + '.txt'))
     data_operator.write_data(data)
Ejemplo n.º 3
0
 def read_text(self):
     data_config = GPRS_data_operator.read_config()
     data_time = time.strftime('%Y%m%d')
     data_operator = GPRS_data_operator(
         os.path.join(data_config['data_dir'], data_time + '.dat'))
     self.ip_var.set(data_config['ip'])
     self.port_var.set(data_config['port'])
     self.directory_var.set(data_config['data_dir'])
     data = data_operator.read_data()
     #print data
     self.receiver_data.insert(END, ''.join(data))
     #data_operator.write_data(data)
     self.pre_date = datetime.now()
Ejemplo n.º 4
0
 def recv(self, queue):
     while True:
         try:
             data = self.server.recv(0xfff)
             print time.strftime(
                 '%Y-%m-%d %h:%M:%s'), data, 'Incomming from '  #,clientaddr
             queue.put(data)
             data_config = GPRS_data_operator.read_config()
             data_time = time.strftime('%Y-%m-%d')
             data_operator = GPRS_data_operator(
                 os.path.join(data_config['data_dir'], data_time + '.dat'))
             data_operator.write_data(data)
         except Exception, e:
             print e