Пример #1
0
    def editarFicheroXML(self):
        cursor = self.cursor()
        util = qsatype.FLUtil()
        if cursor.checkIntegrity():
            temporal = System.getenv(u"TMP")
            if temporal == '':
                temporal = System.getenv(u"TMPDIR")
            if temporal == '':
                temporal = System.getenv(u"HOME")
            if temporal == '':
                temporal = ustr(sys.installPrefix(), u"/share/facturalux/tmp")
            temporal = ustr(temporal, u"/", cursor.valueBuffer(u"nombre"))
            comando = ""
            contenido = self.child(u"contenido").text
            if util.getOS() == u"MACX":
                qsatype.File.write(
                    temporal, ustr(contenido, u"\n\n\n\n\n\n\n\n\n\n\n\n\n\n"))
                comando = ustr(sys.installPrefix(),
                               u"/bin/teddy.app/Contents/MacOS/teddy")
            else:
                qsatype.File.write(temporal, contenido)
                comando = ustr(sys.installPrefix(), u"/bin/teddy")

            self.setDisabled(True)
            qsatype.Process.execute(qsatype.Array([comando, temporal]))
            self.child(u"contenido").text = qsatype.File.read(temporal)
            self.setDisabled(False)
Пример #2
0
    def leerValorGlobal(self, valorName=None):
        util = qsatype.FLUtil()
        valor = util.sqlSelect(u"flsettings", u"valor",
                               ustr(u"flkey='", valorName, u"'"))
        if valor is None:
            valor = ""

        return valor
Пример #3
0
 def leerValorLocal(self, valorName=None):
     util = qsatype.FLUtil()
     settings = qsatype.AQSettings()
     if valorName == u"isDebuggerMode":
         valor = settings.readBoolEntry(ustr(u"application/", valorName))
     else:
         valor = util.readSettingEntry(
             ustr(u"ebcomportamiento/", valorName), u"")
     return valor
Пример #4
0
 def grabarValorGlobal(self, valorName=None, value=None):
     util = qsatype.FLUtil()
     if not util.sqlSelect(u"flsettings", u"flkey",
                           ustr(u"flkey='", valorName, u"'")):
         util.sqlInsert(u"flsettings", u"flkey,valor",
                        ustr(valorName, u",", value))
     else:
         util.sqlUpdate(u"flsettings", u"valor", value,
                        ustr(u"flkey = '", valorName, u"'"))
Пример #5
0
    def oficial_elegirOpcion(self, opciones=None):
        util = qsatype.FLUtil()
        dialog = qsatype.Dialog()
        dialog.okButtonText = util.translate(u"scripts", u"Aceptar")
        dialog.cancelButtonText = util.translate(u"scripts", u"Cancelar")
        bgroup = qsatype.GroupBox()
        bgroup.title = util.translate(u"scripts",
                                      u"Seleccione módulos a cargar")
        dialog.add(bgroup)
        resultado = qsatype.Array()
        cB = qsatype.Array()
        i = 0
        while_pass = True
        while i < len(opciones):
            if not while_pass:
                i += 1
                while_pass = True
                continue
            while_pass = False
            cB[i] = qsatype.CheckBox()
            bgroup.add(cB[i])
            cB[i].text = opciones[i]
            cB[i].checked = True
            i += 1
            while_pass = True
            try:
                i < len(opciones)
            except Exception:
                break

        indice = 0
        if dialog.exec_():
            i = 0
            while_pass = True
            while i < len(opciones):
                if not while_pass:
                    i += 1
                    while_pass = True
                    continue
                while_pass = False
                if cB[i].checked == True:
                    resultado[indice] = opciones[i]
                    indice += 1
                i += 1
                while_pass = True
                try:
                    i < len(opciones)
                except Exception:
                    break

        else:
            return -1

        if len(resultado) == 0:
            return -1
        return resultado
Пример #6
0
    def interna_main(self):
        util = qsatype.FLUtil()
        setting = ustr(u"scripts/sys/modLastModule_", sys.nameBD())
        fichMod = util.readSettingEntry(setting)
        if not fichMod:
            fichMod = FileDialog.getOpenFileName(
                util.translate(u"scripts", u"Módulo a cargar (*.mod)"),
                util.translate(u"scripts", u"Módulo a cargar"))
            if not fichMod:
                return
            util.writeSettingEntry(setting, fichMod)

        sys.processEvents()
        self.iface.cargarModulo(fichMod)
        sys.reinit()
