Ejemplo n.º 1
0
    def closeEvent(self, event):
        if self.confirmexit and QMessageBox.question(
                self, 'Quit', 'Do you really want to quit?',
                QMessageBox.Yes | QMessageBox.No) == QMessageBox.No:
            event.ignore()
            return

        for panel in self.panels:
            if not panel.requestClose():
                event.ignore()
                return

        if self.autosavelayout:
            self.saveWindowLayout()
        with self.sgroup as settings:
            self.saveSettings(settings)
        for panel in self.panels:
            with panel.sgroup as settings:
                panel.saveSettings(settings)

        for window in listvalues(self.windows):
            if not window.close():
                event.ignore()
                return

        if self.helpWindow:
            self.helpWindow.close()

        if self.client.isconnected:
            self.on_actionConnect_triggered(False)

        event.accept()
        QApplication.instance().quit()
Ejemplo n.º 2
0
 def quit(self, signum=None):
     self.log.info('quitting on signal %s...', signum)
     self._stoprequest = True
     # without locking, the _connected list may not have all clients yet....
     with self._connectionLock:
         for client in listvalues(self._connected):
             self.log.info('closing client %s', client)
             if client.is_active():
                 client.closedown()
     with self._connectionLock:
         for client in listvalues(self._connected):
             self.log.info('waiting for %s', client)
             client.closedown()  # make sure, the connection closes down
             client.join()
     self.log.info('waiting for server')
     self._worker.join()
     self.log.info('server finished')
Ejemplo n.º 3
0
 def _setups_updated(self, time, new_setups):
     prev_setups, self._setups = self._setups, new_setups
     # check if we need to remove some conditions
     for entry in listvalues(self._entries):
         if entry.from_setup != 'watchdog':
             if entry.from_setup not in self._setups:
                 self._remove_entry(entry.id)
     # check if we need to add some conditions
     session.readSetups()  # refresh setup info
     for new_setup in self._setups - prev_setups:
         info = session._setup_info.get(new_setup)
         if info and info['watch_conditions']:
             self.log.info('adding conditions from setup %s', new_setup)
             for entry_dict in info['watch_conditions']:
                 self._add_entry(entry_dict, new_setup)
     # trigger an update of all conditions
     for entry in itervalues(self._entries):
         entry.cond_obj.new_setups(self._setups)
         entry.cond_obj.update(time, self._keydict)
         self._check_state(entry, time)
     # update everyone els
     self._publish_config()
     self.log.info('new setups list: %s', ', '.join(self._setups))
Ejemplo n.º 4
0
    def _readSetup(self):
        uniqueId = self._getUniqueSetupId(self._shortSetupPath)

        setups = {}
        setup_roots = findSetupRoots(self._absSetupPath)
        if setup_roots in all_setups_cache:
            all_setups = all_setups_cache[setup_roots]
        else:
            all_setups_cache[setup_roots] = all_setups = \
                dict(iterSetups(setup_roots))

        modname = path.splitext(path.basename(self._absSetupPath))[0]
        readSetup(setups, modname, self._absSetupPath, all_setups, self)

        if not setups:
            # logging will be done by readSetup
            return None

        info = listvalues(setups)[0]
        info['uniqueid'] = uniqueId
        info['setupname'] = self._setupName
        info['shortsetuppath'] = self._shortSetupPath

        return info
Ejemplo n.º 5
0
 def doReset(self):
     multiReset(listvalues(self._adevs))
     self._focwarnings = 3
