Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

Commit

Permalink
Fixed to error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
adammhaile committed Dec 14, 2018
1 parent cec6338 commit 5beaee8
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 9 deletions.
2 changes: 1 addition & 1 deletion doozer
Original file line number Diff line number Diff line change
Expand Up @@ -1364,7 +1364,7 @@ def main():
# nicely instead of a gross stack-trace.
# All internal errors that should simply cause the app
# to exit with an error code should use DoozerFatalError
red_print(ex.message)
red_print('\nDoozer Failed With Error:\n' + ex.message)
sys.exit(1)


Expand Down
27 changes: 23 additions & 4 deletions doozerlib/distgit.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import yaml
import logging
import bashlex
import glob

from dockerfile_parse import DockerfileParser

Expand All @@ -19,6 +20,7 @@
from pushd import Dir
from brew import watch_task, check_rpm_buildroot
from model import Model, Missing
from . exceptions import DoozerFatalError

OIT_COMMENT_PREFIX = '#oit##'
OIT_BEGIN = '##OIT_BEGIN'
Expand Down Expand Up @@ -1184,8 +1186,25 @@ def _merge_source(self):
if os.path.isfile("Dockerfile"):
os.remove("Dockerfile")

# Rename our distgit source Dockerfile appropriately
os.rename(dockerfile_name, "Dockerfile")
try:
# Rename our distgit source Dockerfile appropriately
if not os.path.isfile(dockerfile_name):
options = glob.glob('Dockerfile*')
if options:
options = '\nTry one of these{}\n'.format(options)
else:
options = ''

url = self.source_url
if self.config.content.source.path is not Missing:
rc, out, err = exectools.cmd_gather(["git", "rev-parse", "--abbrev-ref", "HEAD"])
branch = out.strip()
url = '{}/tree/{}/{}'.format(url, branch, self.config.content.source.path)
raise DoozerFatalError('{}:{} does not exist in @ {}{}'
.format(self.name, dockerfile_name, url, options))
os.rename(dockerfile_name, "Dockerfile")
except OSError as err:
raise DoozerFatalError(err.message)

# Clean up any extraneous Dockerfile.* that might be distractions (e.g. Dockerfile.centos)
for ent in os.listdir("."):
Expand Down Expand Up @@ -1275,8 +1294,8 @@ def _run_modifications(self):
pre = dockerfile_data
dockerfile_data = pre.replace(match, replacement)
if dockerfile_data == pre:
raise IOError("Replace (%s->%s) modification did not make a change to the Dockerfile content" % (
match, replacement))
raise DoozerFatalError("{}: Replace ({}->{}) modification did not make a change to the Dockerfile content"
.format(self.name, match, replacement))
self.logger.debug(
"Performed string replace '%s' -> '%s':\n%s\n" %
(match, replacement, dockerfile_data))
Expand Down
7 changes: 4 additions & 3 deletions doozerlib/rpmcfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from metadata import Metadata
from model import Missing
from . exceptions import DoozerFatalError

RELEASERS_CONF = """
[aos]
Expand Down Expand Up @@ -48,7 +49,7 @@ def __init__(self, runtime, data_obj, clone_source=True):
self.specfile = os.path.join(self.source_path, self.source.specfile)
if not os.path.isfile(self.specfile):
raise ValueError('{} config specified a spec file that does not exist: {}'.format(
config_filename, self.specfile
self.config_filename, self.specfile
))
else:
with Dir(self.source_path):
Expand Down Expand Up @@ -125,8 +126,8 @@ def _run_modifications(self):
pre = specfile_data
specfile_data = pre.replace(match, replacement)
if specfile_data == pre:
raise IOError("Replace (%s->%s) modification did not make a change to the Dockerfile content" % (
match, replacement))
raise DoozerFatalError("{}: Replace ({}->{}) modification did not make a change to the spec file content"
.format(self.name, match, replacement))
self.logger.debug(
"Performed string replace '%s' -> '%s':\n%s\n" %
(match, replacement, specfile_data))
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def _get_version():


setup(
name="rh-doozer",
name="doozer",
author="AOS ART Team",
author_email="aos-team-art@redhat.com",
version=_get_version(),
Expand Down

0 comments on commit 5beaee8

Please sign in to comment.