Exemple #1
0
    def load_script(self,scriptname):
        # import aqui para evitar dependencia ciclica
        import pineboolib.emptyscript
        python_script_path = None
        self.script = pineboolib.emptyscript # primero default, luego sobreescribimos
        if scriptname:
            print("Loading script %s . . . " % scriptname)
            # Intentar convertirlo a Python primero con flscriptparser2
            script_path = self.prj.path(scriptname+".qs")
            if not os.path.isfile(script_path): raise IOError
            python_script_path = (script_path+".xml.py").replace(".qs.xml.py",".py")
            if not os.path.isfile(python_script_path) or pineboolib.no_python_cache:
                print("Convirtiendo a Python . . .")
                #ret = subprocess.call(["flscriptparser2", "--full",script_path])
                from pineboolib.flparser import postparse
                postparse.pythonify(script_path)

            if not os.path.isfile(python_script_path):
                raise AssertionError(u"No se encontró el módulo de Python, falló flscriptparser?")
            try:
                self.script = imp.load_source(scriptname,python_script_path)
                #self.script = imp.load_source(scriptname,filedir(scriptname+".py"), open(python_script_path,"U"))
            except Exception as e:
                print("ERROR al cargar script QS para la accion %r:" % self.action.name, e)
                print(traceback.format_exc(),"---")

        self.script.form = self.script.FormInternalObj(action = self.action, project = self.prj, parent = self)
        self.widget = self.script.form
        self.iface = self.widget.iface
 def cargarFicheros(self, directorio=None, extension=None):
     dir = Dir(directorio)
     ficheros = dir.entryList(extension, Dir.Files)
     log = self.child(u"log")
     i = 0
     from pineboolib.fllegacy.flsettings import FLSettings
     from pineboolib.flparser import postparse
     settings= FLSettings()
     while_pass = True
     while i < len(ficheros):
         if not while_pass:
             i += 1
             while_pass = True
             continue
         while_pass = False
         path_ = Dir.cleanDirPath(ustr(directorio, u"/", ficheros[i]))
         if settings.readBoolEntry("ebcomportamiento/parseModulesOnLoad", False):
             file_py_path_ = "%s.py" % path_
             if os.path.exists(file_py_path_):
                 os.remove(file_py_path_)
             if path_.endswith(".qs"):
                 postparse.pythonify(path_)
             if os.path.exists(file_py_path_):
                 value_py = File(file_py_path_).read()
                 self.cargarFicheroEnBD("%s.py" % ficheros[i], value_py, log, directorio)
             
         value = File(path_).read()
         self.cargarFicheroEnBD(ficheros[i], value, log, directorio)
         sys.processEvents()
         i += 1
         while_pass = True
         try:
             i < len(ficheros)
         except Exception:
             break
Exemple #3
0
    def load_script(self,scriptname):
        python_script_path = None
        self.script = pineboolib.emptyscript # primero default, luego sobreescribimos
        if scriptname:
            print("Loading script %s . . . " % scriptname)
            # Intentar convertirlo a Python primero con flscriptparser2
            script_path = self.prj.path(scriptname+".qs")
            if not os.path.isfile(script_path): raise IOError
            python_script_path = (script_path+".xml.py").replace(".qs.xml.py",".py")
            try:
                if not os.path.isfile(python_script_path) or pineboolib.no_python_cache:
                    print("Convirtiendo a Python . . .")
                    #ret = subprocess.call(["flscriptparser2", "--full",script_path])
                    from pineboolib.flparser import postparse
                    postparse.pythonify(script_path)

                if not os.path.isfile(python_script_path):
                    raise AssertionError(u"No se encontró el módulo de Python, falló flscriptparser?")
                self.script = imp.load_source(scriptname,python_script_path)
                #self.script = imp.load_source(scriptname,filedir(scriptname+".py"), open(python_script_path,"U"))
            except Exception as e:
                print("ERROR al cargar script QS para la accion %r:" % self.action.name, e)
                print(traceback.format_exc(),"---")

        self.script.form = self.script.FormInternalObj(action = self.action, project = self.prj, parent = self)
        self.widget = self.script.form
        self.iface = self.widget.iface
