comparison foodtruck/sites.py @ 598:3cec8634209a

admin: Ability to configure SCM stuff per site.
author Ludovic Chabant <ludovic@chabant.com>
date Fri, 22 Jan 2016 11:01:00 -0800
parents e2c91ba44d6c
children effbc78b5528
comparison
equal deleted inserted replaced
597:79a31a3c947b 598:3cec8634209a
1 import os 1 import os
2 import os.path 2 import os.path
3 import copy
3 import shlex 4 import shlex
4 import logging 5 import logging
5 import threading 6 import threading
6 import subprocess 7 import subprocess
7 from piecrust.app import PieCrust 8 from piecrust.app import PieCrust
33 return self._piecrust_app 34 return self._piecrust_app
34 35
35 @property 36 @property
36 def scm(self): 37 def scm(self):
37 if self._scm is None: 38 if self._scm is None:
38 scm_type = self.config.get('scm/type') 39 cfg = None
39 if scm_type == 'hg': 40 scm_cfg = self.config.get('sites/%s/scm' % self.name)
41 global_scm_cfg = self.config.get('scm')
42 if scm_cfg:
43 if global_scm_cfg:
44 cfg = copy.deepcopy(global_scm_cfg)
45 merge_dicts(cfg, scm_cfg)
46 else:
47 cfg = copy.deepcopy(scm_cfg)
48 elif global_scm_cfg:
49 cfg = copy.deepcopy(global_scm_cfg)
50
51 if not cfg or not 'type' in cfg:
52 raise Exception("No SCM available for site: %s" % self.name)
53
54 if cfg['type'] == 'hg':
40 from .scm.mercurial import MercurialSourceControl 55 from .scm.mercurial import MercurialSourceControl
41 self._scm = MercurialSourceControl(self.root_dir) 56 self._scm = MercurialSourceControl(self.root_dir, cfg)
42 else: 57 else:
43 raise NotImplementedError() 58 raise NotImplementedError()
59
44 return self._scm 60 return self._scm
45 61
46 @property 62 @property
47 def is_bake_running(self): 63 def is_bake_running(self):
48 return self._bake_thread is not None and self._bake_thread.is_alive() 64 return self._bake_thread is not None and self._bake_thread.is_alive()