Example #1
0
def addFiles():
    if not "files" in config:
        print "ERROR: No files given"
        sys.exit(2)

    if not "spec" in config:
        print "ERROR: Spec not set"
        sys.exit(2)

    e = ueAssetUtils.getElement(config["spec"])
    if e == {}:
        e = ueCreate.createElement(config["spec"])

    v = ueCreate.createVersion(config["spec"])

    config["spec"].vers = v["version"]

    files = glob.glob(config["files"])

    path = v["path"]
    name = v["file_name"]
    ext = files[0].split(".")[-1]

    if len(files) == 1:
        dest = os.path.join(path, "%s.%s" % (name, ext))
        ueFileUtils.copyFile(files[0], dest)
    else:
        for f in sorted(files):
            dest = os.path.join(path,
                                "%s.%04d.%s" % (name, files.index(f) + 1, ext))
            ueFileUtils.copyFile(f, dest)
Example #2
0
File: ueAddFiles.py Project: hdd/ue
def addFiles():
    if not "files" in config:
        print "ERROR: No files given"
        sys.exit(2)

    if not "spec" in config:
        print "ERROR: Spec not set"
        sys.exit(2)

    e = ueAssetUtils.getElement(config["spec"])
    if e == {}:
        e = ueCreate.createElement(config["spec"])

    v = ueCreate.createVersion(config["spec"])

    config["spec"].vers = v["version"]

    files = glob.glob(config["files"])

    path = v["path"]
    name = v["file_name"]
    ext = files[0].split(".")[-1]

    if len(files) == 1:
        dest = os.path.join(path, "%s.%s" % (name, ext))
        ueFileUtils.copyFile(files[0], dest)
    else:
        for f in sorted(files):
            dest = os.path.join(path, "%s.%04d.%s" % (name, files.index(f)+1, ext))
            ueFileUtils.copyFile(f, dest)
Example #3
0
    def createScript(self):
        job = {}

        if self.run == "nuke":
            ext = "nk"

        proj = ueAssetUtils.getProject(self.destSpec)
        asst = ueAssetUtils.getAsset(self.destSpec)

        versions = ueAssetUtils.getVersions(self.sourceSpec)
        version = versions[len(versions) - 1]

        p = os.path.join(version["path"], version["file_name"] + "." + ext)

        for f in range(self.frame_start, self.frame_end + 1):
            frame = {}
            if self.run == "nuke":
                frame["cmd"] = "nuke -x -V -f -X %s -F %i-%i %s" % (",".join(
                    self.options["writeNode"]), f, f, p)
            frame["proj"] = self.destSpec.proj
            frame["grp"] = self.destSpec.grp
            frame["asst"] = self.destSpec.asst
            frame["proj_root"] = proj["path"]
            frame["asst_root"] = asst["path"]
            job[f] = frame

        versions = ueAssetUtils.getVersions(self.destSpec)
        version = versions[len(versions) - 1]

        p = os.path.join(
            asst["path"], "tmp", "drQueue",
            version["file_name"] + "." + str(int(time.time())) + ".dq")

        if not os.path.exists(os.path.dirname(p)):
            import ueCore.FileUtils as ueFileUtils
            ueFileUtils.createDir(os.path.dirname(p))

        try:
            f = open(p, "w")
            f.write(json.dumps(job, sort_keys=True, indent=4))
            f.close()
        except IOError, e:
            print "ERROR: Creating job script '%s' (%s)" % (p, e)
            sys.exit(2)
Example #4
0
File: Job.py Project: hdd/ue
    def createScript(self):
        job = {}

        if self.run == "nuke":
            ext = "nk"

        proj = ueAssetUtils.getProject(self.destSpec)
        asst = ueAssetUtils.getAsset(self.destSpec)

        versions = ueAssetUtils.getVersions(self.sourceSpec)
        version = versions[len(versions)-1]

        p = os.path.join(version["path"], version["file_name"]+"."+ext)

        for f in range(self.frame_start, self.frame_end+1):
            frame = {}
            if self.run == "nuke":
                frame["cmd"] = "nuke -x -V -f -X %s -F %i-%i %s" % (",".join(self.options["writeNode"]),
                                                                    f, f, p)
            frame["proj"] = self.destSpec.proj
            frame["grp"] = self.destSpec.grp
            frame["asst"] = self.destSpec.asst
            frame["proj_root"] = proj["path"]
            frame["asst_root"] = asst["path"]
            job[f] = frame

        versions = ueAssetUtils.getVersions(self.destSpec)
        version = versions[len(versions)-1]

        p = os.path.join(asst["path"], "tmp", "drQueue", version["file_name"]+"."+str(int(time.time()))+".dq")

        if not os.path.exists(os.path.dirname(p)):
            import ueCore.FileUtils as ueFileUtils
            ueFileUtils.createDir(os.path.dirname(p))

        try:
            f = open(p, "w")
            f.write(json.dumps(job, sort_keys=True, indent=4))
            f.close()
        except IOError, e:
            print "ERROR: Creating job script '%s' (%s)" % (p, e)
            sys.exit(2)
