diff options
author | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2014-03-31 14:23:58 +0000 |
---|---|---|
committer | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2014-03-31 14:23:58 +0000 |
commit | db036f586f9dcfd2a8fb3dd31b1d2df641332430 (patch) | |
tree | a26d360941028977b3a75e7dc83a647115f7b9ac | |
parent | 4e61f9cab2b7a5cbacbc7169027753e01cfc3a54 (diff) | |
download | lorry-controller-db036f586f9dcfd2a8fb3dd31b1d2df641332430.tar.gz |
Move local repo creation to GitanoCommand
-rw-r--r-- | lorrycontroller/gitano.py | 6 | ||||
-rw-r--r-- | lorrycontroller/givemejob.py | 12 |
2 files changed, 13 insertions, 5 deletions
diff --git a/lorrycontroller/gitano.py b/lorrycontroller/gitano.py index d2cfdb3..f2f33b0 100644 --- a/lorrycontroller/gitano.py +++ b/lorrycontroller/gitano.py @@ -33,6 +33,12 @@ class GitanoCommand(object): def __init__(self, trovehost): self.trovehost = trovehost + def create(self, repo_path): + exit, stdout, stderr = cliapp.runcmd_unchecked( + ['ssh', 'git@%s' % self.trovehost, 'create', repo_path]) + if exit: + raise GitanoCommandFailure(self.trovehost, 'create %s' % repo_path) + def get_gitano_config_for_repo(self, repo_path): exit, stdout, stderr = cliapp.runcmd_unchecked( ['ssh', 'git@%s' % self.trovehost, diff --git a/lorrycontroller/givemejob.py b/lorrycontroller/givemejob.py index a60da88..f620734 100644 --- a/lorrycontroller/givemejob.py +++ b/lorrycontroller/givemejob.py @@ -71,12 +71,14 @@ class GiveMeJob(lorrycontroller.LorryControllerRoute): # Create repository on local Trove. If it fails, assume # it failed because the repository already existed, and # ignore the failure (but log message). - exit, stdout, stderr = cliapp.runcmd_unchecked( - ['ssh', 'git@localhost', 'create', lorry_info['path']]) - if exit: + + local = lorrycontroller.GitanoCommand('localhost') + try: + local.create(lorry_info['path']) + except lorrycontroller.GitanoCommandFailure as e: logging.debug( - 'Ignoring error creating %s on local Trove:\n%s\n%s', - lorry_info['path'], stdout, stderr) + 'Ignoring error creating %s on local Trove: %s', + lorry_info['path'], e) else: logging.info('Created %s on local repo', lorry_info['path']) |