PanTilt  1.3.2
RoadNarrows Robotics Pan-Tilt Project
pantilt_console.window Class Reference

Window class supporting application. More...

Inheritance diagram for pantilt_console.window:

Public Member Functions

def __init__ (self, master=None, cnf={}, kw)
 Constructor. More...
 
def initData (self, kw)
 Initialize class state data. More...
 
def createWidgets (self)
 Create gui widgets with supporting data and show.
 
def createHeading (self)
 Create top gui heading.
 
def createLeftButtons (self)
 Create gui left hand side buttons.
 
def createCenterPanel (self)
 Create gui center panel.
 
def createRightButtons (self)
 Create gui right hand side buttons.
 
def createStatusBar (self)
 Create gui multi-line status bar at bottom of gui window.
 
def createButton (self, parent, text, imagefile, command, fg='black')
 Create button. More...
 
def clearSelect (self)
 Clear all select checkboxes.
 
def cbSelect (self)
 Checkbox change state callback.
 
def cbStartServices (self)
 Start selected services callback.
 
def cbStopServices (self)
 Stop selected services callback.
 
def cbRestartServices (self)
 Restart selected services callback.
 
def cbRefreshStatus (self)
 Refresh services status callback.
 
def cbSave (self)
 Save new settings callback.
 
def destroy (self)
 Destroy window callback.
 
def showSbInfo (self, text)
 Show information text on status bar. More...
 
def showSbError (self, text)
 Show error text on status bar. More...
 
def showSbOk (self, text)
 Show ok text on status bar. More...
 
def showSbResult (self, text, success)
 Show operation result on status bar. More...
 
def showSbStatus (self, text, status)
 Show service status result on status bar. More...
 
def setStatus (self, service, status)
 Set service status field. More...
 
def autoRefresh (self)
 
def refresh (self)
 Refresh status of all services.
 
def execStart (self, service)
 Execute 'service <service> start' subprocess. More...
 
def execStop (self, service)
 Execute 'service <service> stop' subprocess. More...
 
def execRestart (self, service)
 Execute 'service <service> restart' subprocess. More...
 
def execStatus (self, service)
 Execute 'service <service> status' subprocess. More...
 

Public Attributes

 m_imageLoader
 
 m_debug
 
 m_icons
 
 m_wBttn
 
 m_svcKeys
 
 m_svcDesc
 
 m_lock
 
 m_service
 
 m_wScrollBar
 
 m_wStatusBar
 

Detailed Description

Window class supporting application.

Definition at line 98 of file pantilt_console.py.

Constructor & Destructor Documentation

def pantilt_console.window.__init__ (   self,
  master = None,
  cnf = {},
  kw 
)

Constructor.

Parameters
masterWindow parent master widget.
cnfConfiguration dictionary.
kwKeyword options.

Definition at line 106 of file pantilt_console.py.

References pantilt_console.window.autoRefresh(), pantilt_console.window.createWidgets(), pantilt_console.window.initData(), pantilt_console.window.m_icons, and pantilt_console.window.m_imageLoader.

106  def __init__(self, master=None, cnf={}, **kw):
107  # intialize window data
108  kw = self.initData(kw)
109 
110  self.m_imageLoader = ImageLoader(py_pkg='Laelaps.images',
111  image_paths=imagePath)
112 
113  Frame.__init__(self, master=master, cnf=cnf, **kw)
114  self.master.title("Laelaps Init.d Console")
115 
116  self.m_icons['app_icon'] = \
117  self.m_imageLoader.loadImage("icons/LaelapsInitIcon.png")
118  if self.m_icons['app_icon'] is not None:
119  self.master.tk.call('wm', 'iconphoto', self.master._w,
120  self.m_icons['app_icon'])
121 
122  # craete and show widgets
123  self.createWidgets()
124 
125  self.grid(row=0, column=0, padx=5, pady=5)
126 
127  self.after(100, self.autoRefresh)
128 
def createWidgets(self)
Create gui widgets with supporting data and show.
def __init__(self, master=None, cnf={}, kw)
Constructor.
def initData(self, kw)
Initialize class state data.

