Permalink
Browse files

Improved logging for planemo.

Per @nsoranzo's suggestions (and rebased with @nsoranzo's fixes).
  • Loading branch information...
jmchilton committed Jan 30, 2017
1 parent fca4183 commit 08c067c1d3375a1697816fcbe7e96419f41e28d2
Showing with 31 additions and 9 deletions.
  1. +13 −8 planemo/commands/cmd_shed_update.py
  2. +18 −1 planemo/shed/__init__.py
@@ -95,29 +95,31 @@ def update(realized_repository):
# Now that we've uploaded (or skipped appropriately), collect results.
if upload_ret_code == 2:
collected_data['results']['failures'] += 1
message = "Failed to update repository '%s' as it does not exist on the %s." % (realized_repository.name, shed_context.label)
repo_result.update({
'errorType': 'FailedUpdate',
'errorMessage': 'Failed to update repository as it does not exist in target ToolShed',
'errorMessage': message,
})
collected_data['tests'].append(repo_result)
error("Failed to update repository it does not exist "
"in target ToolShed.")
error(message)
return upload_ret_code

exit = 0
metadata_ok = True
repository_destination_label = "repository '%s' on the %s" % (realized_repository.name, shed_context.label)
if not skip_metadata:
repo_id = shed.handle_force_create(realized_repository, ctx, shed_context, **kwds)
# failing to create the repo, give up
if repo_id is None:
exit = shed.report_non_existent_repository(realized_repository)
metadata_ok = False
error("Failed to update metadata for repository %s." % realized_repository.name)
error("Failed to update metadata for %s." % repository_destination_label)
else:
metadata_ok = realized_repository.update(ctx, shed_context, repo_id)
info("Repository metadata updated successfully for repository %s." % realized_repository.name)
if metadata_ok:
info("Repository metadata updated successfully for %s." % repository_destination_label)
else:
info("Skipping metadata update for repository %s." % realized_repository.name)
info("Skipping metadata update for %s" % repository_destination_label)

if metadata_ok and upload_ok:
pass
@@ -128,15 +130,18 @@ def update(realized_repository):
'errorMessage': 'Failed to update repository metadata',
})
if not skip_upload:
error("Repo updated but metadata was not.")
error("Repository contents updated but failed to update metadata for %s." % repository_destination_label)
exit = exit or 1
else:
collected_data['results']['failures'] += 1
repo_result.update({
'errorType': 'FailedUpdate',
'errorMessage': 'Failed to update repository',
})
error("Failed to update a repository.")
if metadata_ok:
error("Failed to update repository contents for %s." % repository_destination_label)
else:
error("Failed to update repository contents and metadata for %s." % repository_destination_label)
exit = exit or 1
collected_data['tests'].append(repo_result)
return exit
@@ -84,7 +84,12 @@
SHED_SHORT_NAMES = {
"toolshed": "https://toolshed.g2.bx.psu.edu/",
"testtoolshed": "https://testtoolshed.g2.bx.psu.edu/",
"local": "http://localhost:9009/"
"local": "http://localhost:9009/",
}
SHED_LABELS = {
"toolshed": "main Tool Shed",
"testtoolshed": "test Tool Shed",
"local": "local Tool Shed",
}
REPO_TYPE_UNRESTRICTED = "unrestricted"
REPO_TYPE_TOOL_DEP = "tool_dependency_definition"
@@ -172,7 +177,13 @@ def _shed_context_owner(self):
return owner


@property
def _shed_context_label(self):
return self.shed_config.get("label") or "tool shed"


ShedContext.owner = _shed_context_owner
ShedContext.label = _shed_context_label


def shed_init(ctx, path, **kwds):
@@ -466,6 +477,12 @@ def _shed_config_and_username(ctx, **kwds):
else:
shed_config["url"] = shed_target

if "label" not in shed_config:
if shed_target and shed_target in SHED_LABELS:
shed_config["label"] = SHED_LABELS[shed_target]
else:
shed_config["label"] = "custom tool shed at %s" % shed_target

default_shed_username = global_config.get("shed_username", None)
username = shed_config.get("username", default_shed_username)

0 comments on commit 08c067c

Please sign in to comment.