Skip to content
Snippets Groups Projects
Commit b12ab103 authored by Lorenz Hüdepohl's avatar Lorenz Hüdepohl
Browse files

Fix handling of missing packages in mpcdf_remove

parent 456b8ce7
No related branches found
No related tags found
No related merge requests found
from __future__ import print_function
import os import os
import osc import osc
import osc.conf import osc.conf
import osc.core import osc.core
import osc.cmdln import osc.cmdln
import urllib
@osc.cmdln.option('--ignore-missing', action="store_true",
help="Ignore if package is missing in some/all sub-projects")
def do_mpcdf_remove(self, subcmd, opts, *args): def do_mpcdf_remove(self, subcmd, opts, *args):
"""${cmd_name}: Removes a package from all sub-projects of software: """mpcdf_remove: Removes a package from all sub-projects of software:
Usage: Usage:
osc ${cmd_name} [PACKAGE] osc mpcdf_remove [PACKAGE]
${cmd_option_list}
""" """
if len(args) == 0: if len(args) == 0:
...@@ -34,8 +31,15 @@ def do_mpcdf_remove(self, subcmd, opts, *args): ...@@ -34,8 +31,15 @@ def do_mpcdf_remove(self, subcmd, opts, *args):
if p.startswith("software:") and not (p == "software:dist" or p == "software:images")] if p.startswith("software:") and not (p == "software:dist" or p == "software:images")]
for project in projects: for project in projects:
print("Removing from", project) print("Removing from", project, "...")
osc.core.delete_package(api_url, project, package) try:
osc.core.delete_package(api_url, project, package)
except urllib.error.HTTPError as e:
if e.code == 404 and opts.ignore_missing:
print(" .. not present there!")
continue
else:
raise
print("\nThe package still exists in 'software', you can undo what you did with\n\n" print("\nThe package still exists in 'software', you can undo what you did with\n\n"
" osc mcpdf_push\n\n" " osc mcpdf_push\n\n"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment