{{{ """ MoinMoin macro to display node status via MySQL query Jason McArthur (hack) """ from MoinMoin import config, wikiutil import re def execute(macro, text): import MySQLdb gkey = '' pHost = '' pUser = '' pPass = '' pDb = 'wnmap' pPage = "SELECT status, streetAddress, nodeName, lat, lng FROM nodes WHERE nodeName='%s'" % macro.formatter.page.page_name db = MySQLdb.connect (host = pHost,user = pUser,db = pDb) c = db.cursor() c.execute(pPage) result = c.fetchone() a = str(result[0]) b = str(result[1]) c = str(result[2]) d = str(result[3]) e = str(result[4]) db.close() if a == '2': return u'
  
  



  Coordinates:
  %s %s


  Active
  Down/Potential node
  Inactive

' % (c, d, e, gkey, b, d, e) if a == '1': return u'
  
  



  Coordinates:
  %s %s


  Active
  Down/Potential node
  Inactive
' % (c, d, e, gkey, b, d, e) if a == '0': return u'
  
  



  Coordinates:
  %s %s


  Active
  Down/Potential node
  Inactive
' % (c, d, e, gkey, b, d, e) if a == '': return }}}