Exemple #4
0
    def load_script(self, scriptname, parent= None):
        
                        # import aqui para evitar dependencia ciclica
        import pineboolib.emptyscript
        python_script_path = None
        self.script = pineboolib.emptyscript # primero default, luego sobreescribimos

        script_path_qs = self.prj.path(scriptname+".qs")
        script_path_py = self.prj.path(scriptname+".py") or self.prj.path(scriptname+".qs.py")
        
        overload_pyfile = os.path.join(self.prj.tmpdir,"overloadpy",scriptname+".py")
        if os.path.isfile(overload_pyfile):
            print("WARN: ** cargando %r de overload en lugar de la base de datos!!" % scriptname)
            try:
                self.script = importlib.machinery.SourceFileLoader(scriptname,overload_pyfile).load_module()
            except Exception as e:
                print("ERROR al cargar script OVERLOADPY para la accion %r:" % self.action.name, e)
                print(traceback.format_exc(),"---")
            
        elif script_path_py:
            script_path = script_path_py
            print("Loading script PY %s . . . " % scriptname)
            if not os.path.isfile(script_path): raise IOError
            try:
                print("Cargando %s : %s " % (scriptname,script_path.replace(self.prj.tmpdir,"tempdata")))
                self.script = importlib.machinery.SourceFileLoader(scriptname,script_path).load_module()
            except Exception as e:
                print("ERROR al cargar script PY para la accion %r:" % self.action.name, e)
                print(traceback.format_exc(),"---")
            
        elif script_path_qs:
            script_path = script_path_qs
            print("Loading script QS %s . . . " % scriptname)
            # Intentar convertirlo a Python primero con flscriptparser2
            if not os.path.isfile(script_path): raise IOError
            python_script_path = (script_path+".xml.py").replace(".qs.xml.py",".qs.py")
            if not os.path.isfile(python_script_path) or pineboolib.no_python_cache:
                print("Convirtiendo a Python . . .")
                #ret = subprocess.call(["flscriptparser2", "--full",script_path])
                from pineboolib.flparser import postparse
                postparse.pythonify(script_path)

            if not os.path.isfile(python_script_path):
                raise AssertionError(u"No se encontró el módulo de Python, falló flscriptparser?")
            try:
                print("Cargando %s : %s " % (scriptname,python_script_path.replace(self.prj.tmpdir,"tempdata")))
                self.script = importlib.machinery.SourceFileLoader(scriptname,python_script_path).load_module()
                #self.script = imp.load_source(scriptname,python_script_path)
                #self.script = imp.load_source(scriptname,filedir(scriptname+".py"), open(python_script_path,"U"))
            except Exception as e:
                print("ERROR al cargar script QS para la accion %r:" % self.name, e)
                print(traceback.format_exc(),"---")
            
        
        self.script.form = self.script.FormInternalObj(self, self.prj, parent)
Exemple #5
0
 def parseScript(self, scriptname):
     # Intentar convertirlo a Python primero con flscriptparser2
     if not os.path.isfile(scriptname):
         raise IOError
     python_script_path = (
         scriptname + ".xml.py").replace(".qs.xml.py", ".qs.py")
     if not os.path.isfile(python_script_path) or pineboolib.no_python_cache:
         self.logger.info("Convirtiendo a Python . . . %s", scriptname)
         from pineboolib.flparser import postparse
         try:
             postparse.pythonify(scriptname)
         except Exception as e:
             self.logger.warn(
                 "El fichero %s no se ha podido convertir: %s", scriptname, e)
    def parseScript(self, scriptname, txt_=""):

        # Intentar convertirlo a Python primero con flscriptparser2
        if not os.path.isfile(scriptname):
            raise IOError
        python_script_path = (
            scriptname + ".xml.py").replace(".qs.xml.py", ".qs.py")
        if not os.path.isfile(python_script_path) or pineboolib.no_python_cache:
            settings = FLSettings()
            debug_postparse = False
            if settings.readBoolEntry("application/isDebuggerMode", False):
                util = FLUtil()
                file_name = scriptname.split("\\") if util.getOS() == "WIN32" else scriptname.split("/")

                file_name = file_name[len(file_name) - 2]

                msg = "Convirtiendo a Python . . . %s.qs %s" % (file_name, txt_)
                if settings.readBoolEntry("ebcomportamiento/SLConsola", False):
                    debug_postparse = True
                    self.logger.warning(msg)

                if self._splash:
                    self._splash.showMessage(msg, QtCore.Qt.AlignLeft, QtCore.Qt.white)

                else:
                    if settings.readBoolEntry("ebcomportamiento/SLInterface", False):
                        from pineboolib.pncontrolsfactory import aqApp
                        aqApp.popupWarn(msg)
            
            clean_no_python = self._DGI.clean_no_python()
            
            from pineboolib.flparser import postparse
            try:
                postparse.pythonify(scriptname, debug_postparse, clean_no_python)
            except Exception as e:
                self.logger.warning("El fichero %s no se ha podido convertir: %s", scriptname, e)