Пример #7
0
    def oficial_traducirCadena(self, cadena=None, path=None, modulo=None):
        util = qsatype.FLUtil()
        if cadena.find(u"QT_TRANSLATE_NOOP") == -1:
            return cadena
        cadena2 = cadena
        cadena = qsatype.QString(cadena).mid(41, len(cadena) - 43)
        nombreFichero = None
        try:
            nombreFichero = ustr(path, u"/translations/", modulo, u".",
                                 util.getIdioma(), u".ts")
        except Exception as e:
            e = traceback.format_exc()
            return cadena

        if not qsatype.File.exists(nombreFichero):
            return cadena
        fichero = qsatype.File(nombreFichero)
        fichero.open(qsatype.File.ReadOnly)
        f = fichero.read()
        xmlTranslations = qsatype.FLDomDocument()
        if xmlTranslations.setContent(f):
            nodeMess = xmlTranslations.elementsByTagName(u"message")
            i = 0
            while_pass = True
            while i < len(nodeMess):
                if not while_pass:
                    i += 1
                    while_pass = True
                    continue
                while_pass = False
                if nodeMess.item(i).namedItem(
                        u"source").toElement().text() == cadena:
                    traduccion = nodeMess.item(i).namedItem(
                        u"translation").toElement().text()
                    if traduccion:
                        cadena = traduccion
                i += 1
                while_pass = True
                try:
                    i < len(nodeMess)
                except Exception:
                    break

        return cadena
Пример #8
0
    def interna_main(self):
        util = qsatype.FLUtil()
        setting = ustr(u"scripts/sys/modLastDirModules_", sys.nameDB())
        dirAnt = util.readSettingEntry(setting)
        if dirAnt:
            dirMods = FileDialog.getExistingDirectory(
                dirAnt, util.translate(u"scripts", u"Directorio de Módulos"))
        else:
            dirMods = FileDialog.getExistingDirectory(
                False, util.translate(u"scripts", u"Directorio de Módulos"))

        if not dirMods:
            return
        qsatype.Dir().setCurrent(dirMods)

        resComando = qsatype.Array()
        if util.getOS() == u"WIN32":
            resComando = self.iface.ejecutarComando(
                u"cmd.exe \/C dir \/B \/S *.mod")
        else:
            resComando = self.iface.ejecutarComando(u"find . -name *.mod")

        if resComando.ok == False:
            MessageBox.warning(
                util.translate(
                    u"scripts",
                    u"Error al buscar los módulos en el directorio:\n") +
                dirMods, MessageBox.Ok, MessageBox.NoButton,
                MessageBox.NoButton)
            return

        opciones = resComando.salida.split(u"\n")
        opciones.pop()
        modulos = self.iface.elegirOpcion(opciones)
        if modulos == -1 or modulos == -2:
            return
        i = 0
        while_pass = True
        while i < len(modulos):
            if not while_pass:
                i += 1
                while_pass = True
                continue
            while_pass = False
            if getattr(formRecordflmodules, "child", None):
                sys.processEvents()
            if not self.iface.cargarModulo(modulos[i]):
                MessageBox.warning(
                    util.translate(u"scripts", u"Error al cargar el módulo:\n")
                    + modulos[i], MessageBox.Ok, MessageBox.NoButton,
                    MessageBox.NoButton)
                return
            i += 1
            while_pass = True
            try:
                i < len(modulos)
            except Exception:
                break

        util.writeSettingEntry(setting, dirMods)
        sys.reinit()
