コード例 #1
0
    def cargarAr(self, nombre: str, contenido: str, log: "QtWidgets.QTextEdit",
                 directorio: str) -> bool:
        """Load AR reports."""
        if not qsa.sys.isLoadedModule(u"flar2kut"):
            return False
        if qsa.util.readSettingEntry(u"scripts/sys/conversionAr") != u"true":
            return False
        log.append(
            qsa.util.translate(u"scripts", u"Convirtiendo %s a kut") %
            (str(nombre)))
        contenido = qsa.sys.toUnicode(contenido, u"UTF-8")
        contenido = qsa.from_project("flar2kut").iface.pub_ar2kut(contenido)
        nombre = qsa.ustr(qsa.parseString(nombre)[0:len(nombre) - 3], u".kut")
        if contenido:
            localEnc = qsa.util.readSettingEntry(
                u"scripts/sys/conversionArENC")
            if not localEnc:
                localEnc = u"ISO-8859-15"
            contenido = qsa.sys.fromUnicode(contenido, localEnc)
            self.cargarFicheroEnBD(nombre, contenido, log, directorio)
            log.append(
                qsa.util.translate(u"scripts", u"Volcando a disco ") + nombre)
            qsa.FileStatic.write(
                qsa.Dir.cleanDirPath(qsa.ustr(directorio, u"/", nombre)),
                contenido)

        else:
            log.append(qsa.util.translate(u"scripts", u"Error de conversión"))
            return False

        return True
コード例 #2
0
 def aceptarLicenciaDelModulo(self, directorio: str) -> bool:
     """Accept license dialog."""
     path_licencia = qsa.Dir.cleanDirPath(qsa.ustr(directorio, u"/COPYING"))
     if not qsa.FileStatic.exists(path_licencia):
         qsa.MessageBox.critical(
             qsa.util.translate(
                 u"scripts",
                 qsa.ustr(
                     u"El fichero ",
                     path_licencia,
                     u" con la licencia del módulo no existe.\nEste fichero debe existir para poder aceptar la licencia que contiene.",
                 ),
             ),
             qsa.MessageBox.Ok,
         )
         return False
     licencia = qsa.FileStatic.read(path_licencia)
     dialog = qsa.Dialog()
     dialog.setWidth(600)
     dialog.caption = qsa.util.translate(u"scripts",
                                         u"Acuerdo de Licencia.")
     # dialog.newTab(qsa.util.translate(u"scripts", u"Acuerdo de Licencia."))
     texto = qsa.TextEdit()
     texto.text = licencia
     dialog.add(texto)
     dialog.okButtonText = qsa.util.translate(
         u"scripts", u"Sí, acepto este acuerdo de licencia.")
     dialog.cancelButtonText = qsa.util.translate(
         u"scripts", u"No, no acepto este acuerdo de licencia.")
     if dialog.exec_():
         return True
     else:
         return False
コード例 #3
0
    def editarFicheroXML(self) -> None:
        """Edit xml file."""
        cursor = self.cursor()
        util = qsa.FLUtil()
        if cursor.checkIntegrity():
            temporal = qsa.System.getenv(u"TMP")
            if temporal == "":
                temporal = qsa.System.getenv(u"TMPDIR")
            if temporal == "":
                temporal = qsa.System.getenv(u"HOME")
            if temporal == "":
                from pineboolib.core.settings import config

                temporal = config.value("ebcomportamiento/temp_dir")
            temporal = qsa.ustr(temporal, "/", cursor.valueBuffer(u"nombre"))
            comando = ""
            contenido = self.child("contenido").toPlainText()
            if util.getOS() == "MACX":
                qsa.FileStatic.write(temporal, qsa.ustr(contenido, "\n\n\n\n\n\n\n\n\n\n\n\n\n\n"))
                comando = qsa.ustr(qsa.sys.installPrefix(), "/bin/teddy.app/Contents/MacOS/teddy")
            else:
                qsa.FileStatic.write(temporal, contenido)
                comando = qsa.ustr(qsa.sys.installPrefix(), "/bin/teddy")

            self.setDisabled(True)
            qsa.ProcessStatic.execute([comando, temporal])
            self.child("contenido").setText(qsa.FileStatic.read(temporal))
            self.setDisabled(False)
