示例#1
0
def translate(path):
    files = []
    tsfiles = []
    for name in os.listdir(path):
        if name.endswith((".py", ".pyw")):
            files.append(os.path.join(path, name))
        elif name.endswith(".ts"):
            tsfiles.append(os.path.join(path, name))
    if not tsfiles:
        return
    verbose = "-verbose" if Verbose else ""
    silent = "-silent" if not Verbose else ""
    process = QtCore.QProcess()
    for ts in tsfiles:
        qm = ts[:-3] + ".qm"
        command1 = PYLUPDATE5
        args1 = [verbose] + files + ["-ts", ts]
        command2 = LRELEASE
        args2 = [silent, ts, "-qm", qm]
        if Debug:
            print "updated", ts
            print "generated", qm
        else:
            process.start(command1, args1)
            if not process.waitForFinished(2 * 60 * 1000):
                report_failure(command1, args1, process)
            process.start(command2, args2)
            if not process.waitForFinished(2 * 60 * 1000):
                report_failure(command2, args2, process)
示例#2
0
def build(path):
    for name in os.listdir(path):
        source = os.path.join(path, name)
        target = None
        if source.endswith(".ui"):
            target = os.path.join(path, name.replace(".ui", ".py"))
            command = PYUIC5
        elif source.endswith(".qrc"):
            (fname, fext) = os.path.splitext(name)
            target = os.path.join(path, fname + "_rc.py")
            #target = os.path.join ( path, "qrc_" + name.replace(".qrc", ".py" ) )
            command = PYRCC5
        process = QtCore.QProcess()
        if target is not None:
            if not os.access ( target, os.F_OK) or (
             os.stat ( source ) [ stat.ST_MTIME ] > \
             os.stat ( target ) [ stat.ST_MTIME ] ):
                args = ["-o", target, source]
                if sys.platform.startswith("darwin") and command == PYUIC5:
                    #command = sys.executable
                    #args = [PYUIC4] + args
                    command = PYUIC5
                if Debug:
                    print "# %s %s" % (command, " ".join(args))
                else:
                    if Verbose:
                        print "# %s %s" % (command, " ".join(args))
                    process.start(command, args)
                    if not process.waitForFinished(2 * 60 * 1000):
                        report_failure(command, args, process)
                    else:
                        print source, "->", target
            elif Verbose:
                print source, "is up-to-date"