Member Function Documentation

def pantilt_console.window.createButton (   self,
  parent,
  text,
  imagefile,
  command,
  fg = 'black' 
)

Create button.

Parameters
parentParent widget.
textButton text.
imagefileImage file name. None for no image.
commandCallback for button push.
fgForeground text color.
Returns
Button widget.

Definition at line 382 of file pantilt_console.py.

References pantilt_console.window.m_icons, and pantilt_console.window.m_wBttn.

Referenced by pantilt_console.window.createLeftButtons(), and pantilt_console.window.createRightButtons().

382  def createButton(self, parent, text, imagefile, command, fg='black'):
383  key = str.lower(text.replace("\n", "_"))
384  self.m_icons[key] = self.m_imageLoader.loadImage(imagefile)
385  w = Button(parent)
386  w['text'] = text
387  if self.m_icons[key]:
388  w['image'] = self.m_icons[key]
389  w['compound'] = LEFT
390  w['padx'] = 0
391  w['pady'] = 0
392  w['anchor'] = W
393  w['width'] = 105
394  else:
395  w['anchor'] = CENTER
396  w['width'] = 10
397  w['fg'] = fg
398  w['command'] = command
399  self.m_wBttn[key] = w
400  return self.m_wBttn[key]
401 
def createButton(self, parent, text, imagefile, command, fg='black')
Create button.
def pantilt_console.window.execRestart (   self,
  service 
)

Execute 'service <service> restart' subprocess.

Parameters
servcieService (key).
Returns
Returns True on success, False on failure.

Definition at line 647 of file pantilt_console.py.

Referenced by pantilt_console.window.cbRestartServices().

647  def execRestart(self, service):
648  s = ''
649  hasLock = self.m_lock.acquire()
650  try:
651  s = subprocess.check_output(["service", service, "restart"],
652  stderr=subprocess.STDOUT)
653  except subprocess.CalledProcessError, inst:
654  self.m_lock.release()
655  return False
656  self.m_lock.release()
657  if reDoneDone.search(s):
658  return True
659  elif reFailDone.search(s):
660  return True
661  else:
662  return False
663 
def execRestart(self, service)
Execute &#39;service <service> restart&#39; subprocess.
def pantilt_console.window.execStart (   self,
  service 
)

Execute 'service <service> start' subprocess.

Parameters
servcieService (key).
Returns
Returns True on success, False on failure.

Definition at line 603 of file pantilt_console.py.

Referenced by pantilt_console.window.cbStartServices().

603  def execStart(self, service):
604  s = ''
605  hasLock = self.m_lock.acquire()
606  try:
607  s = subprocess.check_output(["service", service, "start"],
608  stderr=subprocess.STDOUT)
609  except subprocess.CalledProcessError, inst:
610  self.m_lock.release()
611  return False
612  self.m_lock.release()
613  if reFail.search(s):
614  return False
615  else:
616  return True
617 
def execStart(self, service)
Execute &#39;service <service> start&#39; subprocess.
def pantilt_console.window.execStatus (   self,
  service 
)

Execute 'service <service> status' subprocess.

Parameters
servcieService (key).
Returns
Service status. One of: 'running' 'stopped' 'unknown'

Definition at line 671 of file pantilt_console.py.

Referenced by pantilt_console.window.cbRefreshStatus(), and pantilt_console.window.refresh().

671  def execStatus(self, service):
672  s = ''
673  hasLock = self.m_lock.acquire()
674  try:
675  s = subprocess.check_output(["service", service, "status"],
676  stderr=subprocess.STDOUT)
677  except subprocess.CalledProcessError, inst:
678  s = inst.output
679  self.m_lock.release()
680  if reRunning.search(s):
681  return ('running', s)
682  elif reNotRunning.search(s):
683  return ('stopped', s)
684  else:
685  return ('unknown', s)
686 
687 
688 # ------------------------------------------------------------------------------
689 # Exception Class usage
690 # ------------------------------------------------------------------------------
691 
def execStatus(self, service)
Execute &#39;service <service> status&#39; subprocess.
def pantilt_console.window.execStop (   self,
  service 
)

