Laelaps  2.3.5
RoadNarrows Robotics Small Outdoor Mobile Robot Project
laelaps_sane.application Class Reference

Laelaps diagnositcs application class. More...

Public Member Functions

def __init__ (self)
 Constructor.
 
def printUsageErr (self, emsg)
 Print usage error. More...
 
def printUsage (self)
 Print Command-Line Usage Message. More...
 
def getOptions (self, argv=None, kwargs)
 Get command-line options. More...
 
def run (self, argv=None, kwargs)
 Run application. More...
 

Public Attributes

 m_win
 
 kwargs
 

Detailed Description

Laelaps diagnositcs application class.

Definition at line 217 of file laelaps_sane.py.

Member Function Documentation

def laelaps_sane.application.getOptions (   self,
  argv = None,
  kwargs 
)

Get command-line options.

Parameters
argvArgument list. If not None, then overrides command-line arguments.
[out]kwargsKeyword argument list.
Returns
Parsed keyword arguments.

Definition at line 267 of file laelaps_sane.py.

References laelaps_sane.application._Argv0, laelaps_diag.application._Argv0, laelaps_init.application._Argv0, laelaps_sane.application.printUsage(), laelaps_diag.application.printUsage(), laelaps_init.application.printUsage(), laelaps_sane.application.printUsageErr(), laelaps_diag.application.printUsageErr(), and laelaps_init.application.printUsageErr().

Referenced by laelaps_sane.application.run(), laelaps_speed.application.run(), and laelaps_tune_motors.application.run().

267  def getOptions(self, argv=None, **kwargs):
268  if argv is None:
269  argv = sys.argv
270 
271  self._Argv0 = os.path.basename(kwargs.get('argv0', __file__))
272 
273  # defaults
274  kwargs['debug'] = False
275  kwargs['subsys'] = []
276 
277  # parse command-line options
278  try:
279  opts, args = getopt.getopt(argv[1:], "?h",
280  ['help', ''])
281  except getopt.error, msg:
282  raise usage(msg)
283  for opt, optarg in opts:
284  if opt in ('-h', '--help', '-?'):
285  self.printUsage()
286  sys.exit(0)
287 
288  if len(args) < 1:
289  self.printUsageErr("No subsystems specified.")
290  sys.exit(128)
291 
292  for subsys in args:
293  if subsys in SaneSubSys:
294  kwargs['subsys'] += [subsys]
295  else:
296  self.printUsageErr("%s: Unknown/unsupported subsystem." % (subsys))
297  sys.exit(128)
298 
299  return kwargs
300 
def printUsage(self)
Print Command-Line Usage Message.
Unit test command-line exception class.
def getOptions(self, argv=None, kwargs)
Get command-line options.
def printUsageErr(self, emsg)
Print usage error.
def laelaps_sane.application.printUsage (   self)

Print Command-Line Usage Message.

Definition at line 239 of file laelaps_sane.py.

References laelaps_sane.application._Argv0, laelaps_diag.application._Argv0, and laelaps_init.application._Argv0.

Referenced by laelaps_sane.application.getOptions(), laelaps_speed.application.getOptions(), and laelaps_tune_motors.application.getOptions().

239  def printUsage(self):
240  print \
241 """
242 usage: %s [OPTIONS] SUBSYS [SUBSYS ...]
243  %s --help
244 
245 Laelaps sanity.
246 
247 Options and arguments:
248 -h, --help : Display this help and exit.
249 
250 SUBSYS : Laelaps subsystem. One of: motors
251  motors - Motors and motor controllers
252 
253 Exit Status:
254  On success, 0. An exit status of 128 indicates usage
255  error.
256 """ % (self._Argv0, self._Argv0)
257 
def printUsage(self)
Print Command-Line Usage Message.
def laelaps_sane.application.printUsageErr (   self,
  emsg 
)

Print usage error.

Parameters
emsgError message string.

Definition at line 231 of file laelaps_sane.py.

References laelaps_sane.application._Argv0, laelaps_diag.application._Argv0, and laelaps_init.application._Argv0.

Referenced by laelaps_sane.application.getOptions(), and laelaps_speed.application.getOptions().

231  def printUsageErr(self, emsg):
232  if emsg:
233  print "%s: Error: %s" % (self._Argv0, emsg)
234  else:
235  print "%s: Error" % (self._Argv0)
236  print "Try '%s --help' for more information." % (self._Argv0)
237 
def printUsageErr(self, emsg)
Print usage error.
def laelaps_sane.application.run (   self,
  argv = None,
  kwargs 
)

Run application.

Parameters
argvOptional argument list to override command-line arguments.
kwargsOptional keyword argument list.
Returns
Exit code.

Definition at line 309 of file laelaps_sane.py.

References laelaps_sane.application.getOptions(), laelaps_diag.application.getOptions(), laelaps_init.application.getOptions(), laelaps_sane.Sanity.kwargs, laelaps_diag.DiagMotors.kwargs, laelaps_sane.application.kwargs, laelaps_diag.DiagToFs.kwargs, laelaps_diag.DiagImu.kwargs, laelaps_diag.DiagWatchdog.kwargs, and laelaps_diag.application.kwargs.

309  def run(self, argv=None, **kwargs):
310 
311  # parse command-line options and arguments
312  try:
313  self.kwargs = self.getOptions(argv, **kwargs)
314  except usage, e:
315  print e.msg
316  return 128
317 
318  sane = Sanity(self.kwargs)
319 
320  tf = sane.run()
321 
322  if tf:
323  return 0
324  else:
325  return 256
326 
327 
328 # ------------------------------------------------------------------------------
329 # main
330 # ------------------------------------------------------------------------------
def run(self, argv=None, kwargs)
Run application.
def getOptions(self, argv=None, kwargs)
Get command-line options.

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