Skip to content

Commit

Permalink
Shifter: adding Edit button on message window when custom step fails c…
Browse files Browse the repository at this point in the history
…loses #450
  • Loading branch information
miquelcampos committed Feb 7, 2025
1 parent 2c55d19 commit a624195
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions release/scripts/mgear/shifter/guide.py
Original file line number Diff line number Diff line change
Expand Up @@ -1374,19 +1374,24 @@ def get_cs_file_fullpath(self, cs_data):

return fullpath

@classmethod
def _editFile(cls, fullpath):

if sys.platform.startswith("darwin"):
subprocess.call(("open", fullpath))
elif os.name == "nt":
os.startfile(fullpath)
elif os.name == "posix":
subprocess.call(("xdg-open", fullpath))

def editFile(self, widgetList):
for cs in widgetList.selectedItems():
try:
cs_data = cs.text()
fullpath = self.get_cs_file_fullpath(cs_data)

if fullpath:
if sys.platform.startswith("darwin"):
subprocess.call(("open", fullpath))
elif os.name == "nt":
os.startfile(fullpath)
elif os.name == "posix":
subprocess.call(("xdg-open", fullpath))
self._editFile(fullpath)
else:
pm.displayWarning("Please select one item from the list")
except Exception:
Expand Down Expand Up @@ -1432,7 +1437,7 @@ def shared_owner(self, cs_fullpath):
return os.path.split(scan_dir)[1]

@classmethod
def get_steps_dict(self, itemsList):
def get_steps_dict(cls, itemsList):
stepsDict = {}
stepsDict["itemsList"] = itemsList
for item in itemsList:
Expand All @@ -1444,7 +1449,7 @@ def get_steps_dict(self, itemsList):
return stepsDict

@classmethod
def runStep(self, stepPath, customStepDic):
def runStep(cls, stepPath, customStepDic):
try:
with pm.UndoChunk():
pm.displayInfo("EXEC: Executing custom step: %s" % stepPath)
Expand Down Expand Up @@ -1500,18 +1505,21 @@ def runStep(self, stepPath, customStepDic):
+ traceback.format_exc(),
"Continue",
"Stop Build",
"Edit",
"Try Again!",
)
if cont == "Stop Build":
# stop Build
return True
elif cont == "Edit":
cls._editFile(stepPath)
elif cont == "Try Again!":
try: # just in case there is nothing to undo
pm.undo()
except Exception:
pass
pm.displayInfo("Trying again! : {}".format(stepPath))
inception = self.runStep(stepPath, customStepDic)
inception = cls.runStep(stepPath, customStepDic)
if inception: # stops build from the recursion loop.
return True
else:
Expand Down

0 comments on commit a624195

Please sign in to comment.