def resetModes(self):
     self.logger().show()
     try:
         attr = self.getModel()
         schema = self.getSchema()
         print('%s: resetModes(%s)' % (fun.time2str(), attr))
         qm = Qt.QMessageBox(Qt.QMessageBox.Warning, 'Confirmation',
                             '%s archiving will be stopped' % attr,
                             Qt.QMessageBox.Ok | Qt.QMessageBox.Cancel)
         r = qm.exec_()
         if r == Qt.QMessageBox.Ok:
             if not self.api:
                 self.api = pta.api(self.getSchema().lower(),
                                    logger=self.logger())
             self.api.log = self.logger()
             #self.emit(Qt.SIGNAL('archive'),attr,modes)
             Qt.QApplication.instance().setOverrideCursor(
                 Qt.QCursor(Qt.Qt.WaitCursor))
             thr = threading.Thread(target=self.startArchiving,
                                    args=(attr, {}))
             QLoggerDialog._threads = filter(Thread.is_alive,
                                             self.threads()) + [thr]
             thr.start()
         else:
             self.logger().hide()
     except:
         traceback.print_exc()
     print('%s: resetModes(...): running!' % (fun.time2str()))
 def setModel(self, model):
     model = self.getReader().get_attribute_alias(model)
     model = re.sub('\[([0-9]+)\]', '', model.lower())
     print('QArchivingMode.setModel(%s@%s)' % (model, self.getSchema()))
     self.attribute.setText(model)
     Qt.QApplication.instance().setOverrideCursor(
         Qt.QCursor(Qt.Qt.WaitCursor))
     try:
         if self.reader and self.reader.is_attribute_archived(model):
             self.setModes(
                 self.reader.get_attribute_modes(model, force=True))
         else:
             self.setModes()
     except:
         traceback.print_exc()
     Qt.QApplication.instance().restoreOverrideCursor()
 def applyModes(self):
     self.logger().show()
     #Qt.QApplication.instance().setOverrideCursor(Qt.QCursor(Qt.Qt.WaitCursor))
     try:
         attr = self.getModel()
         v = F.check_attribute(attr, brief=True)
         if isinstance(v, (type(None), Exception)):
             Qt.QMessageBox.warning(
                 self, "Warning",
                 "%s is not readable nor archivable" % attr)
             self.logger().hide()
             return
         if fun.isSequence(v) or fun.isString(v):
             Qt.QMessageBox.warning(self, "Warning",
                                    "%s array type is not supported" % attr)
             self.logger().hide()
             return
         modes = self.getModes() or {'MODE_P': [60000]}
         schema = self.getSchema()
         print('%s: applyModes(%s)' % (fun.time2str(), modes))
         msg = 'Modes to be applied:\n'
         for m, v in modes.items():
             msg += '\t%s.%s: %s\n' % (schema, m, v)
         qm = Qt.QMessageBox(Qt.QMessageBox.Warning, 'Confirmation', msg,
                             Qt.QMessageBox.Ok | Qt.QMessageBox.Cancel)
         r = qm.exec_()
         if r == Qt.QMessageBox.Ok:
             if not self.api:
                 self.api = pta.api(self.getSchema().lower(),
                                    logger=self.logger())
             self.api.log = self.logger()
             #self.emit(Qt.SIGNAL('archive'),attr,modes)
             Qt.QApplication.instance().setOverrideCursor(
                 Qt.QCursor(Qt.Qt.WaitCursor))
             thr = threading.Thread(target=self.startArchiving,
                                    args=(attr, modes))
             QLoggerDialog._threads = filter(Thread.is_alive,
                                             self.threads()) + [thr]
             thr.start()
         else:
             self.logger().hide()
     except:
         self.logger().error(traceback.print_exc())
     print('%s: applyModes(...): running!' % (fun.time2str()))
 def getModes(self):
     """ return table values like {'MODE_P':[period]} """
     modes = {}
     values = [[self.getItem(i, j) for j in range(3)] for i in range(3)]
     self.logger().info(
         str('%s(%s).getModes(%s), checking ...' %
             (type(self).__name__, self.getModel(), values)))
     if values[0][0]:
         modes['MODE_P'] = [values[0][0]]
     if values[1][0]:
         modes['MODE_R'] = values[1]
     if values[2][0]:
         modes['MODE_A'] = values[2]
     if modes:
         Qt.QApplication.instance().setOverrideCursor(
             Qt.QCursor(Qt.Qt.WaitCursor))
         modes = pta.ArchivingAPI.check_modes(self.getSchema(), modes)
         Qt.QApplication.instance().restoreOverrideCursor()
     return modes