diff options
Diffstat (limited to 'lorrycontroller/givemejob.py')
-rw-r--r-- | lorrycontroller/givemejob.py | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/lorrycontroller/givemejob.py b/lorrycontroller/givemejob.py index 85f1818..6736b35 100644 --- a/lorrycontroller/givemejob.py +++ b/lorrycontroller/givemejob.py @@ -36,11 +36,7 @@ class GiveMeJob(lorrycontroller.LorryControllerRoute): now = statedb.get_current_time() for lorry_info in lorry_infos: if self.ready_to_run(lorry_info, now): - if lorry_info['from_host']: - metadata = self.get_repo_metadata(statedb, - lorry_info) - else: - metadata = {} + metadata = self.get_repo_metadata(statedb, lorry_info) downstream_type = lorrycontroller.downstream_types[ self.app_settings['git-server-type']] downstream_type(self.app_settings) \ @@ -72,27 +68,32 @@ class GiveMeJob(lorrycontroller.LorryControllerRoute): def get_repo_metadata(self, statedb, lorry_info): '''Get repository head and description.''' - assert lorry_info['from_host'] - assert lorry_info['from_path'] - - # XXX We don't know whether upstream is Trove + if not lorry_info['from_host']: + return {} - metadata = {} - remote = lorrycontroller.new_gitano_command(statedb, lorry_info['from_host']) + assert lorry_info['from_path'] try: - remote_config = remote.get_gitano_config(lorry_info['from_path']) - metadata['head'] = remote_config['project.head'] + host_info = statedb.get_host_info(lorry_info['from_host']) + except lorrycontroller.HostNotFoundError: + # XXX We don't know whether upstream is Trove. It should be + # possible to set host type for single repositories. + host_info = { + 'host': lorry_info['from_host'], + 'protocol': 'ssh', + 'username': None, + 'password': None, + 'type': 'trove', + 'type_params': {}, + } + + metadata = lorrycontroller.get_upstream_host(host_info) \ + .get_repo_metadata(lorry_info['from_path']) + if 'description' in metadata: + # Prepend Upstream Host name metadata['description'] = '{host}: {desc}'.format( host=lorry_info['from_host'], - desc=remote_config['project.description']) - except lorrycontroller.GitanoCommandFailure as e: - logging.error('ERROR: %s' % str(e)) - # FIXME: We need a good way to report these errors to the - # user. However, we probably don't want to fail the - # request, so that's not the way to do this. Needs - # thinking. - + desc=metadata['description']) return metadata def give_job_to_minion(self, statedb, lorry_info, now): |