Commit ec81c0c6 authored by Nicolas Delaby's avatar Nicolas Delaby

Bug fix

Avoid concatenation of None and string vlaues if profile_path is defined later in vcs_repository_list.
parent 1f3745c7
...@@ -109,7 +109,7 @@ def run(config): ...@@ -109,7 +109,7 @@ def run(config):
custom_profile_path = os.path.join(config['working_directory'], 'software.cfg') custom_profile_path = os.path.join(config['working_directory'], 'software.cfg')
config['custom_profile_path'] = custom_profile_path config['custom_profile_path'] = custom_profile_path
vcs_repository_list = config['vcs_repository_list'] vcs_repository_list = config['vcs_repository_list']
profile_content = None profile_content = ''
assert len(vcs_repository_list), "we must have at least one repository" assert len(vcs_repository_list), "we must have at least one repository"
try: try:
# BBB: Accept global profile_path, which is the same as setting it for the # BBB: Accept global profile_path, which is the same as setting it for the
...@@ -119,6 +119,7 @@ def run(config): ...@@ -119,6 +119,7 @@ def run(config):
pass pass
else: else:
vcs_repository_list[0][PROFILE_PATH_KEY] = profile_path vcs_repository_list[0][PROFILE_PATH_KEY] = profile_path
profile_path_count = 0
for vcs_repository in vcs_repository_list: for vcs_repository in vcs_repository_list:
url = vcs_repository['url'] url = vcs_repository['url']
buildout_section_id = vcs_repository.get('buildout_section_id', None) buildout_section_id = vcs_repository.get('buildout_section_id', None)
...@@ -132,7 +133,8 @@ def run(config): ...@@ -132,7 +133,8 @@ def run(config):
except KeyError: except KeyError:
pass pass
else: else:
if profile_content is not None: profile_path_count += 1
if profile_path_count > 1:
raise ValueError(PROFILE_PATH_KEY + ' defined more than once') raise ValueError(PROFILE_PATH_KEY + ' defined more than once')
profile_content = """ profile_content = """
[buildout] [buildout]
...@@ -148,7 +150,7 @@ branch = %(branch)s ...@@ -148,7 +150,7 @@ branch = %(branch)s
'repository_path' : repository_path, 'repository_path' : repository_path,
'branch' : vcs_repository.get('branch','master')} 'branch' : vcs_repository.get('branch','master')}
if profile_content is None: if not profile_path_count:
raise ValueError(PROFILE_PATH_KEY + ' not defined') raise ValueError(PROFILE_PATH_KEY + ' not defined')
custom_profile = open(custom_profile_path, 'w') custom_profile = open(custom_profile_path, 'w')
custom_profile.write(profile_content) custom_profile.write(profile_content)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment