Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes
MoinMoin.script.index.build.PluginScript Class Reference
Inheritance diagram for MoinMoin.script.index.build.PluginScript:
Inheritance graph
[legend]
Collaboration diagram for MoinMoin.script.index.build.PluginScript:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def command
def mainloop
def init_request
def run
def logRuntime

Public Attributes

 files
 request
 argv
 def_values
 parser
 args

Detailed Description

Xapian index build script class 

Definition at line 84 of file build.py.


Member Function Documentation

Definition at line 87 of file build.py.

00087 
00088     def command(self):
00089         from MoinMoin.search.Xapian import XapianIndex
00090         mode = self.options.mode
00091         if mode in ('rebuild', 'buildnewindex'):
00092             # rebuilding the DB into a new index directory, so the rebuild
00093             # process does not interfere with the currently in-use DB
00094             idx_mode, idx_name = 'add', 'index.new'
00095         elif mode in ('add', 'update'):
00096             # update/add in-place
00097             idx_mode, idx_name = mode, 'index'
00098         elif mode == 'usenewindex':
00099             pass # nothing todo
00100         else:
00101             pass # XXX give error msg about invalid mode
00102 
00103         if mode != 'usenewindex':
00104             idx = XapianIndex(self.request, name=idx_name)
00105             idx.indexPages(self.files, idx_mode)
00106 
00107         if mode in ('rebuild', 'usenewindex'):
00108             # 'rebuild' is still a bit dirty, because just killing old index will
00109             # fail currently running searches. Thus, maybe do this in a time
00110             # with litte wiki activity or better use 'buildnewindex' and
00111             # 'usenewindex' (see above).
00112             # XXX code here assumes that idx.db is a directory
00113             # TODO improve this with xapian stub DBs
00114             idx_old = XapianIndex(self.request, name='index').db
00115             idx_new = XapianIndex(self.request, name='index.new').db
00116             try:
00117                 shutil.rmtree(idx_old)
00118             except OSError, err:
00119                 if err.errno != errno.ENOENT: # ignore it if we have no current index
00120                     raise
00121             os.rename(idx_new, idx_old)
00122 

Here is the caller graph for this function:

def MoinMoin.script.MoinScript.init_request (   self) [inherited]
create request 

Definition at line 174 of file __init__.py.

00174 
00175     def init_request(self):
00176         """ create request """
00177         from MoinMoin.web.contexts import ScriptContext
00178         url = self.options.wiki_url or None
00179         self.request = ScriptContext(url, self.options.page)

Here is the caller graph for this function:

def MoinMoin.script.Script.logRuntime (   self) [inherited]
Print the total command run time. 

Definition at line 148 of file __init__.py.

00148 
00149     def logRuntime(self):
00150         """ Print the total command run time. """
00151         if self.options.show_timing:
00152             log("Needed %.3f secs." % (time.clock() - _start_time, ))
00153 

Here is the call graph for this function:

Reimplemented from MoinMoin.script.MoinScript.

Definition at line 75 of file build.py.

00075 
00076     def mainloop(self):
00077         self.init_request()
00078         # Do we have additional files to index?
00079         if self.options.file_list:
00080             self.files = file(self.options.file_list)
00081         else:
00082             self.files = None
00083         self.command()

Here is the call graph for this function:

def MoinMoin.script.Script.run (   self,
  showtime = 1 
) [inherited]
Run the main function of a command. 

Definition at line 130 of file __init__.py.

00130 
00131     def run(self, showtime=1):
00132         """ Run the main function of a command. """
00133         global flag_quiet
00134         try:
00135             try:
00136                 self.options, self.args = self.parser.parse_args(self.argv)
00137                 flag_quiet = self.options.quiet
00138                 # ToDo check if we need to initialize request (self.init_request())
00139                 self.mainloop()
00140             except KeyboardInterrupt:
00141                 log("*** Interrupted by user!")
00142             except SystemExit:
00143                 showtime = 0
00144                 raise
00145         finally:
00146             if showtime:
00147                 self.logRuntime()

Here is the caller graph for this function:


Member Data Documentation

Definition at line 135 of file __init__.py.

Definition at line 102 of file __init__.py.

Definition at line 79 of file build.py.

Definition at line 113 of file __init__.py.

Definition at line 178 of file __init__.py.


The documentation for this class was generated from the following file: