def get_logs( s, ptrn, max_entries_to_return ): """ The server is not obligated to keep logs for any set period of time. The server is not obligated to return all the logs that match. Returns newest to oldest. """ if not LOGS_PUBLIC: return 0 to_return = [] try: log = pickle.load( open( LOGS_PICKLE, "r" ) ) except IOError: log = [] for load in log: if s._match( load, ptrn ): to_return.append( shared.stripped_copy(load) ) to_return.reverse() # newest first if len( to_return ) > max_entries_to_return: to_return = to_return[:max_entries_to_return] if len( to_return ) > MAX_LOGS_RETURNED: to_return = to_return[:MAX_LOGS_RETURNED] return to_return
def _ding(s, client_info, Cpw, load): xmlrpc_url = client_info.get( "CLIENT-XMLRPC", None ) if xmlrpc_url: try: server=xmlrpclib.ServerProxy( xmlrpc_url ) print time.asctime(),"-- notify %s" % xmlrpc_url server.notify( shared.stripped_copy(load), Cpw ) return True # success except httplib.socket.error: pass except xmlrpclib.Fault, f: pass