Esempio n. 1
0
class StandaloneHistoryApp(CacheClient):

    parameters = {
        'views':
        Param('Strings specifying views (from command line)',
              type=listof(str)),
    }

    def doInit(self, mode):
        self._qtapp = QApplication(sys.argv)
        self._qtapp.setOrganizationName('nicos')
        self._qtapp.setApplicationName('history')
        self._window = StandaloneHistoryWindow(self)
        # if no cache was given on the command line...
        if not self._config['cache']:
            dlg = SettingsDialog(self._window)
            dlg.exec_()
            self._setROParam('cache', dlg.cacheBox.currentText())
            self._setROParam('prefix', dlg.prefixEdit.text())
        CacheClient.doInit(self, mode)

    def getDeviceList(self, only_explicit=True, special_clause=None):
        devlist = [
            key[:-6] for (key, _) in self.query_db('')
            if key.endswith('/value')
        ]
        if special_clause:
            devlist = [
                dn for dn in devlist if eval(special_clause, {'dn': dn})
            ]
        return sorted(devlist)

    def getDeviceParam(self, devname, parname):
        return self.get(devname, parname)

    def getDeviceParams(self, devname):
        ldevname = devname.lower()
        index = len(ldevname) + 1
        return {
            key[index:]: value
            for (key, value) in self.query_db('')
            if key.startswith(ldevname + '/')
        }

    def getDeviceParamInfo(self, _):
        return {}  # we can't deliver this info from the cache alone

    def start(self):
        self._startup_done.wait(2)
        self._window.openViews(self.views)
        self._window.show()
        try:
            self._qtapp.exec_()
        except KeyboardInterrupt:
            pass
        self._stoprequest = True

    def _propagate(self, data):
        self._window.newValue.emit(data)
Esempio n. 2
0
class CacheInspector(CICacheClient):
    def doInit(self, mode):
        CICacheClient.doInit(self, self._mode)
        self._qtapp = QApplication(sys.argv)
        self._qtapp.setOrganizationName('nicos')
        self._qtapp.setApplicationName('cacheinspector')
        self._window = MainWindow(self)
        self._window.setWindowIcon(QIcon(':/inspector'))
        session._qthandler.setStatusbar(self._window.statusBar())

    def start(self):
        self._window.show()
        if self.cache:
            self.connect(self.cache)
        try:
            self._qtapp.exec_()
        except KeyboardInterrupt:
            pass
        self._stoprequest = True