From a928b0b9323b88bcecef66d42d3c40f9f0d40fc8 Mon Sep 17 00:00:00 2001 From: Nicolas Wavrant <nicolas.wavrant@tiolive.com> Date: Fri, 13 Sep 2013 15:49:59 +0200 Subject: [PATCH] new function in utils.py: clone the git repo of slapos by default (if it is not present), when the runner is launched --- slapos/runner/__init__.py | 3 +++ slapos/runner/utils.py | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/slapos/runner/__init__.py b/slapos/runner/__init__.py index b509772..8408e97 100755 --- a/slapos/runner/__init__.py +++ b/slapos/runner/__init__.py @@ -11,6 +11,7 @@ import os import slapos.runner.process import sys from slapos.runner.utils import runInstanceWithLock +from utils import cloneDefaultgit class Parser(OptionParser): @@ -120,6 +121,8 @@ def run(): # avoid mistakes (mainly in development mode) raise Exception('Do not run SlapRunner as root.') + cloneDefaultgit() + serve(config) return_code = 0 except SystemExit as err: diff --git a/slapos/runner/utils.py b/slapos/runner/utils.py index ff58f3e..47cf7d9 100755 --- a/slapos/runner/utils.py +++ b/slapos/runner/utils.py @@ -803,3 +803,19 @@ def readParameters(path): return str(e) else: return "No such file or directory: %s" % path + + +def cloneDefaultGit(): + """Test if the slapos git has been downloaded yet + If not, download it in read-only mode""" + slap = os.path.join(config.runner_workdir, 'project', 'slapos') + slap_ro = os.path.join(config.runner_workdir, 'project', 'slapos-readonly') + if not os.path.exists(slap_ro) or not os.path.exists(slap_ro): + from gittools import cloneRepo + user = open(os.path.join(config.etc_dir, '.users')).read().split(';') + data = {'path': slap_ro, + 'repo': 'http://git.erp5.org/repos/slapos.git', + 'email': user[2], + 'user': user[3], + } + cloneRepo(data) -- 2.30.9