コード例 #4
0
ファイル: sys.py プロジェクト: Miguel-J/pineboo
    def init(self) -> None:
        """Init function."""
        settings = qsa.AQSettings()
        app_ = qsa.aqApp
        if not app_:
            return
        flfactppal = qsa.SysType().isLoadedModule("flfactppal")
        if flfactppal is True:
            try:
                codEjercicio = qsa.from_project("flfactppal").iface.pub_ejercicioActual()
            except Exception as e:
                logger.error(
                    "Module flfactppal was loaded but not able to execute <flfactppal.iface.pub_ejercicioActual()>"
                )
                logger.error(
                    "... this usually means that flfactppal has failed translation to python"
                )
                logger.exception(e)
                codEjercicio = None
            if codEjercicio:
                util = qsa.FLUtil()
                nombreEjercicio = util.sqlSelect(
                    u"ejercicios", u"nombre", qsa.ustr(u"codejercicio='", codEjercicio, u"'")
                )
                if qsa.AQUtil.sqlSelect(u"flsettings", u"valor", u"flkey='PosInfo'") == "True":
                    texto = ""
                    if nombreEjercicio:
                        texto = qsa.ustr(u"[ ", nombreEjercicio, u" ]")
                    texto = qsa.ustr(
                        texto,
                        u" [ ",
                        app_.db().driverNameToDriverAlias(app_.db().driverName()),
                        u" ] * [ ",
                        qsa.SysType().nameBD(),
                        u" ] * [ ",
                        qsa.SysType().nameUser(),
                        u" ] ",
                    )
                    app_.setCaptionMainWidget(texto)

                else:
                    if nombreEjercicio:
                        app_.setCaptionMainWidget(nombreEjercicio)

                oldApi = settings.readBoolEntry(u"application/oldApi")
                if not oldApi:
                    valor = util.readSettingEntry(u"ebcomportamiento/ebCallFunction")
                    if valor:
                        funcion = qsa.Function(valor)
                        try:
                            funcion()
                        except Exception:
                            qsa.debug(traceback.format_exc())

        if settings.readBoolEntry("ebcomportamiento/git_updates_enabled", False):
            qsa.sys.AQTimer.singleShot(2000, qsa.SysType.search_git_updates)