Example #5
0
File: Save.py Project: hdd/ue
def ueSaveAs():
#    if not ueNuke.ueScriptSanityCheck():
#        return

    app = QtGui.QApplication.allWidgets()
    i = 0
    for widget in app:
        if str(type(widget)) == "<class 'PyQt4.QtGui.QStackedWidget'>":
            name = "ueSaveThumbs_%04d.png" % i
            QtGui.QPixmap.grabWindow(widget.winId()).save(os.path.join(os.getenv("ASST_ROOT"), "tmp", name), "png")
            i += 1

    p = nukescripts.registerWidgetAsPanel("ueCommonSave.Save", "ueSave",
                                          "ue.panel.ueSave", create=True)
    p.setMinimumSize(400, 600)
    ueCommonSave.setClasses(__ueclasses__)

    if p.showModalDialog():
        spec, dbMeta = ueCommonSave.getValues()
        ueNukeUtils.saveUtility(spec, dbMeta=dbMeta)

    ueFileUtils.deleteFiles(os.path.join(os.path.join(os.getenv("ASST_ROOT"), "tmp", "ueSaveThumbs_*.png")))
    nukescripts.unregisterPanel("ue.panel.ueSave", lambda: "return")
Example #6
0
def saveUtility(spec, dbMeta={}):
    root = nuke.root()

    e = ueAssetUtils.getElement(spec)
    if e == {}:
        e = ueCreate.createElement(spec, dbMeta=dbMeta)

    v = ueCreate.createVersion(spec, dbMeta=dbMeta)

    spec.vers = v["version"]

    nkPath = v["path"]
    nkName = v["file_name"]
    f = os.path.join(nkPath, nkName+".nk")

    if root.knob("ueproj") == None:
        root.addKnob(nuke.String_Knob("ueproj", "project", spec.proj))
    else:
        root.knob("ueproj").setValue(spec.proj)

    if root.knob("uegrp") == None:
        root.addKnob(nuke.String_Knob("uegrp", "group", spec.grp))
    else:
        root.knob("uegrp").setValue(spec.grp)

    if root.knob("ueasst") == None:
        root.addKnob(nuke.String_Knob("ueasst", "asset", spec.asst))
    else:
        root.knob("ueasst").setValue(spec.asst)

    if root.knob("ueclass") == None:
        root.addKnob(nuke.String_Knob("ueclass", "class", spec.elclass))
    else:
        root.knob("ueclass").setValue(spec.elclass)

    if root.knob("uetype") == None:
        root.addKnob(nuke.String_Knob("uetype", "type", spec.eltype))
    else:
        root.knob("uetype").setValue(spec.eltype)

    if root.knob("uename") == None:
        root.addKnob(nuke.String_Knob("uename", "name", spec.elname))
    else:
        root.knob("uename").setValue(spec.elname)

    if root.knob("uevers") == None:
        root.addKnob(nuke.Int_Knob("uevers", "vers", spec.vers))
        # Nuke bug? Passing a value into Int_Knob doesn't actually set the value
        # on the knob. Calling setValue explicitly to get around this.
        root.knob("uevers").setValue(spec.vers)
    else:
        root.knob("uevers").setValue(spec.vers)

    if root.knob("version_path") == None:
        root.addKnob(nuke.String_Knob("version_path", "version_path", nkPath))
    else:
        root.knob("version_path").setValue(nkPath)

    nuke.scriptSaveAs(f)

    if "thumbnail" in v:
        source = os.path.join(os.getenv("ASST_ROOT"), "tmp", "ueSaveThumbs_"+str(v["thumbnail"])+".png")
        dest = os.path.join(os.getenv("PROJ_ROOT"), "var", "thumbs", spec.grp, spec.asst, nkName+".png")
        if not os.path.exists(os.path.dirname(dest)):
            ueFileUtils.createDir(os.path.dirname(dest))
        ueFileUtils.moveFile(source, dest)

    nuke.tprint("Saved %s" % spec)