Ejemplo n.º 6
0
def create(parent,
           typ,
           curvalue,
           fmtstr='',
           unit='',
           allow_buttons=False,
           allow_enter=True,
           client=None,
           valinfo=None):
    # make sure the type is correct
    try:
        curvalue = typ(curvalue)
    except ValueError:
        curvalue = typ()
    except TypeError:
        return MissingWidget(parent, curvalue, 'device not found')
    if unit:
        inner = create(parent,
                       typ,
                       curvalue,
                       fmtstr,
                       unit='',
                       client=client,
                       allow_buttons=allow_buttons,
                       allow_enter=allow_enter,
                       valinfo=valinfo)
        return AnnotatedWidget(parent, inner, unit)
    if isinstance(typ, params.oneof):
        if allow_buttons and len(typ.vals) <= 3:
            return ButtonWidget(parent, typ.vals)
        return ComboWidget(parent, typ.vals, curvalue)
    elif isinstance(typ, params.oneofdict):
        if allow_buttons and len(typ.vals) <= 3:
            return ButtonWidget(parent, listvalues(typ.vals))
        return ComboWidget(parent, listvalues(typ.vals), curvalue)
    elif isinstance(typ, params.oneofdict_or):
        inner = create(parent, typ.conv, curvalue, fmtstr, unit, allow_buttons,
                       allow_enter, client, valinfo)
        if allow_buttons and len(typ.named_vals) <= 3:
            selector = ButtonWidget(parent, typ.named_vals)
            return OneofdictOrWidget(parent, inner, selector, buttons=True)
        else:
            for (name, value) in iteritems(typ.named_vals):
                if value == curvalue:
                    curvalue = name
                    break
            selector = ComboWidget(parent,
                                   list(typ.named_vals),
                                   curvalue,
                                   add_other=True)
            return OneofdictOrWidget(parent, inner, selector, buttons=False)
    elif isinstance(typ, params.none_or):
        return CheckWidget(parent, typ.conv, curvalue, client)
    elif isinstance(typ, params.tupleof):
        return MultiWidget(parent,
                           typ.types,
                           curvalue,
                           client,
                           allow_enter=allow_enter,
                           valinfo=valinfo)
    elif isinstance(typ, params.dictwith):
        return DictWithWidget(parent,
                              typ.keys,
                              typ.convs.values(),
                              curvalue,
                              client,
                              allow_enter=allow_enter)
    elif typ == params.limits:
        return LimitsWidget(parent, curvalue, client, allow_enter=allow_enter)
    elif isinstance(typ, params.floatrange):
        edw = EditWidget(parent,
                         float,
                         curvalue,
                         fmtstr or '%.4g',
                         minmax=(typ.fr, typ.to),
                         allow_enter=allow_enter)
        annotation = '(range: %.5g to %.5g)' % (typ.fr, typ.to) \
            if typ.to is not None else '(must be >= %.5g)' % typ.fr
        return AnnotatedWidget(parent, edw, annotation)
    elif isinstance(typ, params.intrange):
        edw = SpinBoxWidget(parent,
                            curvalue, (typ.fr, typ.to),
                            fmtstr=fmtstr or '%.4g',
                            allow_enter=allow_enter)
        return AnnotatedWidget(parent, edw,
                               '(range: %d to %d)' % (typ.fr, typ.to))
    elif typ in (int, float, str, params.string):
        return EditWidget(parent,
                          typ,
                          curvalue,
                          fmtstr or '%.4g',
                          allow_enter=allow_enter)
    elif typ == bool:
        if allow_buttons:
            return ButtonWidget(parent, [True, False])
        return ComboWidget(parent, [True, False], curvalue)
    elif typ == params.vec3:
        return MultiWidget(parent, (float, float, float),
                           curvalue,
                           client,
                           allow_enter=allow_enter)
    elif typ == params.nicosdev:
        return DeviceComboWidget(parent,
                                 curvalue,
                                 client,
                                 allow_enter=allow_enter)
    elif typ in (params.tacodev, params.tangodev, params.mailaddress,
                 params.ipv4, params.subdir, params.relative_path,
                 params.absolute_path):
        # XXX validate via regexp
        return EditWidget(parent, str, curvalue, allow_enter=allow_enter)
    elif isinstance(typ, params.host):
        # XXX validate via regexp
        return EditWidget(parent, str, curvalue, allow_enter=allow_enter)
    elif typ == anytype:
        return ExprWidget(parent, curvalue, allow_enter=allow_enter)
    elif isinstance(typ, params.setof):
        return SetOfWidget(parent, typ.vals, curvalue, client)
    elif isinstance(typ, params.listof):
        return ListOfWidget(parent,
                            typ.conv,
                            curvalue,
                            client,
                            allow_enter=allow_enter)
    elif isinstance(typ, params.nonemptylistof):
        return ListOfWidget(parent,
                            typ.conv,
                            curvalue,
                            client,
                            nmin=1,
                            allow_enter=allow_enter)
    elif isinstance(typ, params.dictof):
        return DictOfWidget(parent,
                            typ.keyconv,
                            typ.valconv,
                            curvalue,
                            client,
                            allow_enter=allow_enter)
    elif typ == SXTalCellType:
        return TableWidget(parent,
                           float,
                           curvalue.rmat.T.round(10),
                           '%.4g',
                           client,
                           allow_enter=allow_enter)
    return MissingWidget(parent, curvalue)