Ejemplo n.º 1
0
 def setModes(self, modes={}, expected={}):
     """ modes is a dictionary like {'MODE_P':[period]} """
     print(type(self).__name__, 'setModes', self.getModel(), modes)
     if pta.utils.modes_to_string(expected) == pta.utils.modes_to_string(
             modes):
         self.logger().hide()
     for i, m in enumerate(('MODE_P', 'MODE_R', 'MODE_A')):
         for j in range(3):
             t = self.table.item(i, j)
             if not t:
                 t = Qt.QTableWidgetItem('')
                 self.table.setItem(i, j, t)
             if m in modes and j < len(modes[m]):
                 t.setText(str(modes[m][j]))
                 #print((i,j,modes[m][j]))
             else:
                 t.setText('')
     if 'archiver' in modes:
         try:
             db = self.reader.get_database()
             attr_id = modes.get('ID')
             date = db.get_table_updates(
                 db.get_table_name(attr_id)).values()[0]
             if date < time.time() - 600:
                 date = '<b>%s</b>' % fun.time2str(date)
             else:
                 date = fun.time2str(date)
             dev = modes['archiver']
             self.archiver.setText('%s(%s,%s)' % (dev, attr_id, date))
             self.archiver.setContextCallbacks({
                 'Test Device':
                 fun.partial(showTestDevice, device=dev),
                 'Show Info':
                 fun.partial(showDeviceInfo, device=dev),
                 'Show Logs':
                 self.logger().show,
                 'Refresh':
                 fun.partial(self.setModel, model=self.getModel()),
             })
         except:
             traceback.print_exc()
     else:
         self.archiver.setText('...')
         self.archiver.setContextCallbacks({})
     Qt.QApplication.instance().restoreOverrideCursor()
     return
Ejemplo n.º 2
0
 def setModes(self,modes={},expected={}):
   """ modes is a dictionary like {'MODE_P':[period]} """
   print(type(self).__name__,'setModes',self.getModel(),modes)
   if modes_to_string(expected) == modes_to_string(modes):
     self.logger().hide()    
   for i,m in enumerate(('MODE_P','MODE_R','MODE_A')):
     for j in range(3):
       t = self.table.item(i,j)
       if not t: 
         t = Qt.QTableWidgetItem('')
         self.table.setItem(i,j,t)
       if m in modes and j<len(modes[m]):
         t.setText(str(modes[m][j]))
         #print((i,j,modes[m][j]))
       else:
         t.setText('')
   if 'archiver' in modes:
     try:
       db = self.reader.get_database()
       attr_id = modes.get('ID')
       date = db.get_table_updates(db.get_table_name(attr_id)).values()[0]
       if date<time.time()-600: date = '<b>%s</b>' % fun.time2str(date)
       else: date = fun.time2str(date)
       dev = modes['archiver']
       self.archiver.setText('%s(%s,%s)'%(dev,attr_id,date))
       self.archiver.setContextCallbacks({
         'Test Device':fun.partial(showTestDevice,device=dev),
         'Show Info':fun.partial(showDeviceInfo,device=dev),
         'Show Logs':self.logger().show,
         'Refresh':fun.partial(self.setModel,model=self.getModel()),
         })
     except:
       traceback.print_exc()
   else:
      self.archiver.setText('...')
      self.archiver.setContextCallbacks({})
   Qt.QApplication.instance().restoreOverrideCursor()
   return
Ejemplo n.º 3
0
 report = open(filename,'w')
 def add2lines(text,trace=True):
     #print text
     lines.append(text)
     #report.write(text)
 #add2lines('<html><body>')
 
 index = web.title('Index',4) + '\n<ul>'
 lines = []
 totals = {}
 
     
 add2lines('<br>Script called like: archiving_report.py %s<br>' % (' '.join(sys.argv)))
 add2lines(web.separator)
 add2lines('<br>'+'Archiving Status Report at %s'%time.ctime(tstart)+', generated in %d seconds <br>'%(int(time.time()-tstart)))
 add2lines(web.dict2dict2table(summary,keys=['','active','dedicated','archivers','down','idle','up'],formatter=fun.partial(summarize,NMAX=0)))
 add2lines(web.em('active,dedicated refers to attributes status'))
 add2lines(web.link(web.em('up,down,idle refers to archivers status'),web.iurl('Archivers Status')))
 add2lines(web.separator)
 
 def conf2file(chkfile,vals):
     print 'Writing check values to %s ...' % chkfile
     try:
         f = open(chkfile,'w')
         f.write('\t'.join(CHECK_KEYS)+'\n')
         f.write('\t'.join([str(vals[k]) for k in CHECK_KEYS]) + '\n')
         f.close()
     except:
         print 'Unable to write %s: %s' % (chkfile,traceback.format_exc())
         
 #Adding Summaries for each Schema