Execute 'service <service> stop' subprocess.

Parameters
servcieService (key).
Returns
Returns True on success, False on failure.

Definition at line 625 of file pantilt_console.py.

Referenced by pantilt_console.window.cbStopServices().

625  def execStop(self, service):
626  s = ''
627  hasLock = self.m_lock.acquire()
628  try:
629  s = subprocess.check_output(["service", service, "stop"],
630  stderr=subprocess.STDOUT)
631  except subprocess.CalledProcessError, inst:
632  self.m_lock.release()
633  return False
634  self.m_lock.release()
635  if reFail.search(s):
636  return False
637  else:
638  return True
639 
def execStop(self, service)
Execute &#39;service <service> stop&#39; subprocess.
def pantilt_console.window.initData (   self,
  kw 
)

Initialize class state data.

Any keywords for this application specific window that are not supported by the Frame Tkinter class must be removed.

Parameters
kwKeyword options.
Returns
Modified keywords sans this specific class.

Definition at line 139 of file pantilt_console.py.

References pantilt_console.window.m_debug, pantilt_console.window.m_icons, pantilt_console.window.m_lock, pantilt_console.window.m_svcDesc, pantilt_console.window.m_svcKeys, and pantilt_console.window.m_wBttn.

Referenced by pantilt_console.window.__init__().

139  def initData(self, kw):
140  self.m_debug = False # default debug level
141  self.m_icons = {} # must keep loaded icons referenced
142  self.m_wBttn = {} # button widgets
143  self.m_svcKeys = [
144  'laelaps_bsproxy', 'laelaps_roscore', 'laelaps_control',
145  'laelaps_xbox', 'laelaps_teleop']
146  self.m_svcDesc = {
147  'laelaps_bsproxy': 'BotSense Proxy Server',
148  'laelaps_roscore': 'ROS Master, Parameter Server, rosout logging node',
149  'laelaps_control': 'Laelaps Control ROS node',
150  'laelaps_xbox': 'HID Xbox360 daemon / ROS node',
151  'laelaps_teleop': 'Laelaps Teleoperation ROS node'}
152  self.m_lock = threading.Lock()
153 
154  if kw.has_key('debug'):
155  self.m_debug = kw['debug']
156  del kw['debug']
157 
158  # variables only used for debugging
159  if self.m_debug:
160  pass
161 
162  return kw
163 
def initData(self, kw)
Initialize class state data.
def pantilt_console.window.setStatus (   self,
  service,
  status 
)

Set service status field.

Parameters
servcieService (key).
statusService status. One of: 'running' 'stopped' 'unknown'

Definition at line 580 of file pantilt_console.py.

References pantilt_console.window.autoRefresh(), pantilt_console.window.m_service, and pantilt_console.window.refresh().

Referenced by pantilt_console.window.cbRefreshStatus(), and pantilt_console.window.refresh().

580  def setStatus(self, service, status):
581  self.m_service[service]['status'].set(status)
582  self.m_service[service]['wstatus']['fg'] = statusText[status]
583 
def setStatus(self, service, status)
Set service status field.
def pantilt_console.window.showSbError (   self,
  text 
)

Show error text on status bar.

Parameters
textError text string.

Definition at line 516 of file pantilt_console.py.

References pantilt_console.window.m_wStatusBar.

Referenced by pantilt_console.window.showSbResult(), and pantilt_console.window.showSbStatus().

516  def showSbError(self, text):
517  self.m_wStatusBar["state"] = "normal"
518  idx0 = self.m_wStatusBar.index(INSERT)
519  self.m_wStatusBar.insert(END, text)
520  idx1 = self.m_wStatusBar.index(INSERT)
521  self.m_wStatusBar.tag_add("err", idx0, idx1)
522  self.m_wStatusBar.tag_config("err", foreground=fgColors['error'])
523  self.m_wStatusBar.see(END)
524  self.m_wStatusBar["state"] = "disabled"
525 
def showSbError(self, text)
Show error text on status bar.
def pantilt_console.window.showSbInfo (   self,
  text 
)

Show information text on status bar.

Parameters
textInfo text string.