Пример #9
0
    def oficial_cargarModulo(self, nombreFichero=None):
        util = qsatype.FLUtil()
        if util.getOS() == u"WIN32":
            nombreFichero = nombreFichero[0:len(nombreFichero) - 1]

        if not isinstance(nombreFichero, str):
            nombreFichero = nombreFichero.data().decode("utf-8")

        fichero = qsatype.File(nombreFichero, "iso-8859-15")
        modulo = None
        descripcion = None
        area = None
        desArea = None
        version = None
        nombreIcono = None
        versionMinimaFL = None
        dependencias = qsatype.Array()
        fichero.open(qsatype.File.ReadOnly)
        f = fichero.read()
        xmlModule = qsatype.FLDomDocument()
        if xmlModule.setContent(f):
            nodeModule = xmlModule.namedItem(u"MODULE")
            if not nodeModule:
                MessageBox.critical(
                    util.translate(u"scripts",
                                   u"Error en la carga del fichero xml .mod"),
                    MessageBox.Ok, MessageBox.NoButton)
            modulo = nodeModule.namedItem(u"name").toElement().text()
            descripcion = nodeModule.namedItem(u"alias").toElement().text()
            area = nodeModule.namedItem(u"area").toElement().text()
            desArea = nodeModule.namedItem(u"areaname").toElement().text()
            version = nodeModule.namedItem(u"version").toElement().text()
            nombreIcono = nodeModule.namedItem(u"icon").toElement().text()
            if nodeModule.namedItem(u"flversion"):
                versionMinimaFL = nodeModule.namedItem(
                    u"flversion").toElement().text()
            if nodeModule.namedItem(u"dependencies"):
                nodeDepend = xmlModule.elementsByTagName(u"dependency")
                i = 0
                while_pass = True
                while i < len(nodeDepend):
                    if not while_pass:
                        i += 1
                        while_pass = True
                        continue
                    while_pass = False
                    dependencias[i] = nodeDepend.item(i).toElement().text()
                    i += 1
                    while_pass = True
                    try:
                        i < len(nodeDepend)
                    except Exception:
                        break

        else:
            aF = f.split(u"\n")
            modulo = self.iface.dameValor(aF[0])
            descripcion = self.iface.dameValor(aF[1])
            area = self.iface.dameValor(aF[2])
            desArea = self.iface.dameValor(aF[3])
            version = self.iface.dameValor(aF[4])
            nombreIcono = self.iface.dameValor(aF[5])
            if len(aF) > 6:
                versionMinimaFL = self.iface.dameValor(aF[6])
            if len(aF) > 7:
                # DEBUG:: Argument 0 not understood
                # DEBUG:: <Value><Constant><regexbody><regexchar
                # arg00="LBRACKET"/><regexchar arg00="COMMA"/><regexchar
                # arg00="SEMI"/><regexchar
                # arg00="RBRACKET"/></regexbody></Constant></Value>
                dependencias = self.ifacedameValor(aF[7]).split(unknownarg)

        descripcion = self.iface.traducirCadena(descripcion, fichero.path,
                                                modulo)
        desArea = self.iface.traducirCadena(desArea, fichero.path, modulo)
        fichIcono = qsatype.File(ustr(fichero.path, u"/", nombreIcono))
        fichIcono.open(qsatype.File.ReadOnly)
        icono = fichIcono.read()
        icono = clearXPM(icono)
        # DEBUG:: Argument 0 not understood
        # DEBUG:: <Value><Constant><regexbody><regexchar arg00="LBRACKET"/><regexchar arg00="ICONST:'0'"/><regexchar arg00="MINUS"/><regexchar arg00="ICONST:'9'"/><regexchar arg00="RBRACKET"/><regexchar arg00="PLUS"/><regexchar arg00="PERIOD"/><regexchar arg00="LBRACKET"/><regexchar arg00="ICONST:'0'"/><regexchar arg00="MINUS"/><regexchar arg00="ICONST:'9'"/><regexchar arg00="RBRACKET"/><regexchar arg00="PLUS"/></regexbody></Constant></Value>
        #versionSys = sys.version().match(unknownarg)
        # if self.iface.compararVersiones(versionSys, versionMinimaFL) == 2:
        #    contVersion = MessageBox.warning(util.translate(u"scripts", u"Este módulo necesita la versión ") + versionMinimaFL + util.translate(u"scripts", u" o superior de la aplicación base,\nactualmente la versión instalada es la ") + sys.version() + util.translate(u"scripts", u".\nFacturaLUX puede fallar por esta causa.\n¿Desea continuar la carga?"), MessageBox.Yes, MessageBox.No)
        #    if contVersion == MessageBox.No:
        #        return
        if not util.sqlSelect(u"flareas", u"idarea",
                              ustr(u"idarea = '", area, u"'")):
            if not util.sqlInsert(u"flareas", u"idarea,descripcion",
                                  ustr(area, u",", desArea)):
                MessageBox.warning(
                    util.translate(u"scripts", u"Error al crear el área:\n") +
                    area, MessageBox.Ok, MessageBox.NoButton)
                return False
        recargar = util.sqlSelect(u"flmodules", u"idmodulo",
                                  ustr(u"idmodulo = '", modulo, u"'"))
        curModulo = qsatype.FLSqlCursor(u"flmodules")
        if recargar:
            # WITH_START
            curModulo.select(ustr(u"idmodulo = '", modulo, u"'"))
            curModulo.first()
            curModulo.setModeAccess(curModulo.Edit)
            # WITH_END

        else:
            curModulo.setModeAccess(curModulo.Insert)

        # WITH_START
        curModulo.refreshBuffer()
        curModulo.setValueBuffer(u"idmodulo", modulo)
        curModulo.setValueBuffer(u"descripcion", descripcion)
        curModulo.setValueBuffer(u"idarea", area)
        curModulo.setValueBuffer(u"version", version)
        curModulo.setValueBuffer(u"icono", icono)
        curModulo.commitBuffer()
        # WITH_END
        curSeleccion = qsatype.FLSqlCursor(u"flmodules")
        curModulo.setMainFilter(ustr(u"idmodulo = '", modulo, u"'"))
        curModulo.editRecord()
        formRecordflmodules.cargarDeDisco(ustr(fichero.path, u"/"), False)
        formRecordflmodules.accept()
        sys.processEvents()
        return True
