summaryrefslogtreecommitdiff
path: root/lorrycontroller/lstroves.py
diff options
context:
space:
mode:
Diffstat (limited to 'lorrycontroller/lstroves.py')
-rw-r--r--lorrycontroller/lstroves.py28
1 files changed, 20 insertions, 8 deletions
diff --git a/lorrycontroller/lstroves.py b/lorrycontroller/lstroves.py
index 72515f5..456359c 100644
--- a/lorrycontroller/lstroves.py
+++ b/lorrycontroller/lstroves.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2014-2015 Codethink Limited
+# Copyright (C) 2014-2016 Codethink Limited
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -23,14 +23,14 @@ import bottle
import lorrycontroller
-class GitanoLsError(Exception):
+class ServerLsError(Exception):
- def __init__(self, trovehost, output):
+ def __init__(self, remote_host, output):
Exception.__init__(
self,
'Failed to get list of git repositories '
- 'on remote host %s:\n%s' % (trovehost, output))
- self.trovehost = trovehost
+ 'on remote host %s:\n%s' % (remote_host, output))
+ self.remote_host = remote_host
class TroveRepositoryLister(object):
@@ -69,7 +69,13 @@ class TroveRepositoryLister(object):
return None
def get_real_ls_output(self, statedb, trove_info):
- gitano = lorrycontroller.new_gitano_command(statedb, trove_info['trovehost'])
+ gitlab_token = trove_info.get('gitlab_token')
+ if gitlab_token:
+ return lorrycontroller.Gitlab(
+ trove_info['trovehost'], gitlab_token).list_projects()
+
+ gitano = lorrycontroller.new_gitano_command(
+ statedb, trove_info['trovehost'])
output = gitano.ls()
return self.parse_ls_output(output)
@@ -149,6 +155,12 @@ class TroveRepositoryLister(object):
}
def construct_lorry_url(self, trove_info, remote_path):
+ gitlab_token = trove_info.get('gitlab_token')
+ if gitlab_token:
+ return lorrycontroller.Gitlab(
+ trove_info['trovehost'], gitlab_token).get_project_url(
+ trove_info['protocol'], remote_path)
+
vars = dict(trove_info)
vars['remote_path'] = remote_path
@@ -177,7 +189,7 @@ class ForceLsTrove(lorrycontroller.LorryControllerRoute):
trove_info = statedb.get_trove_info(trovehost)
try:
updated = lister.list_trove_into_statedb(statedb, trove_info)
- except GitanoLsError as e:
+ except ServerLsError as e:
raise bottle.abort(500, str(e))
return { 'updated-troves': updated }
@@ -199,7 +211,7 @@ class LsTroves(lorrycontroller.LorryControllerRoute):
logging.info('Trove %r is due an ls', trove_info['trovehost'])
try:
lister.list_trove_into_statedb(statedb, trove_info)
- except GitanoLsError as e:
+ except ServerLsError as e:
bottle.abort(500, str(e))
return {