Ejemplo n.º 1
0
    def on_but_edit(self):
        #logger.debug('on_but_edit')
        if self.w_edit is None:
            logger.debug("TBD Open configuration editor window")
            resp = self.select_config_type_and_dev()
            if resp is None: return
            cfgtype, dev = resp
            self.device = dev

            inst, confdb = self.inst_configdb('on_but_edit: ')

            try:
                self.config = confdb.get_configuration(cfgtype,
                                                       dev,
                                                       hutch=inst)
            except ValueError as err:
                logger.error('ValueError: %s' % err)
                return

            msg = 'get_configuration(%s, %s, %s):\n' % (cfgtype, dev, inst)\
                + '%s\n    type(config): %s'%(str_json(self.config), type(self.config))
            logger.debug(msg)

            self.w_edit = CGWConfigEditor(dictj=self.config)
            self.w_edit.move(self.mapToGlobal(QPoint(self.width() + 10, 0)))
            self.w_edit.show()

        else:
            logger.debug("Close configuration editor window")
            self.w_edit.close()
            self.w_edit = None
Ejemplo n.º 2
0
 def load_dict(self):
     ifname = self.ifname_json
     logger.info('CGWConfigEditor: load json from %s' % ifname)
     self.dictj = dj = load_json_from_file(ifname)
     sj = str_json(dj)
     logger.debug(
         'CGWConfigEditor: dict of json as str:\n%s\nconfiguration object type: %s'
         % (sj, type(dj)))
Ejemplo n.º 3
0
    def on_but_apply(self):
        logger.debug('on_but_apply')
        dj = self.get_content()
        sj = str_json(dj)
        logger.info('on_but_apply jason/dict:\n%s' % sj)

        if cp.cgwmainconfiguration is None:
            logger.warning("parent (ctrl) is None - changes can't be applied to DB")
            return
        else:
            cp.cgwmainconfiguration.save_dictj_in_db(dj, msg='CGWConfigEditor: ')
Ejemplo n.º 4
0
    def on_but_edit_v0(self):
        #logger.debug('on_but_edit')
        if self.w_edit is None:
            inst, confdb = self.inst_configdb('on_but_edit: ')
            cfgtype = self.but_type_text()
            dev = self.but_dev_text()
            self.config = confdb.get_configuration(cfgtype, dev, hutch=inst)
            msg = 'get_configuration(%s, %s, %s):\n' % (cfgtype, dev, inst)\
                + '%s\n    type(config): %s'%(str_json(self.config), type(self.config))
            logger.debug(msg)

            self.w_edit = CGWConfigEditor(dictj=self.config)
            self.w_edit.move(self.mapToGlobal(QPoint(self.width() + 10, 0)))
            self.w_edit.show()

        else:
            self.w_edit.close()
            self.w_edit = None
Ejemplo n.º 5
0
    def select_configuration_dict_to_edit(self):
        logger.debug('select_configuration_dict_to_edit')
        resp = self.select_config_type_and_dev()
        if resp is None: return None
        cfgtype, dev = resp
        self.device_edit = dev
        self.cfgtype_edit = cfgtype

        inst, confdb = self.inst_configdb('on_but_edit: ')

        try:
            self.config = confdb.get_configuration(cfgtype, dev, hutch=inst)
        except ValueError as err:
            logger.error('ValueError: %s' % err)
            return None
        except Exception as err:
            logger.error('Exception: %s' % err)
            return None

        msg = 'get_configuration(%s, %s, %s):\n' % (cfgtype, dev, inst)\
            + '%s\n    type(config): %s'%(str_json(self.config), type(self.config))
        logger.debug(msg)

        return self.config
Ejemplo n.º 6
0
 def save_dict_in_file(self):
     logger.info('save_dict_in_file %s' % self.ofname_json)
     dj = self.get_content()
     sj = str_json(dj)
     save_textfile(sj, self.ofname_json, mode='w', verb=True)
Ejemplo n.º 7
0
 def set_content(self, dictj):
     """Interface method
     """
     self.dictj = dictj
     sj = str_json(dictj)
     self.edi_txt.setText(str(sj))