Print this page
3166 feed generation needs performance improvement
3306 feed returns invalid last-modified header


  13 #
  14 # When distributing Covered Code, include this CDDL HEADER in each
  15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16 # If applicable, add the following below this CDDL HEADER, with the
  17 # fields enclosed by brackets "[]" replaced with your own identifying
  18 # information: Portions Copyright [yyyy] [name of copyright owner]
  19 #
  20 # CDDL HEADER END
  21 #
  22 # Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  23 # Use is subject to license terms.
  24 
  25 import subprocess
  26 import threading
  27 import signal
  28 import os
  29 import sys
  30 import cherrypy
  31 
  32 import pkg.catalog as catalog

  33 import pkg.indexer as indexer
  34 import pkg.server.query_engine as query_e
  35 
  36 from pkg.misc import SERVER_DEFAULT_MEM_USE_KB
  37 from pkg.misc import emsg
  38 
  39 class ServerCatalog(catalog.Catalog):
  40         """The catalog information which is only needed by the server."""
  41 
  42         def __init__(self, cat_root, authority = None, pkg_root = None,
  43             read_only = False, index_root = None, repo_root = None,
  44             rebuild = True):
  45 
  46                 self.index_root = index_root
  47                 self.repo_root = repo_root
  48 
  49                 # The update_handle lock protects the update_handle variable.
  50                 # This allows update_handle to be checked and acted on in a
  51                 # consistent step, preventing the dropping of needed updates.
  52                 # The check at the top of refresh index should always be done


 243 
 244                 for f in fmri_list:
 245                         mfst_path = os.path.join(self.pkg_root,
 246                                                  f.get_dir_path())
 247                         fmri_manifest_list.append((f, mfst_path))
 248 
 249                 if fmri_manifest_list:
 250                         index_inst = indexer.Indexer(self.index_root,
 251                             SERVER_DEFAULT_MEM_USE_KB)
 252                         index_inst.server_update_index(fmri_manifest_list)
 253 
 254         def search(self, token):
 255                 """Search through the search database for 'token'.  Return a
 256                 list of token type / fmri pairs."""
 257                 assert self.index_root
 258                 if not self.query_engine:
 259                         self.query_engine = \
 260                             query_e.ServerQueryEngine(self.index_root)
 261                 query = query_e.Query(token, case_sensitive=False)
 262                 return self.query_engine.search(query)



















  13 #
  14 # When distributing Covered Code, include this CDDL HEADER in each
  15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16 # If applicable, add the following below this CDDL HEADER, with the
  17 # fields enclosed by brackets "[]" replaced with your own identifying
  18 # information: Portions Copyright [yyyy] [name of copyright owner]
  19 #
  20 # CDDL HEADER END
  21 #
  22 # Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  23 # Use is subject to license terms.
  24 
  25 import subprocess
  26 import threading
  27 import signal
  28 import os
  29 import sys
  30 import cherrypy
  31 
  32 import pkg.catalog as catalog
  33 import pkg.fmri as fmri
  34 import pkg.indexer as indexer
  35 import pkg.server.query_engine as query_e
  36 
  37 from pkg.misc import SERVER_DEFAULT_MEM_USE_KB
  38 from pkg.misc import emsg
  39 
  40 class ServerCatalog(catalog.Catalog):
  41         """The catalog information which is only needed by the server."""
  42 
  43         def __init__(self, cat_root, authority = None, pkg_root = None,
  44             read_only = False, index_root = None, repo_root = None,
  45             rebuild = True):
  46 
  47                 self.index_root = index_root
  48                 self.repo_root = repo_root
  49 
  50                 # The update_handle lock protects the update_handle variable.
  51                 # This allows update_handle to be checked and acted on in a
  52                 # consistent step, preventing the dropping of needed updates.
  53                 # The check at the top of refresh index should always be done


 244 
 245                 for f in fmri_list:
 246                         mfst_path = os.path.join(self.pkg_root,
 247                                                  f.get_dir_path())
 248                         fmri_manifest_list.append((f, mfst_path))
 249 
 250                 if fmri_manifest_list:
 251                         index_inst = indexer.Indexer(self.index_root,
 252                             SERVER_DEFAULT_MEM_USE_KB)
 253                         index_inst.server_update_index(fmri_manifest_list)
 254 
 255         def search(self, token):
 256                 """Search through the search database for 'token'.  Return a
 257                 list of token type / fmri pairs."""
 258                 assert self.index_root
 259                 if not self.query_engine:
 260                         self.query_engine = \
 261                             query_e.ServerQueryEngine(self.index_root)
 262                 query = query_e.Query(token, case_sensitive=False)
 263                 return self.query_engine.search(query)
 264 
 265         @staticmethod
 266         def read_catalog(catalog, dir, auth=None):
 267                 """Read the catalog file in "dir" and combine it with the
 268                 existing data in "catalog"."""
 269 
 270                 catf = file(os.path.join(dir, "catalog"))
 271                 for line in catf:
 272                         if not line.startswith("V pkg") and \
 273                             not line.startswith("C pkg"):
 274                                 continue
 275 
 276                         f = fmri.PkgFmri(line[7:])
 277                         ServerCatalog.cache_fmri(catalog, f, auth)
 278 
 279                 catf.close()
 280