Example #1
0
 def createNewContext(self):
     try:
         self.snapapi = SnapAPI()
         attributes = []
         for i in range(self.ui.final_List.count()):
             attributes.append(str(self.ui.final_List.item(i).text()))
         self.snapapi.create_context(str(self.ui.line_author.text()),
                                     str(self.ui.line_name.text()),
                                     str(self.ui.line_reason.text()),
                                     str(self.ui.line_description.text()),
                                     attributes)
     except Exception:
         print traceback.format_exc()
         Qt.QMessageBox.critical(self,"Tango Archiving Problem",
                                 "Could not create new context.<br>" + \
                                 "Was not possible to talk with SnapManager DS.<br>" + \
                                 "Please check if DS is running.")
         return
     self.newID = self.snapapi.contexts.keys()[
         len(self.snapapi.contexts.items()) - 1]
     print('un contexte nou: %d' % self.newID)
     self.emit(QtCore.SIGNAL("NewContextCreated(int)"), self.newID)
     self.onCancelPressed()
     Qt.QMessageBox.information(self, "Context",
                                "Context created succesfully!")
 def __init__(self,contextid=None,useInputForComment=False,parent=None):
     QtGui.QPushButton .__init__(self,parent)
     self.setIconSize(Qt.QSize(30,30))
     self.setIcon(Qt.QIcon(":/devices/camera-photo.svg"))
     self.snapapi=SnapAPI()
     self.contextid = contextid
     self.comment = "AutoSnap" 
     self.useInputForComment = useInputForComment
     QtCore.QObject.connect(self, QtCore.SIGNAL("clicked()"), self.snap)
     self.setToolTip("Snapshot for contextid " + str(self.contextid))
Example #3
0
 def fillForm(self,cid):
     self.snapapi = SnapAPI()
     self.ctx = self.snapapi.get_context(cid)
     try: self.ctx.get_attributes(update=True)
     except:
         self.ctx.attributes = {}
         self.ctx.get_attributes()#update=True may not be updated in the last bliss package?
     self.ui.line_name.setText(self.ctx.name)
     self.ui.line_author.setText(self.ctx.author)
     self.ui.line_reason.setText(self.ctx.reason)
     self.ui.line_description.setText(self.ctx.description)
     attributes = self.ctx.get_attributes()#get_attributes_data
     self.ui.attch.updateList([v['full_name'] for v in attributes.values()])
 def __init__(self,useInputForComment=False,useWizardForContext=False,parent=None):
     QtGui.QPushButton .__init__(self,parent)
     self.setIconSize(Qt.QSize(30,30))
     self.setIcon(Qt.QIcon(":/devices/camera-photo.svg"))
     self.snapapi=SnapAPI()
     self.contextid = None
     self.model="" 
     self.author = self.getUserName()
     self.name = "AutoSnap_" + time.strftime("%Y_%m_%d_%H%M%S")
     self.reason = "Always a good reason to create an AutoSnap" 
     self.description = "Snap for all attributes of " + self.model
     self.comment = "AutoSnap" 
     self.useInputForComment = useInputForComment
     self.useWizardForContext = useWizardForContext
     QtCore.QObject.connect(self, QtCore.SIGNAL("clicked()"), self.snap)
     self.setToolTip("Snapshot for device " + self.model)