Пример #10
0
    def editarFichero(self):
        cursor = self.cursor()
        util = qsatype.FLUtil()
        if cursor.checkIntegrity():
            self.child(u"nombre").setDisabled(True)
            nombre = cursor.valueBuffer(u"nombre")
            tipo = self.tipoDeFichero(nombre)
            temporal = System.getenv(u"TMP")
            if temporal == '':
                temporal = System.getenv(u"TMPDIR")
            if temporal == '':
                temporal = System.getenv(u"HOME")
            if temporal == '':
                temporal = ustr(sys.installPrefix(), u"/share/facturalux/tmp")
            temporal = ustr(temporal, u"/", cursor.valueBuffer(u"nombre"))
            contenido = self.child(u"contenido").text
            comando = ""
            s01_when = tipo
            s01_do_work, s01_work_done = False, False
            if s01_when == u".ui":
                s01_do_work, s01_work_done = True, True
            if s01_do_work:
                if util.getOS() == u"MACX":
                    qsatype.File.write(
                        temporal,
                        ustr(contenido, u"\n\n\n\n\n\n\n\n\n\n\n\n\n\n"))
                    comando = ustr(
                        sys.installPrefix(),
                        u"/bin/designer.app/Contents/MacOS/designer")
                else:
                    qsatype.File.write(temporal, contenido)
                    comando = ustr(sys.installPrefix(), u"/bin/designer")

                self.setDisabled(True)
                qsatype.Process.execute(qsatype.Array([comando, temporal]))
                self.child(u"contenido").text = qsatype.File.read(temporal)
                self.setDisabled(False)
                s01_do_work = False  # BREAK

            if s01_when == u".ts":
                s01_do_work, s01_work_done = True, True
            if s01_do_work:
                if util.getOS() == u"MACX":
                    qsatype.File.write(
                        temporal,
                        ustr(contenido, u"\n\n\n\n\n\n\n\n\n\n\n\n\n\n"))
                    comando = ustr(
                        sys.installPrefix(),
                        u"/bin/linguist.app/Contents/MacOS/linguist")
                else:
                    qsatype.File.write(temporal, contenido)
                    comando = ustr(sys.installPrefix(), u"/bin/linguist")

                self.setDisabled(True)
                qsatype.Process.execute(qsatype.Array([comando, temporal]))
                self.child(u"contenido").text = qsatype.File.read(temporal)
                self.setDisabled(False)
                s01_do_work = False  # BREAK

            if s01_when == u".kut":
                s01_do_work, s01_work_done = True, True
            if s01_do_work:
                if util.getOS() == u"MACX":
                    qsatype.File.write(
                        temporal,
                        ustr(contenido, u"\n\n\n\n\n\n\n\n\n\n\n\n\n\n"))
                    comando = ustr(
                        sys.installPrefix(),
                        u"/bin/kudesigner.app/Contents/MacOS/kudesigner")
                else:
                    qsatype.File.write(temporal, contenido)
                    comando = ustr(sys.installPrefix(), u"/bin/kudesigner")

                self.setDisabled(True)
                qsatype.Process.execute(qsatype.Array([comando, temporal]))
                self.child(u"contenido").text = qsatype.File.read(temporal)
                self.setDisabled(False)
                s01_do_work = False  # BREAK

            if s01_when == u".qs":
                s01_do_work, s01_work_done = True, True
            if s01_do_work:
                self.setDisabled(True)
                editor = qsatype.FLScriptEditor(nombre)
                editor.exec_()
                self.child(u"contenido").text = editor.code()
                self.setDisabled(False)
                s01_do_work = False  # BREAK

            if not s01_work_done:
                s01_do_work, s01_work_done = True, True
            if s01_do_work:
                self.setDisabled(True)
                dialog = qsatype.Dialog()
                dialog.width = 600
                dialog.cancelButtonText = u""
                editor = qsatype.TextEdit()
                editor.textFormat = editor.PlainText
                editor.text = contenido
                dialog.add(editor)
                dialog.exec_()
                self.child(u"contenido").text = editor.text
                self.setDisabled(False)
Пример #11
0
 def calculateField(self, fN=None):
     if fN == u"sha":
         util = qsatype.FLUtil()
         return util.sha1(self.cursor().valueBuffer(u"contenido"))
Пример #12
0
 def _class_init(self):
     self.util = qsatype.FLUtil()