Skip to content

Commit

Permalink
Check is_pmr_workflow when committing changes
Browse files Browse the repository at this point in the history
  • Loading branch information
tsalemink committed Oct 2, 2023
1 parent d4fe4ce commit 686326f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
16 changes: 13 additions & 3 deletions src/mapclient/tools/pmr/pmrtool.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ class PMRTool(object):
PROTOCOL = 'application/vnd.physiome.pmr2.json.0'
UA = 'pmr.jsonclient.Client/0.2'

PMR_URLS = [
"https://models.physiomeproject.org/workspace",
"https://teaching.physiomeproject.org/workspace"
]

def __init__(self, pmr_info=None, use_external_git=False):
self._termLookUpLimit = 32
self.set_info(pmr_info)
Expand Down Expand Up @@ -387,16 +392,21 @@ def linkWorkspaceDirToUrl(self, local_workspace_dir, remote_workspace_url):
# Do the writing.
cmd.write_remote(workspace)

def hasDVCS(self, local_workspace_dir):
def is_pmr_workflow(self, local_workspace_dir):
git_dir = os.path.join(local_workspace_dir, '.git')
if os.path.isdir(git_dir):
bob = get_cmd_by_name(self._git_implementation)()
workspace = CmdWorkspace(local_workspace_dir, bob)
return workspace.cmd is not None
if workspace.cmd is None:
return False

remote_workspace_url = workspace.cmd.read_remote(workspace)
url = remote_workspace_url[:remote_workspace_url.rfind('/')]
return url in self.PMR_URLS

else:
return False


def commitFiles(self, local_workspace_dir, message, files):
workspace = CmdWorkspace(local_workspace_dir, get_cmd_by_name(self._git_implementation)())
cmd = workspace.cmd
Expand Down
4 changes: 2 additions & 2 deletions src/mapclient/view/workflow/workflowwidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ def commitChanges(self, workflowDir):
om = self._main_window.model().optionsManager()
pmr_info = PMR()
pmr_tool = PMRTool(pmr_info, use_external_git=om.getOption(USE_EXTERNAL_GIT))
if not pmr_tool.hasDVCS(workflowDir):
if not pmr_tool.is_pmr_workflow(workflowDir):
# nothing to commit.
return True

Expand Down Expand Up @@ -614,7 +614,7 @@ def _setIndexerFile(self, workflow_dir):
pmr_info = PMR()
pmr_tool = PMRTool(pmr_info, use_external_git=om.getOption(USE_EXTERNAL_GIT))

if not pmr_tool.hasDVCS(workflow_dir):
if not pmr_tool.is_pmr_workflow(workflow_dir):
return
try:
pmr_tool.addFileToIndexer(workflow_dir, DEFAULT_WORKFLOW_ANNOTATION_FILENAME)
Expand Down

0 comments on commit 686326f

Please sign in to comment.