Exemple #7
0
    def load_script(self, scriptname, parent=None):
        self.logger.info("Cargando script %s de %s accion %s", scriptname,
                         parent, self.name)

        parent_ = parent
        if parent is None:
            parent = self
            action_ = self
        else:
            action_ = parent.action

        # Si ya esta cargado se reusa...
        # if getattr(self, "script", None) and parent_:
        #    if getattr(self.script, "form", None):
        #        parent.script = self.script
        #        parent.widget = self.script.form
        #    else:
        #        if getattr(self.script.form, "iface", None):
        #            parent.iface = self.script.form.iface
        #        return

        # import aqui para evitar dependencia ciclica
        import pineboolib.emptyscript
        python_script_path = None
        # primero default, luego sobreescribimos
        parent.script = pineboolib.emptyscript

        if scriptname is None:
            parent.script.form = parent.script.FormInternalObj(
                action=action_, project=pineboolib.project, parent=parent)
            parent.widget = parent.script.form
            parent.iface = parent.widget.iface
            return

        script_path_qs = pineboolib.project.path(scriptname + ".qs")
        script_path_py = pineboolib.project.coalesce_path(
            scriptname + ".py", scriptname + ".qs.py", None)

        overload_pyfile = os.path.join(parent.prj.tmpdir, "overloadpy",
                                       scriptname + ".py")
        if os.path.isfile(overload_pyfile):
            self.logger.warn(
                "Cargando %s desde overload en lugar de la base de datos!!",
                scriptname)
            try:
                parent.script = machinery.SourceFileLoader(
                    scriptname, overload_pyfile).load_module()
            except Exception as e:
                self.logger.exception(
                    "ERROR al cargar script OVERLOADPY para la accion %s:",
                    action_.name)

        elif script_path_py:
            script_path = script_path_py
            self.logger.info("Loading script PY %s . . . ", scriptname)
            if not os.path.isfile(script_path):
                raise IOError
            try:
                self.logger.info(
                    "Cargando %s : %s ", scriptname,
                    script_path.replace(pineboolib.project.tmpdir, "tempdata"))
                parent.script = machinery.SourceFileLoader(
                    scriptname, script_path).load_module()
            except Exception as e:
                self.logger.exception(
                    "ERROR al cargar script PY para la accion %s:",
                    action_.name)

        elif script_path_qs:
            script_path = script_path_qs
            self.logger.info("Loading script QS %s . . . ", scriptname)
            # Intentar convertirlo a Python primero con flscriptparser2
            if not os.path.isfile(script_path):
                raise IOError("QS Script File %s not found" % script_path)
            python_script_path = (script_path + ".xml.py").replace(
                ".qs.xml.py", ".qs.py")
            if not os.path.isfile(
                    python_script_path) or pineboolib.no_python_cache:
                self.logger.info("Convirtiendo a Python . . .")
                from pineboolib.flparser import postparse
                postparse.pythonify(script_path)

            if not os.path.isfile(python_script_path):
                raise AssertionError(
                    u"No se encontró el módulo de Python, falló flscriptparser?"
                )
            try:
                self.logger.info(
                    "Cargando %s : %s ", scriptname,
                    python_script_path.replace(pineboolib.project.tmpdir,
                                               "tempdata"))
                parent.script = machinery.SourceFileLoader(
                    scriptname, python_script_path).load_module()
            except Exception as e:
                self.logger.exception(
                    "ERROR al cargar script QS para la accion %s:",
                    action_.name)

        parent.script.form = parent.script.FormInternalObj(
            action_, pineboolib.project, parent_)
        if parent_:
            parent.widget = parent.script.form
            if getattr(parent.widget, "iface", None):
                parent.iface = parent.widget.iface