meqds.enable_node_publish_by_name(name,sync=True,get_state=True);
      else:
        _dprint(2,"not reenabling publishing of",name,", as it no longer exists?");
    # clear publisher list so it's re-saved next time in import_content()
    self._pub_nodes = None;
    ### NB: presume this all was successful for now
    # insert node scope into TDL module
    setattr(_tdlmod,'_tdl_nodescope',ns);

    # does the script define an explicit job list?
    joblist = getattr(_tdlmod,'_tdl_job_list',[]);
    if not joblist:
      joblist = [];
      # try to build it from implicit function names
      for (name,func) in _tdlmod.__dict__.iteritems():
        if name.startswith("_tdl_job_") and callable(func) and not TDLOptions.is_jobfunc_defined(func):
          joblist.append(func);
    # does the script define a testing function?
    testfunc = getattr(_tdlmod,'_test_forest',None);
    if not callable(testfunc):
      testfunc = getattr(_tdlmod,'test_forest',None);
      if callable(testfunc):
        res = QMessageBox.warning(self,"Deprecated method",
          """Your script contains a test_forest() method. This is deprecated
          and will be disabled in the future. Please rename it to
          _test_forest().
          """,
          QMessageBox.Ok);
    if callable(testfunc):
      joblist.append(testfunc);
    joblist.sort(lambda a,b:cmp(str(a),str(b)));
Exemple #2
0
    def compile_content(self):
        # import content first, and return if failed
        if not self.import_content(force=True):
            return None
        _dprint(1, self._filename, "compiling forest")
        # clear predefined functions
        self._tb_tdlexec.hide()
        # try the compilation
        busy = BusyIndicator()
        try:
            (_tdlmod,ns,msg) = \
       TDL.Compile.run_forest_definition(
            meqds.mqs(),self._filename,self._tdlmod,self._tdltext,
            parent=self,wait=False)
        # catch compilation errors
        except TDL.CumulativeError as value:
            _dprint(0, "caught cumulative error, length", len(value.args))
            self._error_window.set_errors(value.args,
                                          message="TDL import failed")
            busy = None
            return None
        except Exception as value:
            _dprint(0, "caught other error, traceback follows")
            traceback.print_exc()
            self._error_window.set_errors([value])
            busy = None
            return None
        # refresh the nodelist
        meqds.request_nodelist(sync=True)
        # restore publishing nodes
        for name in (self._pub_nodes or []):
            if name in ns.AllNodes():
                _dprint(2, "reenabling publishing of", name)
                meqds.enable_node_publish_by_name(name,
                                                  sync=True,
                                                  get_state=True)
            else:
                _dprint(2, "not reenabling publishing of", name,
                        ", as it no longer exists?")
        # clear publisher list so it's re-saved next time in import_content()
        self._pub_nodes = None
        ### NB: presume this all was successful for now
        # insert node scope into TDL module
        setattr(_tdlmod, '_tdl_nodescope', ns)

        # does the script define an explicit job list?
        joblist = getattr(_tdlmod, '_tdl_job_list', [])
        if not joblist:
            joblist = []
            # try to build it from implicit function names
            for (name, func) in _tdlmod.__dict__.items():
                if name.startswith("_tdl_job_") and callable(
                        func) and not TDLOptions.is_jobfunc_defined(func):
                    joblist.append(func)
        # does the script define a testing function?
        testfunc = getattr(_tdlmod, '_test_forest', None)
        if not callable(testfunc):
            testfunc = getattr(_tdlmod, 'test_forest', None)
            if callable(testfunc):
                res = QMessageBox.warning(
                    self, "Deprecated method",
                    """Your script contains a test_forest() method. This is deprecated
          and will be disabled in the future. Please rename it to
          _test_forest().
          """, QMessageBox.Ok)
        if callable(testfunc):
            joblist.append(testfunc)

        from past.builtins import cmp
        from functools import cmp_to_key
        joblist.sort(key=cmp_to_key(lambda a, b: cmp(str(a), str(b))))

        # create list of job actions
        opts = TDLOptions.get_runtime_options()
        self._tdlexec_menu.clear()
        if joblist or opts:
            if opts:
                self._job_executor = curry(self.execute_tdl_job, _tdlmod, ns)
                ## new style:
                try:
                    TDLOptions.populate_option_treewidget(
                        self._tdlexec_menu.treeWidget(),
                        opts,
                        executor=self._job_executor)
                except Exception as value:
                    _dprint(0, "error setting up TDL options GUI")
                    traceback.print_exc()
                    self._error_window.set_errors(
                        [value], message="Error setting up TDL options GUI")
                    busy = None
                    return None
            if joblist:
                for func in joblist:
                    name = re.sub("^_tdl_job_", "", func.__name__)
                    name = name.replace('_', ' ')
                    self._tdlexec_menu.addAction(name,
                                                 curry(self.execute_tdl_job,
                                                       _tdlmod, ns, func, name,
                                                       func.__name__),
                                                 icon=pixmaps.gear)
            self.emit(PYSIGNAL("hasRuntimeOptions()"), self, True)
            self._tdlexec_menu.adjustSizes()
            self._tb_tdlexec.show()
        else:
            self.emit(PYSIGNAL("hasRuntimeOptions()"), self, False)
            self._tb_tdlexec.hide()

        if joblist:
            msg += " %d predefined function(s) available, please use the Exec menu to run them." % (
                len(joblist), )

        self.show_message(msg, transient=True)
        busy = None
        return True
Exemple #3
0
                _dprint(2, "not reenabling publishing of", name,
                        ", as it no longer exists?")
        # clear publisher list so it's re-saved next time in import_content()
        self._pub_nodes = None
        ### NB: presume this all was successful for now
        # insert node scope into TDL module
        setattr(_tdlmod, '_tdl_nodescope', ns)

        # does the script define an explicit job list?
        joblist = getattr(_tdlmod, '_tdl_job_list', [])
        if not joblist:
            joblist = []
            # try to build it from implicit function names
            for (name, func) in _tdlmod.__dict__.iteritems():
                if name.startswith("_tdl_job_") and callable(
                        func) and not TDLOptions.is_jobfunc_defined(func):
                    joblist.append(func)
        # does the script define a testing function?
        testfunc = getattr(_tdlmod, '_test_forest', None)
        if not callable(testfunc):
            testfunc = getattr(_tdlmod, 'test_forest', None)
            if callable(testfunc):
                res = QMessageBox.warning(
                    self, "Deprecated method",
                    """Your script contains a test_forest() method. This is deprecated
          and will be disabled in the future. Please rename it to
          _test_forest().
          """, QMessageBox.Ok)
        if callable(testfunc):
            joblist.append(testfunc)
        joblist.sort(lambda a, b: cmp(str(a), str(b)))