Improved error messages for configuration errors.
Review Request #248 - Created April 1, 2011 and submitted
Alain Linden | Reviewers | ||
CHOP-180 | oz.linden, brad.linden, jenn, nat_linden | ||
None | autobuild |
Improved error messages in response to CHOP-180.
Diff revision 1
This is not the most recent revision of the diff. The latest diff is revision 2. See what's changed.
1
2
|
|
1
2
|
autobuild/configfile.py | |||
---|---|---|---|
Revision 1d9938bed21d | New Change | ||
... | 90 lines hidden [Expand] | ||
def get_all_build_configurations(self, platform_name=get_current_platform()): |
|||
91 |
|
91 |
|
92 |
def get_build_configuration(self, build_configuration_name, platform_name=get_current_platform()): |
92 |
def get_build_configuration(self, build_configuration_name, platform_name=get_current_platform()): |
93 |
"""
|
93 |
"""
|
94 |
Returns the named build configuration for the platform.
|
94 |
Returns the named build configuration for the platform.
|
95 |
"""
|
95 |
"""
|
96 |
build_configuration = \ |
96 |
build_configuration = \ |
97 |
self.get_platform(platform_name).configurations.get(build_configuration_name, None) |
97 |
self.get_platform(platform_name).configurations.get(build_configuration_name, None) |
98 |
if build_configuration is not None: |
98 |
if build_configuration is not None: |
99 |
return build_configuration |
99 |
return build_configuration |
100 |
else: |
100 |
else: |
101 | raise ConfigurationError("no configuration for build configuration '%s'" % |
101 | raise ConfigurationError("no configuration for build configuration '%s' found; one may be created using 'autobuild edit build'" % |
102 |
build_configuration_name) |
102 |
build_configuration_name) |
103 |
|
103 |
|
104 |
def get_build_directory(self, platform_name=get_current_platform()): |
104 |
def get_build_directory(self, platform_name=get_current_platform()): |
105 |
"""
|
105 |
"""
|
106 |
Returns the absolute path to the build directory for the platform.
|
106 |
Returns the absolute path to the build directory for the platform.
|
107 |
"""
|
107 |
"""
|
108 |
if self.package_description is None: |
108 |
if self.package_description is None: |
109 | raise ConfigurationError('no package configuration defined') |
109 | raise ConfigurationError("no package configuration defined; one may be created using 'autobuild edit package'") |
110 |
platform_description = self.package_description.platforms.get(platform_name, None) |
110 |
platform_description = self.package_description.platforms.get(platform_name, None) |
111 |
if platform_description is None: |
111 |
if platform_description is None: |
112 | raise ConfigurationError("no configuration for platform '%s'" % platform_name) |
112 | raise ConfigurationError("no configuration for platform '%s' found; one may be created using 'autobuild edit platform'" % platform_name) |
113 |
common_platform_description = self.package_description.platforms.get('common', None) |
113 |
common_platform_description = self.package_description.platforms.get('common', None) |
114 |
config_directory = os.path.dirname(self.path) |
114 |
config_directory = os.path.dirname(self.path) |
115 |
if platform_description.build_directory is not None: |
115 |
if platform_description.build_directory is not None: |
116 |
build_directory = platform_description.build_directory |
116 |
build_directory = platform_description.build_directory |
117 |
if not os.path.isabs(build_directory): |
117 |
if not os.path.isabs(build_directory): |
118 |
build_directory = os.path.abspath(os.path.join(config_directory, build_directory)) |
118 |
build_directory = os.path.abspath(os.path.join(config_directory, build_directory)) |
119 |
elif common_platform_description is not None and common_platform_description.build_directory is not None: |
119 |
elif common_platform_description is not None and common_platform_description.build_directory is not None: |
120 |
build_directory = common_platform_description.build_directory |
120 |
build_directory = common_platform_description.build_directory |
121 |
if not os.path.isabs(build_directory): |
121 |
if not os.path.isabs(build_directory): |
122 |
build_directory = os.path.abspath(os.path.join(config_directory, build_directory)) |
122 |
build_directory = os.path.abspath(os.path.join(config_directory, build_directory)) |
... | 9 lines hidden [Expand] | ||
def get_default_build_configurations(self, platform_name=get_current_platform()): |
|||
132 |
for (key, value) in self.get_platform(platform_name).configurations.iteritems(): |
132 |
for (key, value) in self.get_platform(platform_name).configurations.iteritems(): |
133 |
if value.default: |
133 |
if value.default: |
134 |
default_build_configurations.append(value) |
134 |
default_build_configurations.append(value) |
135 |
return default_build_configurations |
135 |
return default_build_configurations |
136 |
|
136 |
|
137 |
def get_platform(self, platform_name): |
137 |
def get_platform(self, platform_name): |
138 |
"""
|
138 |
"""
|
139 |
Returns the named platform description.
|
139 |
Returns the named platform description.
|
140 |
"""
|
140 |
"""
|
141 |
if self.package_description is None: |
141 |
if self.package_description is None: |
142 | raise ConfigurationError('no package configuration defined') |
142 | raise ConfigurationError("no package configuration defined; one may be created using 'autobuild edit package'") |
143 |
platform_description = self.package_description.platforms.get(platform_name, None) |
143 |
platform_description = self.package_description.platforms.get(platform_name, None) |
144 |
if platform_description is None: |
144 |
if platform_description is None: |
145 | raise ConfigurationError("no configuration for platform '%s'" % platform_name) |
145 | raise ConfigurationError("no configuration for platform '%s' found; one may be created using 'autobuild edit platform'" % platform_name) |
146 |
else: |
146 |
else: |
147 |
return platform_description |
147 |
return platform_description |
148 |
|
148 |
|
149 |
def get_all_platforms(self): |
149 |
def get_all_platforms(self): |
150 |
try: |
150 |
try: |
151 |
return self.package_description.platforms |
151 |
return self.package_description.platforms |
152 |
except AttributeError: |
152 |
except AttributeError: |
153 |
self.package_description = PackageDescription({}) |
153 |
self.package_description = PackageDescription({}) |
154 |
return self.package_description.platforms |
154 |
return self.package_description.platforms |
155 | 155 | ||
... | 284 lines hidden [Expand] |
Other reviews