diff options
Diffstat (limited to 'lorrycontroller/givemejob.py')
-rw-r--r-- | lorrycontroller/givemejob.py | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/lorrycontroller/givemejob.py b/lorrycontroller/givemejob.py index 8f4a2a8..721b55e 100644 --- a/lorrycontroller/givemejob.py +++ b/lorrycontroller/givemejob.py @@ -65,12 +65,9 @@ class GiveMeJob(lorrycontroller.LorryControllerRoute): due = lorry_info['last_run'] + lorry_info['interval'] return (lorry_info['running_job'] is None and due <= now) - def get_repo_metadata(self, statedb, lorry_info): - '''Get repository head and description.''' - - if not lorry_info['from_host']: - return {} - + @staticmethod + def get_upstream_host_repo_metadata(lorry_info): + assert lorry_info['from_host'] assert lorry_info['from_path'] try: @@ -79,14 +76,25 @@ class GiveMeJob(lorrycontroller.LorryControllerRoute): # XXX Shouldn't happen, but currently the database schema # does not prevent it return {} - - metadata = lorrycontroller.get_upstream_host(host_info) \ + else: + return lorrycontroller.get_upstream_host(host_info) \ .get_repo_metadata(lorry_info['from_path']) - if 'description' in metadata: + + def get_repo_metadata(self, statedb, lorry_info): + '''Get repository head and description.''' + + host_name = lorry_info['from_host'] + if host_name: + metadata = self.get_upstream_host_repo_metadata(lorry_info) + else: + metadata = {} + + if host_name and 'description' in metadata: # Prepend Upstream Host name metadata['description'] = '{host}: {desc}'.format( - host=lorry_info['from_host'], + host=host_name, desc=metadata['description']) + return metadata def give_job_to_minion(self, statedb, lorry_info, now): |