Example #5
0
    def setupUi(self, Form, load=True):
        Snap_Core_Ui_Form.setupUi(self,Form)
        
        self.context = None
        self.snapshots = []
        self.snapapi = SnapAPI()
        
        self._Form=Form
        Form.setWindowTitle(QtGui.QApplication.translate("Form",'!:'+str(os.getenv('TANGO_HOST')).split(':',1)[0]+' Snaps', None, QtGui.QApplication.UnicodeUTF8))
        self.contextComboBox.setToolTip(QtGui.QApplication.translate("Form", "Choose a Context", None, QtGui.QApplication.UnicodeUTF8))
        print 'connecting signals ...'
        QtCore.QObject.connect(self.contextComboBox,QtCore.SIGNAL("currentIndexChanged(int)"), self.onContextChanged)
        QtCore.QObject.connect(self.contextComboBox,QtCore.SIGNAL("activated(int)"), self.onContextChanged)
        self.contextComboBox.setMaximumWidth(250)
        self.comboLabel.setText(QtGui.QApplication.translate("Form", "Context:", None, QtGui.QApplication.UnicodeUTF8))
        
        self.buttonNew.setText(QtGui.QApplication.translate("Form", "New", None, QtGui.QApplication.UnicodeUTF8))
        icon_view=QtGui.QIcon(":/actions/document-new.svg")
        self.buttonNew.setIcon(icon_view)
        QtCore.QObject.connect(self.buttonNew,QtCore.SIGNAL("pressed()"), self.onNewPressed)
        self.buttonNew.setToolTip(QtGui.QApplication.translate("Form", "New Context", None, QtGui.QApplication.UnicodeUTF8))
        
        self.buttonEditCtx.setText(QtGui.QApplication.translate("Form", "Edit", None, QtGui.QApplication.UnicodeUTF8))
        icon_view=QtGui.QIcon(":/apps/accessories-text-editor.svg")
        self.buttonEditCtx.setIcon(icon_view)
        QtCore.QObject.connect(self.buttonEditCtx,QtCore.SIGNAL("pressed()"), self.onEditPressed)
        self.buttonEditCtx.setToolTip(QtGui.QApplication.translate("Form", "Edit Context", None, QtGui.QApplication.UnicodeUTF8))
        print 'connected signals ...'
        
        self.filterLabel.setText(QtGui.QApplication.translate("Form", "Filter:", None, QtGui.QApplication.UnicodeUTF8))
        self.filterComboBox.addItem('Name')
        self.filterComboBox.addItem('Reason')
        self.filterComboBox.addItem('Attributes')
        self.filterComboBox.setMaximumWidth(90)
        self.filterComboBox2.setEditable(True)
        QtCore.QObject.connect(self.filterComboBox,QtCore.SIGNAL("currentIndexChanged(int)"), self.onFilterComboChanged)        
        refresh_icon=QtGui.QIcon(":/actions/view-refresh.svg")
        self.refreshButton.setIcon(refresh_icon)
        QtCore.QObject.connect(self.refreshButton,QtCore.SIGNAL("pressed()"), self.onRefreshPressed)
        self.refreshButton.setToolTip(QtGui.QApplication.translate("Form", "Refresh List", None, QtGui.QApplication.UnicodeUTF8))

        self.infoLabel1_1.setText(QtGui.QApplication.translate("Form", "Author:", None, QtGui.QApplication.UnicodeUTF8))
        self.infoLabel2_1.setText(QtGui.QApplication.translate("Form", "Reason:", None, QtGui.QApplication.UnicodeUTF8))
        self.infoLabel3_1.setText(QtGui.QApplication.translate("Form", "Description:", None, QtGui.QApplication.UnicodeUTF8))
        self.infoLabel4_1.setText(QtGui.QApplication.translate("Form", "Snapshots:", None, QtGui.QApplication.UnicodeUTF8))
        
        self.buttonTake.setText(QtGui.QApplication.translate("Form", "Take Snapshot", None, QtGui.QApplication.UnicodeUTF8))
        self.buttonTake.setToolTip(QtGui.QApplication.translate("Form", "Save Snapshot in Database", None, QtGui.QApplication.UnicodeUTF8))
        icon_save=QtGui.QIcon(":/devices/camera-photo.svg")
        #icon_save=QtGui.QIcon(":/actions/document-save.svg")not_archived_HDB = [a for a in [t for t in csv if 'HDB' in csv[t]] if a not in last_values_HDB or last_values_HDB[a] is None]
        self.buttonTake.setIcon(icon_save)
        
        QtCore.QObject.connect(self.buttonTake,QtCore.SIGNAL("pressed()"), self.onSavePressed)
        self.buttonLoad.setText(QtGui.QApplication.translate("Form", "Load to Devices", None, QtGui.QApplication.UnicodeUTF8))
        QtCore.QObject.connect(self.buttonLoad,QtCore.SIGNAL("pressed()"), self.onLoadPressed)
        self.buttonLoad.setToolTip(QtGui.QApplication.translate("Form", "Load Snapshot to Devices", None, QtGui.QApplication.UnicodeUTF8))
        icon_load=QtGui.QIcon(":/actions/go-jump.svg")
        self.buttonLoad.setIcon(icon_load)
        
        self.buttonImport.setText(QtGui.QApplication.translate("Form", "Import from CSV", None, QtGui.QApplication.UnicodeUTF8))
        QtCore.QObject.connect(self.buttonImport,QtCore.SIGNAL("pressed()"), self.onImportPressed)
        self.buttonImport.setToolTip(QtGui.QApplication.translate("Form", "Import from CSV File", None, QtGui.QApplication.UnicodeUTF8))
        icon_csv=QtGui.QIcon(":/actions/document-open.svg")
        self.buttonImport.setIcon(icon_csv)        

        self.buttonExport.setText(QtGui.QApplication.translate("Form", "Export to CSV", None, QtGui.QApplication.UnicodeUTF8))
        QtCore.QObject.connect(self.buttonExport,QtCore.SIGNAL("pressed()"), self.onExportPressed)
        self.buttonExport.setToolTip(QtGui.QApplication.translate("Form", "Export to CSV File", None, QtGui.QApplication.UnicodeUTF8))
        icon_csv=QtGui.QIcon(":/actions/document-save-as.svg")
        self.buttonExport.setIcon(icon_csv)
        
        self.buttonDelSnap.setText(QtGui.QApplication.translate("Form", "Delete", None, QtGui.QApplication.UnicodeUTF8))
        QtCore.QObject.connect(self.buttonDelSnap,QtCore.SIGNAL("pressed()"), self.onDelSnapPressed)
        self.buttonDelSnap.setToolTip(QtGui.QApplication.translate("Form", "Delete Snapshot", None, QtGui.QApplication.UnicodeUTF8))
        icon_csv=QtGui.QIcon(":/actions/edit-clear.svg")
        self.buttonDelSnap.setIcon(icon_csv)
        
        self.buttonEditSnap.setText(QtGui.QApplication.translate("Form", "Edit", None, QtGui.QApplication.UnicodeUTF8))
        QtCore.QObject.connect(self.buttonEditSnap,QtCore.SIGNAL("pressed()"), self.onEditSnapPressed)
        self.buttonEditSnap.setToolTip(QtGui.QApplication.translate("Form", "Edit Snap Comment", None, QtGui.QApplication.UnicodeUTF8))
        icon_csv=QtGui.QIcon(":/apps/accessories-text-editor.svg")
        self.buttonEditSnap.setIcon(icon_csv)        
        
        self.buttonDelCtx.setText(QtGui.QApplication.translate("Form", "Delete", None, QtGui.QApplication.UnicodeUTF8))
        QtCore.QObject.connect(self.buttonDelCtx,QtCore.SIGNAL("pressed()"), self.onDelCtxPressed)
        self.buttonDelCtx.setToolTip(QtGui.QApplication.translate("Form", "Delete Context", None, QtGui.QApplication.UnicodeUTF8))
        icon_csv=QtGui.QIcon(":/actions/mail-mark-junk.svg")
        self.buttonDelCtx.setIcon(icon_csv)        

        QtCore.QObject.connect(self.buttonClose,QtCore.SIGNAL("pressed()"), self.onClosePressed)


        self.tableLabel.setText(QtGui.QApplication.translate("Form", "Attribute list:", None, QtGui.QApplication.UnicodeUTF8))
        self.tableWidget.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows)
        self.listWidget.setSelectionMode(QtGui.QAbstractItemView.SingleSelection)
        QtCore.QObject.connect(self.listWidget, QtCore.SIGNAL("currentItemChanged (QListWidgetItem *,QListWidgetItem *)"), self.onSnapshotChanged)
        QtCore.QObject.connect(self.viewComboBox,QtCore.SIGNAL("currentIndexChanged(int)"), self.changeView)
        #self.frame.setMaximumWidth(450)
        self.comp=diffWidget()
        self.comp.setMinimumWidth(450)
        QtCore.QObject.connect(self.comp._wi.diffButtonCompare,QtCore.SIGNAL("pressed()"), self.onCompareButtonPressed)
        self.viewComboBox.setToolTip(QtGui.QApplication.translate("Form", "Change View Mode", None, QtGui.QApplication.UnicodeUTF8))
        self.comboLabel.show()
        
        self.gridLayout.addWidget(self.tableWidget)
        self.gridLayout.addWidget(self.taurusForm)
        self.gridLayout.addWidget(self.comp)

        if load: self.initContexts()
        new_table = []
        for a in self.factory.getExistingAttributes():
            new_table.append(str(a).split('/', 1)[1])
        new_table = sorted(set(s.lower() for s in new_table))
        if not self.att_table or new_table != self.att_table:
            self.att_table = new_table
            if self.att_table: self.SnapApp.initContexts(self.att_table)
            else: self.SnapApp.initContexts()

    def setRefreshTime(self, refTime):
        self.refreshTimer.start(refTime * 1000)


if __name__ == "__main__":
    qapp = Qt.QApplication([])
    snapapi = SnapAPI()
    context = snapapi.get_context(0)
    tmw = container.TaurusMainWindow()
    tmw.setFixedWidth(280)
    #SnapApp=snapWidget(container=tmw)
    #snap=SnapApp.show
    #tmw.fileMenu.addAction(Qt.QIcon(":/actions/media-record.svg"),"SnapApp",snap)
    #dupa2=tmw.fileMenu.addMenu('Dupa2')
    #dupa2.addAction(Qt.QIcon(":/actions/media-record.svg"),"SnapApp",snap)

    #toolbar=Qt.QToolBar(tmw)
    #tmw.addToolBar(toolbar)
    #toolbar.setIconSize(Qt.QSize(30,30))
    #toolbar.addAction(Qt.QIcon(":/actions/media-record.svg"),"SnapApp",snap)
    #toolbar.setMovable(True)
    #toolbar.setFloatable(True)