Package backend :: Package server :: Package rhnServer :: Module search_notify
[hide private]
[frames] | no frames]

Source Code for Module backend.server.rhnServer.search_notify

 1  # 
 2  # Copyright (c) 2008--2016 Red Hat, Inc. 
 3  # 
 4  # This software is licensed to you under the GNU General Public License, 
 5  # version 2 (GPLv2). There is NO WARRANTY for this software, express or 
 6  # implied, including the implied warranties of MERCHANTABILITY or FITNESS 
 7  # FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 
 8  # along with this software; if not, see 
 9  # http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. 
10  # 
11  # Red Hat trademarks are not licensed under GPLv2. No permission is 
12  # granted to use or replicate Red Hat trademarks that are incorporated 
13  # in this software or its documentation. 
14  # 
15  # Sends notification to search-server that it should update server index 
16  # 
17   
18  import sys 
19   
20  try: 
21      #  python 2 
22      import xmlrpclib 
23  except ImportError: 
24      #  python3 
25      import xmlrpc.client as xmlrpclib 
26  from spacewalk.common.rhnLog import log_error 
27   
28   
29 -class SearchNotify:
30
31 - def __init__(self, host="127.0.0.1", port="2828"):
32 self.addr = "http://%s:%s" % (host, port)
33
34 - def notify(self, indexName="server"):
35 try: 36 client = xmlrpclib.ServerProxy(self.addr) 37 result = client.admin.updateIndex(indexName) 38 except Exception: 39 e = sys.exc_info()[1] 40 log_error("Failed to notify search service located at %s to update %s indexes" 41 % (self.addr, indexName), e) 42 return False 43 return result
44 45 if __name__ == "__main__": 46 search = SearchNotify() 47 result = search.notify() 48 print("search.notify() = %s" % (result)) 49