Back to index

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

List of all members.

Public Member Functions

def __init__
def mainloop
def init_request
def run
def logRuntime

Public Attributes

 request
 argv
 def_values
 parser
 args

Detailed Description

Definition at line 17 of file standalone.py.


Constructor & Destructor Documentation

def MoinMoin.script.server.standalone.PluginScript.__init__ (   self,
  argv,
  def_values 
)

Reimplemented from MoinMoin.script.MoinScript.

Definition at line 18 of file standalone.py.

00018 
00019     def __init__(self, argv, def_values):
00020         MoinScript.__init__(self, argv, def_values)
00021         self.parser.add_option(
00022             "--docs", dest="docs",
00023             help="Set the documents directory. Default: use builtin MoinMoin/web/static/htdocs"
00024         )
00025         self.parser.add_option(
00026             "--user", dest="user",
00027             help="Set the user to change to. UNIX only. Default: Don't change"
00028         )
00029         self.parser.add_option(
00030             "--group", dest="group",
00031             help="Set the group to change to. UNIX only. Default: Don't change"
00032         )
00033         self.parser.add_option(
00034             "--port", dest="port", type="int",
00035             help="Set the port to listen on. Default: 8080"
00036         )
00037         self.parser.add_option(
00038             "--hostname", "--interface", dest="hostname",
00039             help="Set the ip/hostname to listen on. Use \"\" for all interfaces. Default: localhost"
00040         )
00041         self.parser.add_option(
00042             "--start", dest="start", action="store_true",
00043             help="Start server in background."
00044         )
00045         self.parser.add_option(
00046             "--stop", dest="stop", action="store_true",
00047             help="Stop server in background."
00048         )
00049         self.parser.add_option(
00050             "--pidfile", dest="pidfile",
00051             help="Set file to store pid of moin daemon in. Default: moin.pid"
00052         )
00053         self.parser.add_option(
00054             "--debug", dest="debug",
00055             help="Debug mode of server. off: no debugging (default), web: for browser based debugging, external: for using an external debugger."
00056         )


Member Function Documentation

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 57 of file standalone.py.

00057 
00058     def mainloop(self):
00059         # we don't expect non-option arguments
00060         if self.args:
00061             self.parser.error("incorrect number of arguments")
00062 
00063         pidfile = "moin.pid"
00064         if self.options.pidfile:
00065             pidfile = self.options.pidfile
00066 
00067         if self.options.stop:
00068             try:
00069                 pids = open(pidfile, "r").read()
00070             except IOError:
00071                 print "pid file not found (server not running?)"
00072             else:
00073                 try:
00074                     os.kill(int(pids), signal.SIGTERM)
00075                 except OSError:
00076                     print "kill failed (server not running?)"
00077             os.remove(pidfile)
00078         else:
00079             try:
00080                 if self.options.config_dir:
00081                     sys.path.insert(0, self.options.config_dir)
00082                 from wikiserverconfig import Config
00083             except ImportError, err:
00084                 if 'wikiserverconfig' in str(err):
00085                     # we are unable to import from wikiserverconfig module
00086                     Config = DefaultConfig
00087                 else:
00088                     # some other import went wrong
00089                     raise
00090 
00091             # intialize some defaults if missing
00092             kwargs = {}
00093             for option in ('user', 'group',
00094                            'hostname', 'port',
00095                            'threaded', 'processes',
00096                            'debug', 'use_evalex',
00097                            'use_reloader', 'extra_files', 'reloader_interval',
00098                            'docs', 'static_files', ):
00099                 if hasattr(Config, option):
00100                     kwargs[option] = getattr(Config, option)
00101                 else:
00102                     # usually inheriting from DefaultConfig should make this superfluous,
00103                     # but who knows what users write into their config...
00104                     kwargs[option] = getattr(DefaultConfig, option)
00105 
00106             # override config settings with cmdline options:
00107             if self.options.docs:
00108                 kwargs['docs'] = self.options.docs
00109             if self.options.user:
00110                 kwargs['user'] = self.options.user
00111             if self.options.group:
00112                 kwargs['group'] = self.options.group
00113             if self.options.debug:
00114                 kwargs['debug'] = self.options.debug
00115 
00116             if self.options.hostname is not None: # needs to work for "" value also
00117                 kwargs['hostname'] = self.options.hostname
00118             if self.options.port:
00119                 kwargs['port'] = self.options.port
00120 
00121             if self.options.start:
00122                 daemon = Daemon('moin', pidfile, run_server, **kwargs)
00123                 daemon.do_start()
00124             else:
00125                 run_server(**kwargs)
00126 

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 113 of file __init__.py.

Definition at line 178 of file __init__.py.


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