コード例 #5
0
    def cargarFicheros(self, directorio: str, extension: str) -> None:
        """Load files into database."""
        dir = qsa.Dir(directorio)
        ficheros = dir.entryList(extension, qsa.Dir.Files)
        log = self.child(u"log")
        if log is None:
            raise Exception("log is empty!.")
        i = 0
        from pineboolib.application.parsers.qsaparser import postparse
        import os

        settings = qsa.FLSettings()
        while_pass = True
        while i < len(ficheros):
            if not while_pass:
                i += 1
                while_pass = True
                continue
            while_pass = False
            path_ = qsa.Dir.cleanDirPath(
                qsa.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 = qsa.File(file_py_path_).read()
                    if not isinstance(value_py, str):
                        raise Exception("value_py must be string not bytes.")

                    self.cargarFicheroEnBD("%s.py" % ficheros[i][-3], value_py,
                                           log, directorio)

            encode = "ISO-8859-1"
            if path_.endswith("ts"):
                encode = "UTF-8"
            try:
                value = qsa.File(path_, encode).read()
            except UnicodeDecodeError:
                self.logger.warning("The file %s has a incorrect encode (%s)" %
                                    (path_, encode))
                encode = "UTF8" if encode == "ISO-8859-1" else "ISO-8859-1"
                value = qsa.File(path_, encode).read()

            if not isinstance(value, str):
                raise Exception("value must be string not bytes.")

            self.cargarFicheroEnBD(ficheros[i], value, log, directorio)
            qsa.sys.processEvents()
            i += 1
            while_pass = True
            try:
                i < len(ficheros)
            except Exception:
                break
コード例 #6
0
ファイル: flloadmod.py プロジェクト: Miguel-J/pineboo
def valorPorClave(tabla: str, campo: str, where: str) -> Any:
    """Return a value from database."""
    valor = None
    query = qsa.FLSqlQuery()
    query.setTablesList(tabla)
    query.setSelect(campo)
    query.setFrom(tabla)
    query.setWhere(qsa.ustr(where, u";"))
    query.exec_()
    if query.next():
        valor = query.value(0)
    return valor
コード例 #7
0
ファイル: flreloadlast.py プロジェクト: Miguel-J/pineboo
    def traducirCadena(self, cadena: str, path: str, modulo: str) -> str:
        """Translate string."""
        util = qsa.FLUtil()
        if cadena.find(u"QT_TRANSLATE_NOOP") == -1:
            return cadena
        cadena = qsa.QString(cadena).mid(41, len(cadena) - 43)
        nombre_fichero = None
        try:
            nombre_fichero = qsa.ustr(path, u"/translations/", modulo, u".",
                                      util.getIdioma(), u".ts")
        except Exception as e:
            qsa.debug(str(e))
            return cadena

        if not qsa.FileStatic.exists(nombre_fichero):
            return cadena
        fichero = qsa.File(nombre_fichero)
        fichero.open(qsa.File.ReadOnly)
        f = fichero.read()
        xmlTranslations = qsa.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
ファイル: flloadmod.py プロジェクト: Miguel-J/pineboo
    def main(self) -> None:
        """Entry function."""
        continuar = qsa.MessageBox.warning(
            qsa.util.translate(
                u"scripts",
                u"Antes de cargar un módulo asegúrese de tener una copia de seguridad de todos los datos,\n"
                +
                "y de que no hay ningun otro usuario conectado a la base de datos mientras se realiza la carga.\n\n¿Desea continuar?",
            ),
            qsa.MessageBox.Yes,
            qsa.MessageBox.No,
        )
        if continuar == qsa.MessageBox.No:
            return
        nombre_fichero = qsa.FileDialog.getOpenFileName(
            u"modfiles(*.mod)",
            qsa.util.translate(u"scripts", u"Elegir Fichero"))
        if nombre_fichero:
            fichero = qsa.File(nombre_fichero)
            if not qsa.from_project(
                    "formRecordflmodules").aceptarLicenciaDelModulo(
                        qsa.ustr(fichero.path, u"/")):
                qsa.MessageBox.critical(
                    qsa.util.translate(
                        u"scripts",
                        u"Imposible cargar el módulo.\nLicencia del módulo no aceptada."
                    ),
                    qsa.MessageBox.Ok,
                )
                return

            if qsa.from_project("formflreloadlast").cargarModulo(
                    nombre_fichero):
                app_ = qsa.aqApp
                if app_ is None:
                    return
                app_.reinit()
コード例 #9
0
    def cargarFicheroEnBD(self, nombre: str, contenido: str,
                          log: "QtWidgets.QTextEdit", directorio: str) -> None:
        """Load a file into database."""
        if (not qsa.util.isFLDefFile(contenido)
                and not nombre.endswith(u".mod")
                and not nombre.endswith(u".xpm")
                and not nombre.endswith(u".signatures")
                and not nombre.endswith(u".checksum")
                and not nombre.endswith(u".certificates")
                and not nombre.endswith(u".qs") and not nombre.endswith(u".ar")
                and not nombre.endswith(u".py")
                and not nombre.endswith(u".kut")):
            return
        cursorFicheros = qsa.FLSqlCursor(u"flfiles")
        cursor = self.cursor()
        cursorFicheros.select(qsa.ustr(u"nombre = '", nombre, u"'"))
        if not cursorFicheros.first():
            if nombre.endswith(u".ar"):
                if not self.cargarAr(nombre, contenido, log, directorio):
                    return
            log.append(
                qsa.util.translate(u"scripts", u"- Cargando :: ") + nombre)
            cursorFicheros.setModeAccess(cursorFicheros.Insert)
            cursorFicheros.refreshBuffer()
            cursorFicheros.setValueBuffer(u"nombre", nombre)
            cursorFicheros.setValueBuffer(u"idmodulo",
                                          cursor.valueBuffer(u"idmodulo"))
            cursorFicheros.setValueBuffer(u"sha", qsa.util.sha1(contenido))
            cursorFicheros.setValueBuffer(u"contenido", contenido)
            cursorFicheros.commitBuffer()

        else:
            cursorFicheros.setModeAccess(cursorFicheros.Edit)
            cursorFicheros.refreshBuffer()
            contenidoCopia = cursorFicheros.valueBuffer(u"contenido")
            if contenidoCopia != contenido:
                log.append(
                    qsa.util.translate(u"scripts", u"- Actualizando :: ") +
                    nombre)
                cursorFicheros.setModeAccess(cursorFicheros.Insert)
                cursorFicheros.refreshBuffer()
                d = qsa.Date()
                cursorFicheros.setValueBuffer(u"nombre",
                                              nombre + qsa.parseString(d))
                cursorFicheros.setValueBuffer(u"idmodulo",
                                              cursor.valueBuffer(u"idmodulo"))
                cursorFicheros.setValueBuffer(u"contenido", contenidoCopia)
                cursorFicheros.commitBuffer()
                log.append(
                    qsa.util.translate(u"scripts", u"- Backup :: ") + nombre +
                    qsa.parseString(d))
                cursorFicheros.select(qsa.ustr(u"nombre = '", nombre, u"'"))
                cursorFicheros.first()
                cursorFicheros.setModeAccess(cursorFicheros.Edit)
                cursorFicheros.refreshBuffer()
                cursorFicheros.setValueBuffer(u"idmodulo",
                                              cursor.valueBuffer(u"idmodulo"))
                cursorFicheros.setValueBuffer(u"sha", qsa.util.sha1(contenido))
                cursorFicheros.setValueBuffer(u"contenido", contenido)
                cursorFicheros.commitBuffer()
                if nombre.endswith(u".ar"):
                    self.cargarAr(nombre, contenido, log, directorio)
コード例 #10
0
    def exportarADisco(self, directorio: str) -> None:
        """Export a module to disk."""
        if directorio:
            tdb_lineas = self.child(u"lineas")
            if tdb_lineas is None:
                raise Exception("lineas control not found")

            curFiles = tdb_lineas.cursor()
            cursorModules = qsa.FLSqlCursor(u"flmodules")
            cursorAreas = qsa.FLSqlCursor(u"flareas")
            if curFiles.size() != 0:
                dir = qsa.Dir()
                idModulo = self.cursor().valueBuffer(u"idmodulo")
                log = self.child(u"log")
                if log is None:
                    raise Exception("Log control not found!.")

                log.text = u""
                directorio = qsa.Dir.cleanDirPath(
                    qsa.ustr(directorio, u"/", idModulo))
                if not dir.fileExists(directorio):
                    dir.mkdir(directorio)
                if not dir.fileExists(qsa.ustr(directorio, u"/forms")):
                    dir.mkdir(qsa.ustr(directorio, u"/forms"))
                if not dir.fileExists(qsa.ustr(directorio, u"/scripts")):
                    dir.mkdir(qsa.ustr(directorio, u"/scripts"))
                if not dir.fileExists(qsa.ustr(directorio, u"/queries")):
                    dir.mkdir(qsa.ustr(directorio, u"/queries"))
                if not dir.fileExists(qsa.ustr(directorio, u"/tables")):
                    dir.mkdir(qsa.ustr(directorio, u"/tables"))
                if not dir.fileExists(qsa.ustr(directorio, u"/reports")):
                    dir.mkdir(qsa.ustr(directorio, u"/reports"))
                if not dir.fileExists(qsa.ustr(directorio, u"/translations")):
                    dir.mkdir(qsa.ustr(directorio, u"/translations"))
                curFiles.first()
                file = None
                tipo = None
                contenido = ""
                self.setDisabled(True)
                s01_dowhile_1stloop = True
                while s01_dowhile_1stloop or curFiles.next():
                    s01_dowhile_1stloop = False
                    file = curFiles.valueBuffer(u"nombre")
                    tipo = self.tipoDeFichero(file)
                    contenido = curFiles.valueBuffer(u"contenido")
                    if not contenido == "":
                        s01_when = tipo
                        s01_do_work, s01_work_done = False, False
                        if s01_when == u".xml":
                            s01_do_work, s01_work_done = True, True
                        if s01_do_work:
                            qsa.sys.write(u"ISO-8859-1",
                                          qsa.ustr(directorio, u"/", file),
                                          contenido)
                            log.append(
                                qsa.util.translate(
                                    u"scripts",
                                    qsa.ustr(u"* Exportando ", file, u".")))
                            s01_do_work = False  # BREAK
                        if s01_when == u".mod":
                            s01_do_work, s01_work_done = True, True
                        if s01_do_work:
                            qsa.sys.write(u"ISO-8859-1",
                                          qsa.ustr(directorio, u"/", file),
                                          contenido)
                            log.append(
                                qsa.util.translate(
                                    u"scripts",
                                    qsa.ustr(u"* Exportando ", file, u".")))
                            s01_do_work = False  # BREAK
                        if s01_when == u".xpm":
                            s01_do_work, s01_work_done = True, True
                        if s01_do_work:
                            qsa.sys.write(u"ISO-8859-1",
                                          qsa.ustr(directorio, u"/", file),
                                          contenido)
                            log.append(
                                qsa.util.translate(
                                    u"scripts",
                                    qsa.ustr(u"* Exportando ", file, u".")))
                            s01_do_work = False  # BREAK
                        if s01_when == u".signatures":
                            s01_do_work, s01_work_done = True, True
                        if s01_do_work:
                            qsa.sys.write(u"ISO-8859-1",
                                          qsa.ustr(directorio, u"/", file),
                                          contenido)
                            log.append(
                                qsa.util.translate(
                                    u"scripts",
                                    qsa.ustr(u"* Exportando ", file, u".")))
                            s01_do_work = False  # BREAK
                        if s01_when == u".certificates":
                            s01_do_work, s01_work_done = True, True
                        if s01_do_work:
                            qsa.sys.write(u"ISO-8859-1",
                                          qsa.ustr(directorio, u"/", file),
                                          contenido)
                            log.append(
                                qsa.util.translate(
                                    u"scripts",
                                    qsa.ustr(u"* Exportando ", file, u".")))
                            s01_do_work = False  # BREAK
                        if s01_when == u".checksum":
                            s01_do_work, s01_work_done = True, True
                        if s01_do_work:
                            qsa.sys.write(u"ISO-8859-1",
                                          qsa.ustr(directorio, u"/", file),
                                          contenido)
                            log.append(
                                qsa.util.translate(
                                    u"scripts",
                                    qsa.ustr(u"* Exportando ", file, u".")))
                            s01_do_work = False  # BREAK
                        if s01_when == u".ui":
                            s01_do_work, s01_work_done = True, True
                        if s01_do_work:
                            qsa.sys.write(
                                u"ISO-8859-1",
                                qsa.ustr(directorio, u"/forms/", file),
                                contenido)
                            log.append(
                                qsa.util.translate(
                                    u"scripts",
                                    qsa.ustr(u"* Exportando ", file, u".")))
                            s01_do_work = False  # BREAK
                        if s01_when == u".qs":
                            s01_do_work, s01_work_done = True, True
                        if s01_do_work:
                            qsa.sys.write(
                                u"ISO-8859-1",
                                qsa.ustr(directorio, u"/scripts/", file),
                                contenido)
                            log.append(
                                qsa.util.translate(
                                    u"scripts",
                                    qsa.ustr(u"* Exportando ", file, u".")))
                            s01_do_work = False  # BREAK
                        if s01_when == u".py":
                            s01_do_work, s01_work_done = True, True
                        if s01_do_work:
                            qsa.sys.write(
                                u"UTF-8",
                                qsa.ustr(directorio, u"/scripts/", file),
                                contenido)
                            log.append(
                                qsa.util.translate(
                                    u"scripts",
                                    qsa.ustr(u"* Exportando ", file, u".")))
                            s01_do_work = False  # BREAK

                        if s01_when == u".qry":
                            s01_do_work, s01_work_done = True, True
                        if s01_do_work:
                            qsa.sys.write(
                                u"ISO-8859-1",
                                qsa.ustr(directorio, u"/queries/", file),
                                contenido)
                            log.append(
                                qsa.util.translate(
                                    u"scripts",
                                    qsa.ustr(u"* Exportando ", file, u".")))
                            s01_do_work = False  # BREAK
                        if s01_when == u".mtd":
                            s01_do_work, s01_work_done = True, True
                        if s01_do_work:
                            qsa.sys.write(
                                u"ISO-8859-1",
                                qsa.ustr(directorio, u"/tables/", file),
                                contenido)
                            log.append(
                                qsa.util.translate(
                                    u"scripts",
                                    qsa.ustr(u"* Exportando ", file, u".")))
                            s01_do_work = False  # BREAK
                        if s01_when == u".kut":
                            s01_do_work, s01_work_done = True, True
                        if s01_do_work:
                            qsa.sys.write(
                                u"UTF-8",
                                qsa.ustr(directorio, u"/reports/", file),
                                contenido)
                            log.append(
                                qsa.util.translate(
                                    u"scripts",
                                    qsa.ustr(u"* Exportando ", file, u".")))
                            s01_do_work = False  # BREAK
                        if s01_when == u".ts":
                            s01_do_work, s01_work_done = True, True
                        if s01_do_work:
                            qsa.sys.write(
                                u"UTF-8",
                                qsa.ustr(directorio, u"/translations/", file),
                                contenido)
                            log.append(
                                qsa.util.translate(
                                    u"scripts",
                                    qsa.ustr(u"* Exportando ", file, u".")))
                            s01_do_work = False  # BREAK
                        if not s01_work_done:
                            s01_do_work, s01_work_done = True, True
                        if s01_do_work:
                            log.append(
                                qsa.util.translate(
                                    u"scripts",
                                    qsa.ustr(u"* Omitiendo ", file, u".")))

                    qsa.sys.processEvents()

                cursorModules.select(qsa.ustr(u"idmodulo = '", idModulo, u"'"))
                if cursorModules.first():
                    cursorAreas.select(
                        qsa.ustr(u"idarea = '",
                                 cursorModules.valueBuffer(u"idarea"), u"'"))
                    cursorAreas.first()
                    areaName = cursorAreas.valueBuffer(u"descripcion")
                    if not qsa.FileStatic.exists(
                            qsa.ustr(directorio, u"/",
                                     cursorModules.valueBuffer(u"idmodulo"),
                                     u".xpm")):
                        qsa.sys.write(
                            u"ISO-8859-1",
                            qsa.ustr(directorio, u"/",
                                     cursorModules.valueBuffer(u"idmodulo"),
                                     u".xpm"),
                            cursorModules.valueBuffer(u"icono"),
                        )
                        log.append(
                            qsa.util.translate(
                                u"scripts",
                                qsa.ustr(
                                    u"* Exportando ",
                                    cursorModules.valueBuffer(u"idmodulo"),
                                    u".xpm (Regenerado).",
                                ),
                            ))
                    if not qsa.FileStatic.exists(
                            qsa.ustr(directorio, u"/",
                                     cursorModules.valueBuffer(u"idmodulo"),
                                     u".mod")):
                        contenido = qsa.ustr(
                            u"<!DOCTYPE MODULE>\n<MODULE>\n<name>",
                            cursorModules.valueBuffer(u"idmodulo"),
                            u'</name>\n<alias>QT_TRANSLATE_NOOP("FLWidgetApplication","',
                            cursorModules.valueBuffer(u"descripcion"),
                            u'")</alias>\n<area>',
                            cursorModules.valueBuffer(u"idarea"),
                            u'</area>\n<areaname>QT_TRANSLATE_NOOP("FLWidgetApplication","',
                            areaName,
                            u'")</areaname>\n<version>',
                            cursorModules.valueBuffer(u"version"),
                            u"</version>\n<icon>",
                            cursorModules.valueBuffer(u"idmodulo"),
                            u".xpm</icon>\n<flversion>",
                            cursorModules.valueBuffer(u"version"),
                            u"</flversion>\n<description>",
                            cursorModules.valueBuffer(u"idmodulo"),
                            u"</description>\n</MODULE>",
                        )
                        qsa.sys.write(
                            u"ISO-8859-1",
                            qsa.ustr(directorio, u"/",
                                     cursorModules.valueBuffer(u"idmodulo"),
                                     u".mod"),
                            contenido,
                        )
                        log.append(
                            qsa.util.translate(
                                u"scripts",
                                qsa.ustr(
                                    u"* Generando ",
                                    cursorModules.valueBuffer(u"idmodulo"),
                                    u".mod (Regenerado).",
                                ),
                            ))

                self.setDisabled(False)
                log.append(
                    qsa.util.translate(u"scripts",
                                       u"* Exportación finalizada."))
コード例 #11
0
    def cargarDeDisco(self, directorio: str, comprobarLicencia: bool) -> None:
        """Load a folder from file system."""
        if directorio:
            if comprobarLicencia:
                if not self.aceptarLicenciaDelModulo(directorio):
                    qsa.MessageBox.critical(
                        qsa.util.translate(
                            u"scripts",
                            u"Imposible cargar el módulo.\nLicencia del módulo no aceptada.",
                        ),
                        qsa.MessageBox.Ok,
                    )
                    return
            qsa.sys.cleanupMetaData()
            qsa.sys.processEvents()
            if self.cursor().commitBuffer():
                id_mod_widget = self.child(u"idMod")
                if id_mod_widget is not None:
                    id_mod_widget.setDisabled(True)
                log = self.child(u"log")

                if log is None:
                    raise Exception("log is empty!.")

                log.text = u""
                self.setDisabled(True)
                self.cargarFicheros(qsa.ustr(directorio, u"/"), u"*.xml")
                self.cargarFicheros(qsa.ustr(directorio, u"/"), u"*.mod")
                self.cargarFicheros(qsa.ustr(directorio, u"/"), u"*.xpm")
                self.cargarFicheros(qsa.ustr(directorio, u"/"),
                                    u"*.signatures")
                self.cargarFicheros(qsa.ustr(directorio, u"/"),
                                    u"*.certificates")
                self.cargarFicheros(qsa.ustr(directorio, u"/"), u"*.checksum")
                self.cargarFicheros(qsa.ustr(directorio, u"/forms/"), u"*.ui")
                self.cargarFicheros(qsa.ustr(directorio, u"/tables/"),
                                    u"*.mtd")
                self.cargarFicheros(qsa.ustr(directorio, u"/scripts/"),
                                    u"*.qs")
                self.cargarFicheros(qsa.ustr(directorio, u"/scripts/"),
                                    u"*.py")
                self.cargarFicheros(qsa.ustr(directorio, u"/queries/"),
                                    u"*.qry")
                self.cargarFicheros(qsa.ustr(directorio, u"/reports/"),
                                    u"*.kut")
                self.cargarFicheros(qsa.ustr(directorio, u"/reports/"),
                                    u"*.ar")
                self.cargarFicheros(qsa.ustr(directorio, u"/translations/"),
                                    u"*.ts")

                log.append(
                    qsa.util.translate(u"scripts", u"* Carga finalizada."))
                self.setDisabled(False)
                tdb_lineas = self.child(u"lineas")
                if tdb_lineas is not None:
                    tdb_lineas.refresh()
コード例 #12
0
    def editarFichero(self) -> None:
        """Edit a file."""
        qsa.MessageBox.warning(
            qsa.util.translate("scripts", "Opción no disponible"),
            qsa.MessageBox.Yes,
            qsa.MessageBox.NoButton,
        )
        return
        cursor = self.cursor()
        util = qsa.FLUtil()
        if cursor.checkIntegrity():
            self.child("nombre").setDisabled(True)
            nombre = cursor.valueBuffer("nombre")
            tipo = self.tipoDeFichero(nombre)
            temporal = qsa.System.getenv("TMP")
            if temporal == "":
                temporal = qsa.System.getenv("TMPDIR")
            if temporal == "":
                temporal = qsa.System.getenv("HOME")
            if temporal == "":
                from pineboolib.core.settings import config

                temporal = config.value("ebcomportamiento/temp_dir")

            temporal = qsa.ustr(temporal, "/", cursor.valueBuffer("nombre"))
            contenido = self.child("contenido").toPlainText()
            comando = ""
            if tipo == ".ui":
                if util.getOS() == "MACX":
                    qsa.FileStatic.write(
                        temporal, qsa.ustr(contenido, "\n\n\n\n\n\n\n\n\n\n\n\n\n\n")
                    )
                    comando = qsa.ustr(
                        qsa.sys.installPrefix(), "/bin/designer.app/Contents/MacOS/designer"
                    )
                else:
                    qsa.FileStatic.write(temporal, contenido)
                    comando = qsa.ustr(qsa.sys.installPrefix(), "/bin/designer")

                self.setDisabled(True)
                qsa.ProcessStatic.execute(qsa.Array([comando, temporal]))
                self.child(u"contenido").setText(qsa.FileStatic.read(temporal))
                self.setDisabled(False)
            elif tipo == ".ts":
                if util.getOS() == "MACX":
                    qsa.FileStatic.write(
                        temporal, qsa.ustr(contenido, "\n\n\n\n\n\n\n\n\n\n\n\n\n\n")
                    )
                    comando = qsa.ustr(
                        qsa.sys.installPrefix(), "/bin/linguist.app/Contents/MacOS/linguist"
                    )
                else:
                    qsa.FileStatic.write(temporal, contenido)
                    comando = qsa.ustr(qsa.sys.installPrefix(), "/bin/linguist")

                self.setDisabled(True)
                qsa.ProcessStatic.execute(qsa.Array([comando, temporal]))
                self.child("contenido").setText(qsa.FileStatic.read(temporal))
                self.setDisabled(False)
            elif tipo == ".kut":
                if util.getOS() == "MACX":
                    qsa.FileStatic.write(
                        temporal, qsa.ustr(contenido, "\n\n\n\n\n\n\n\n\n\n\n\n\n\n")
                    )
                    comando = qsa.ustr(
                        qsa.sys.installPrefix(), "/bin/kudesigner.app/Contents/MacOS/kudesigner"
                    )
                else:
                    qsa.FileStatic.write(temporal, contenido)
                    comando = qsa.ustr(qsa.sys.installPrefix(), "/bin/kudesigner")

                self.setDisabled(True)
                qsa.ProcessStatic.execute(qsa.Array([comando, temporal]))
                self.child("contenido").setText(qsa.FileStatic.read(temporal))
                self.setDisabled(False)

            elif tipo in (".qs", ".py"):
                self.setDisabled(True)
                editor_ = qsa.FLScriptEditor(nombre)
                editor_.exec_()
                self.child("contenido").setText(editor_.code())
                self.setDisabled(False)
            else:
                self.setDisabled(True)
                dialog = qsa.Dialog()
                dialog.setWidth(600)
                dialog.cancelButtonText = ""
                editor = qsa.TextEdit()
                if editor is None:
                    raise Exception("editor is empty!")
                editor.textFormat = editor.PlainText
                editor.text = contenido
                dialog.add(editor)
                dialog.exec_()
                self.child("contenido").setText(editor.text)
                self.setDisabled(False)
コード例 #13
0
ファイル: ebcomportamiento.py プロジェクト: Miguel-J/pineboo
 def initEventFilter(self) -> None:
     """Inicialize event filter."""
     w = self.w_
     w.eventFilterFunction = qsa.ustr(w.objectName(), u".eventFilter")
     w.allowedEvents = qsa.Array([qsa.AQS.Close])
     w.installEventFilter(w)
コード例 #14
0
ファイル: flreloadlast.py プロジェクト: Miguel-J/pineboo
    def cargarModulo(self, nombre_fichero: str) -> bool:
        """Load modules."""
        util = qsa.FLUtil()
        fichero = qsa.File(nombre_fichero, "iso-8859-15")
        modulo = None
        descripcion = None
        area = None
        desArea = None
        version = None
        nombreIcono = None
        # versionMinimaFL = None
        dependencias = qsa.Array()
        fichero.open(qsa.File.ReadOnly)
        f = fichero.read()
        xmlModule = qsa.FLDomDocument()
        if xmlModule.setContent(f):
            nodeModule = xmlModule.namedItem(u"MODULE")
            if not nodeModule:
                qsa.MessageBox.critical(
                    util.translate(u"scripts",
                                   u"Error en la carga del fichero xml .mod"),
                    qsa.MessageBox.Ok,
                    qsa.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:
            if not isinstance(f, str):
                raise Exception("data must be str, not bytes!!")
            aF = f.split(u"\n")
            modulo = self.dameValor(aF[0])
            descripcion = self.dameValor(aF[1])
            area = self.dameValor(aF[2]) or ""
            desArea = self.dameValor(aF[3])
            version = self.dameValor(aF[4])
            nombreIcono = self.dameValor(aF[5])

        descripcion = self.traducirCadena(descripcion or "", fichero.path
                                          or "", modulo or "")
        desArea = self.traducirCadena(desArea or "", fichero.path or "", modulo
                                      or "")
        fichIcono = qsa.File(qsa.ustr(fichero.path, u"/", nombreIcono))
        fichIcono.open(qsa.File.ReadOnly)
        icono = fichIcono.read()

        if not util.sqlSelect(u"flareas", u"idarea",
                              qsa.ustr(u"idarea = '", area, u"'")):
            if not util.sqlInsert(u"flareas", u"idarea,descripcion",
                                  qsa.ustr(area, u",", desArea)):
                qsa.MessageBox.warning(
                    util.translate(u"scripts", u"Error al crear el área:\n") +
                    area,
                    qsa.MessageBox.Ok,
                    qsa.MessageBox.NoButton,
                )
                return False
        recargar = util.sqlSelect(u"flmodules", u"idmodulo",
                                  qsa.ustr(u"idmodulo = '", modulo, u"'"))
        curModulo = qsa.FLSqlCursor(u"flmodules")
        if recargar:
            # WITH_START
            curModulo.select(qsa.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 = qsa.FLSqlCursor(u"flmodules")
        curModulo.setMainFilter(qsa.ustr(u"idmodulo = '", modulo, u"'"))
        curModulo.editRecord(False)
        qsa.from_project("formRecordflmodules").cargarDeDisco(
            qsa.ustr(fichero.path, u"/"), False)
        qsa.from_project("formRecordflmodules").accept()

        setting = "scripts/sys/modLastModule_%s" % qsa.sys.nameBD()
        nombre_fichero = "%s" % os.path.abspath(nombre_fichero)
        qsa.util.writeSettingEntry(setting, nombre_fichero)
        qsa.sys.processEvents()

        return True