Definition at line 501 of file pantilt_console.py.

References pantilt_console.window.m_wStatusBar.

Referenced by pantilt_console.window.cbRefreshStatus(), pantilt_console.window.cbRestartServices(), pantilt_console.window.cbSave(), pantilt_console.window.cbStartServices(), pantilt_console.window.cbStopServices(), and pantilt_console.window.showSbStatus().

501  def showSbInfo(self, text):
502  self.m_wStatusBar["state"] = "normal"
503  idx0 = self.m_wStatusBar.index(INSERT)
504  self.m_wStatusBar.insert(END, text)
505  idx1 = self.m_wStatusBar.index(INSERT)
506  self.m_wStatusBar.tag_add("norm", idx0, idx1)
507  self.m_wStatusBar.tag_config("norm", foreground=fgColors['normal'])
508  self.m_wStatusBar.see(END)
509  self.m_wStatusBar["state"] = "disabled"
510 
def showSbInfo(self, text)
Show information text on status bar.
def pantilt_console.window.showSbOk (   self,
  text 
)

Show ok text on status bar.

Parameters
textOk text string.

Definition at line 531 of file pantilt_console.py.

References pantilt_console.window.m_wStatusBar.

Referenced by pantilt_console.window.showSbResult(), and pantilt_console.window.showSbStatus().

531  def showSbOk(self, text):
532  self.m_wStatusBar["state"] = "normal"
533  idx0 = self.m_wStatusBar.index(INSERT)
534  self.m_wStatusBar.insert(END, text)
535  idx1 = self.m_wStatusBar.index(INSERT)
536  self.m_wStatusBar.tag_add("ok", idx0, idx1)
537  self.m_wStatusBar.tag_config("ok", foreground=fgColors['ok'])
538  self.m_wStatusBar.see(END)
539  self.m_wStatusBar["state"] = "disabled"
540 
def showSbOk(self, text)
Show ok text on status bar.
def pantilt_console.window.showSbResult (   self,
  text,
  success 
)

Show operation result on status bar.

Parameters
textPrefix text already displayed on current status bar line.
successOperation was [not] a success.

Definition at line 547 of file pantilt_console.py.

References pantilt_console.window.m_wStatusBar, pantilt_console.window.showSbError(), and pantilt_console.window.showSbOk().

Referenced by pantilt_console.window.cbRestartServices(), pantilt_console.window.cbStartServices(), and pantilt_console.window.cbStopServices().

547  def showSbResult(self, text, success):
548  n = self.m_wStatusBar['width'] - len(text)
549  if success:
550  rc = '[ok]'
551  self.showSbOk("%*s\n" % (n, rc))
552  else:
553  rc = '[failed]'
554  self.showSbError("%*s\n" % (n, rc))
555 
def showSbOk(self, text)
Show ok text on status bar.
def showSbResult(self, text, success)
Show operation result on status bar.
def showSbError(self, text)
Show error text on status bar.
def pantilt_console.window.showSbStatus (   self,
  text,
  status 
)

Show service status result on status bar.

Parameters
textPrefix text already displayed on current status bar line.
statusService status. One of: 'running' 'stopped' 'unknown'

Definition at line 562 of file pantilt_console.py.

References pantilt_console.window.m_wStatusBar, pantilt_console.window.showSbError(), pantilt_console.window.showSbInfo(), and pantilt_console.window.showSbOk().

Referenced by pantilt_console.window.cbRefreshStatus().

562  def showSbStatus(self, text, status):
563  n = self.m_wStatusBar['width'] - len(text)
564  if status == 'running':
565  rc = '[running]'
566  self.showSbOk("%*s\n" % (n, rc))
567  elif status == 'stopped':
568  rc = '[stopped]'
569  self.showSbError("%*s\n" % (n, rc))
570  else:
571  rc = '[unknown]'
572  self.showSbInfo("%*s\n" % (n, rc))
573 
def showSbOk(self, text)
Show ok text on status bar.
def showSbInfo(self, text)
Show information text on status bar.
def showSbStatus(self, text, status)
Show service status result on status bar.
def showSbError(self, text)
Show error text on status bar.

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