Back to index

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

List of all members.

Public Member Functions

def __init__
def run
def logRuntime

Public Attributes

 argv
 def_values
 parser
 args

Detailed Description

Definition at line 95 of file __init__.py.


Constructor & Destructor Documentation

def MoinMoin.script.Script.__init__ (   self,
  cmd,
  usage,
  argv = None,
  def_values = None 
)

Definition at line 96 of file __init__.py.

00096 
00097     def __init__(self, cmd, usage, argv=None, def_values=None):
00098         #print "argv:", argv, "def_values:", repr(def_values)
00099         if argv is None:
00100             self.argv = sys.argv[1:]
00101         else:
00102             self.argv = argv
00103         self.def_values = def_values
00104 
00105         global _start_time
00106         _start_time = time.clock()
00107 
00108         import optparse
00109         from MoinMoin import version
00110 
00111         rev = "%s %s [%s]" % (version.project, version.release, version.revision)
00112         sys.argv[0] = cmd
00113 
00114         self.parser = optparse.OptionParser(
00115             usage="%(cmd)s [command] %(usage)s" % {'cmd': os.path.basename(sys.argv[0]), 'usage': usage, },
00116             version=rev, add_help_option=False)
00117         self.parser.allow_interspersed_args = False
00118         if def_values:
00119             self.parser.set_defaults(**def_values.__dict__)
00120         self.parser.add_option(
00121             "-q", "--quiet",
00122             action="store_true", dest="quiet",
00123             help="Be quiet (no informational messages)"
00124         )
00125         self.parser.add_option(
00126             "--show-timing",
00127             action="store_true", dest="show_timing", default=False,
00128             help="Show timing values [default: False]"
00129         )


Member Function Documentation

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:

def MoinMoin.script.Script.run (   self,
  showtime = 1 
)
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.


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