| Server IP : 61.19.30.66 / Your IP : 216.73.216.15 Web Server : Apache/2.2.22 (Ubuntu) System : Linux klw 3.11.0-15-generic #25~precise1-Ubuntu SMP Thu Jan 30 17:39:31 UTC 2014 x86_64 User : www-data ( 33) PHP Version : 5.3.10-1ubuntu3.48 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : ON | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /usr/sbin/ |
Upload File : |
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# update-apt-xapian-index - Maintain a system-wide Xapian index of Debian
# package information
#
# Copyright (C) 2007--2010 Enrico Zini <enrico@debian.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#
# Main program body
#
# Minimal imports so we are always able to print command line help
from optparse import OptionParser
import sys
import os
import warnings
VERSION="0.44"
# Activate support for the CJK tokenizer
os.environ["XAPIAN_CJK_NGRAM"] = "1"
class Parser(OptionParser):
def __init__(self, *args, **kwargs):
OptionParser.__init__(self, *args, **kwargs)
def error(self, msg):
sys.stderr.write("%s: error: %s\n\n" % (self.get_prog_name(), msg))
self.print_help(sys.stderr)
sys.exit(2)
parser = Parser(usage="usage: %prog [options]",
version="%prog "+ VERSION,
description="Rebuild the Apt Xapian index")
parser.add_option("-q", "--quiet", action="store_true", help="quiet mode: only output fatal errors")
parser.add_option("-v", "--verbose", action="store_true", help="verbose mode")
parser.add_option("-f", "--force", action="store_true", help="force database rebuild even if it's already up to date")
parser.add_option("--pkgfile", action="append", help="do not use the APT cache, but the given Package file")
parser.add_option("--batch-mode", action="store_true", help="use progress reporting suitable from programatic parsing.")
parser.add_option("-u","--update", action="store_true", help="incremental update, reindexing only those packages whose version has changed since the last run")
(opts, args) = parser.parse_args()
# Rest of the imports here
import axi
import axi.indexer
#if opts.quiet: print "quiet"
#if opts.verbose: print "verbose"
#if opts.force: print "force"
# Instantiate the progress report
if opts.batch_mode:
quietapt = False
progress = axi.indexer.BatchProgress()
elif opts.quiet:
quietapt = True
progress = axi.indexer.SilentProgress()
warnings.filterwarnings("ignore","")
else:
quietapt = False
progress = axi.indexer.Progress()
if opts.verbose:
progress.is_verbose = True
# Create the indexer
indexer = axi.indexer.Indexer(progress, quietapt)
# Lock the session so that we prevent concurrent updates
try:
locked = indexer.lock()
except OSError, e:
import errno
if e.errno == errno.EACCES:
print >>sys.stderr, "You probably need to be root to do this."
sys.exit(1)
raise
if not locked:
indexer.slave()
sys.exit(0)
# Set up the indexer and check that we have something to do
if not indexer.setupIndexing(force=opts.force, system=opts.pkgfile is None):
sys.exit(0)
if opts.update:
# update only mode
indexer.incrementalUpdate()
else:
indexer.rebuild(opts.pkgfile)
sys.exit(0)