Skip to content

Commit 6a415cd

Browse files
committed
Improve handling of PMR based workflows.
1 parent 6a032d5 commit 6a415cd

3 files changed

Lines changed: 16 additions & 8 deletions

File tree

src/mapclient/tools/pmr/pmrtool.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -384,17 +384,25 @@ def linkWorkspaceDirToUrl(self, local_workspace_dir, remote_workspace_url):
384384
# Do the writing.
385385
cmd.write_remote(workspace)
386386

387-
def is_pmr_workflow(self, local_workspace_dir):
388-
git_dir = os.path.join(local_workspace_dir, '.git')
389-
if os.path.isdir(git_dir):
387+
def is_pmr_workflow_accessible(self, local_workspace_dir):
388+
if self.is_pmr_workflow(local_workspace_dir):
390389
remote_workspace_url = get_workspace_url(local_workspace_dir)
391390
credentials = self.request_temporary_password(remote_workspace_url)
391+
if credentials is None:
392+
return False
393+
392394
cmd = self._cmd_class()
393395
cmd.set_authorization(create_authentication_header(credentials['user'], credentials['key']))
394396
workspace = CmdWorkspace(local_workspace_dir, cmd)
395397

396-
if workspace.cmd is None:
397-
return False
398+
return workspace.cmd is not None
399+
400+
return False
401+
402+
def is_pmr_workflow(self, local_workspace_dir):
403+
git_dir = os.path.join(local_workspace_dir, '.git')
404+
if os.path.isdir(git_dir):
405+
remote_workspace_url = get_workspace_url(local_workspace_dir)
398406

399407
url_parsed = urlparse(remote_workspace_url)
400408
for host_domain in self._pmr_info.hosts():

src/mapclient/tools/pmr/widgets/workspacewidget.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def _pull_from_pmr(self):
9494
pmr_info = PMR()
9595
pmr_tool = PMRTool(pmr_info, use_external_git=om.getOption(USE_EXTERNAL_GIT))
9696
workflow_dir = m.location()
97-
if pmr_tool.is_pmr_workflow(workflow_dir):
97+
if pmr_tool.is_pmr_workflow_accessible(workflow_dir):
9898
pmr_tool.pullFromRemote(workflow_dir)
9999
return True
100100

@@ -108,7 +108,7 @@ def _push_to_pmr(self):
108108
pmr_info = PMR()
109109
pmr_tool = PMRTool(pmr_info, use_external_git=om.getOption(USE_EXTERNAL_GIT))
110110
workflow_dir = m.location()
111-
if pmr_tool.is_pmr_workflow(workflow_dir):
111+
if pmr_tool.is_pmr_workflow_accessible(workflow_dir):
112112
pmr_tool.pushToRemote(workflow_dir)
113113
return True
114114

src/mapclient/view/workflow/workflowwidget.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ def _commitChanges(self, workflowDir, comment):
582582
except Exception:
583583
logger.exception('Error')
584584
raise ClientRuntimeError(
585-
'Error Saving', 'The commit to PMR did not succeed')
585+
'Error Saving', 'The commit to workflow did not succeed')
586586

587587
return committed_changes
588588

0 commit comments

Comments
 (0)