def checkout_button_clicked(self): version = self.rollback_dialog.get_current_item()[1:] filePath = common.get_checkin_path() toCheckout = amu.getCheckinDest(filePath) latestVersion = amu.tempSetVersion(toCheckout, version) amu.discard(filePath) try: destpath = amu.checkout(toCheckout, True) except Exception as e: if not amu.checkedOutByMe(toCheckout): muke.message(str(e)) return else: destpath = amu.getCheckoutDest(toCheckout) amu.tempSetVersion(toCheckout, latestVersion) # move to correct checkout directory correctCheckoutDir = amu.getCheckoutDest(toCheckout) if not destpath == correctCheckoutDir: if os.path.exists(correctCheckoutDir): shutil.rmtree(correctCheckoutDir) os.rename(destpath, correctCheckoutDir) toOpen = os.path.join(correctCheckoutDir, self.get_filename(toCheckout)+'.nk') if not os.path.exists(toOpen): # create new file nuke.scriptNew() nuke.scriptSaveAs(filename=toOpen, overwrite=0) else: nuke.scriptOpen(toOpen) self.rollback_dialog.close()
def checkout_button_clicked(self): version = self.rollback_dialog.get_current_item()[1:] filePath = common.get_checkin_path() toCheckout = amu.getCheckinDest(filePath) latestVersion = amu.tempSetVersion(toCheckout, version) amu.discard(filePath) try: destpath = amu.checkout(toCheckout, True) except Exception as e: if not amu.checkedOutByMe(toCheckout): muke.message(str(e)) return else: destpath = amu.getCheckoutDest(toCheckout) amu.tempSetVersion(toCheckout, latestVersion) # move to correct checkout directory correctCheckoutDir = amu.getCheckoutDest(toCheckout) if not destpath == correctCheckoutDir: if os.path.exists(correctCheckoutDir): shutil.rmtree(correctCheckoutDir) os.rename(destpath, correctCheckoutDir) toOpen = os.path.join(correctCheckoutDir, self.get_filename(toCheckout) + '.nk') if not os.path.exists(toOpen): # create new file nuke.scriptNew() nuke.scriptSaveAs(filename=toOpen, overwrite=0) else: nuke.scriptOpen(toOpen) self.rollback_dialog.close()
def restartNuke(): if nuke.ask('Are you sure you want to restart Nuke?'): scriptName = nuke.root().knob('name').getValue() subprocess_options = {"shell": True} separate_terminal_options = { "close_fds": True, "preexec_fn": os.setsid } if nuke.env['nukex'] == True: session = '--nukex' else: session = '--nuke' if 'REZ_VOLT_SESSION_ROOT' in os.environ: subprocess_options.update(separate_terminal_options) if os.path.isfile(scriptName): nuke.scriptSave() launch_cmd = '{} {} {}'.format(sys.executable, session, scriptName) subprocess.Popen(launch_cmd, **subprocess_options) nuke.modified(False) nuke.scriptExit() else: nuke.scriptNew('') nuke.modified(False) nuke.scriptExit()
def restartNuke(): """ Restarts Nuke. :return: None """ # https://community.foundry.com/discuss/topic/135555/ nuke.scriptNew('') nuke.modified(False) # doesn't ask for saving nuke.scriptExit()
def discard(): file_path = get_file_path() if file_path: toDiscard = get_checkin_path() if amu.isCheckedOutCopyFolder(toDiscard): if show_confirm_dialog(): nuke.scriptNew() amu.discard(toDiscard) else: show_dialog('ERROR: Not checked out.') else: show_dialog('ERROR: Not a file.')
def checkout(self): asset_name = self.checkout_dialog.get_current_item() toCheckout = os.path.join(os.environ['SHOTS_DIR'], asset_name,'compositing') try: destpath = amu.checkout(toCheckout, True) except Exception as e: if not amu.checkedOutByMe(toCheckout): nuke.message(str(e)) return else: destpath = amu.getCheckoutDest(toCheckout) #nuke.message("destpath = " + destpath) toOpen = os.path.join(destpath,self.get_filename(toCheckout)+'.nk') #nuke.message("toOpen = " + toOpen) #nuke.scriptClose() if not os.path.exists(toOpen): nuke.scriptNew() nuke.scriptSaveAs(filename=toOpen, overwrite=1) else: nuke.scriptOpen(toOpen) nuke.message('Checkout Successful')
def newComp(self): self.afterOpen() if inNuke == True: nuke.scriptNew()
def new_scene(new_window=False): if not new_window: clear_script() else: nuke.scriptNew()