Changeset 462
- Timestamp:
- 05/15/08 16:25:36 (8 months ago)
- Files:
-
- branches/trunk-pmd-intproto/agent/agent.py (modified) (2 diffs)
- branches/trunk-pmd-intproto/server/master.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/trunk-pmd-intproto/agent/agent.py
r432 r462 52 52 print "f2" 53 53 pass 54 55 ### 56 ### Client side update message generators. 57 ### 58 ### These functions return the message to send to the server if 59 ### such an update is required, otherwise they return none 60 ### 61 62 def updated_bools(self): 63 ''' 64 returns the updated bools msg if updated since the last pass 65 ''' 66 print "Unimplemented" 67 return None 68 69 def updated_status(self): 70 ''' 71 returns the status update msg if it has changed since last invocation, 72 otherwise returns None 73 ''' 74 print "Unimplemented" 75 return None 76 77 def updated_logs(self): 78 ''' 79 returns updated messages msg containing all new messages from the 80 log file 81 82 NOTE: This should maintain a persistant notion of how far in the 83 log file we have come. Don't send all messages at every startup. 84 ''' 85 print "Unimplemented" 86 return None 87 88 def updated_modules(self): 89 ''' 90 Not sure what this should do at the moment. 91 FIXME: Jeremy please help flesh this out. 92 ''' 93 return None 94 ################################################################# 54 95 55 96 def handle_msg(self, msg): … … 110 151 if self.server == None: 111 152 self.connect() 112 if(self.server != None and self.server.data_ready(5) != []): 153 if self.server == None: 154 time.sleep(5) 155 return 156 map(self.server.send_message, filter(lambda x: x != None, \ 157 [self.updated_bools(), 158 self.updated_status(), 159 self.updated_logs(), 160 self.updated_modules() ]) ) 161 162 if(self.server.data_ready(5) != []): 113 163 msg = self.server.recv_message() 114 164 print self.handle_msg(msg) 115 165 self.server.send_message(msg) 116 else:117 time.sleep(5)118 166 119 167 c = ClientD("localhost", 50000) branches/trunk-pmd-intproto/server/master.py
r456 r462 59 59 self.manager = server.Server('', 55555, accept_func=accept_helper) 60 60 61 def service_client(self): 61 def service_client(self, (client, info)): 62 ''' 63 Handle servicing of a client connection. The client will send us 64 a message. We need to store the data off so a manager can query 65 against it later. 66 ''' 67 try: 68 print "Servicing " + repr(info) 69 m = select.select([client],[],[],0)[0] 70 if(m != []): 71 val = pickle.load(client.makefile()) 72 if val.type != "update": 73 print "Unrecognized message type from client, got \""\ 74 + val.type + '"' 75 raise NotImplementedError 76 if val.msg == 'bools': 77 self.bools((val.body, info[0])) 78 elif val.msg == 'status': 79 self.status((val.body, info[0])) 80 elif val.msg == 'log': 81 # This branch should possibly clear the store of \ 82 # old log messages FIXME: 83 self.log((val.body, info[0])) 84 elif val.msg == 'logdelta': 85 self.log((val.body, info[0])) 86 elif val.msg == 'modules': 87 self.log((val.body, info[0])) 88 else: 89 print "Unrecognized message \"" + val.msg + '"' 90 raise NotImplementedError 91 else: 92 pass 93 except EOFError: 94 # client closed connection. Can clean up this socket. 95 print "Removing a socket" 96 self.clients.remove(client) 97 pass 62 98 pass 63 99
