Commit 188e1d3d53735f2038b4c7019c489e111c286d75
1 parent
4b2544b2
Exists in
master
and in
39 other branches
Fabric is now configurable.
Showing
2 changed files
with
18 additions
and
20 deletions
Show diff stats
.gitignore
fabfile.py
... | ... | @@ -3,17 +3,15 @@ |
3 | 3 | import os |
4 | 4 | |
5 | 5 | from fabric import colors |
6 | +from fabric.utils import error | |
6 | 7 | from fabric.decorators import task |
7 | 8 | from fabric.api import env, run, sudo, local |
8 | 9 | from fabric.contrib.files import exists |
9 | 10 | from fabric.context_managers import prefix, cd, settings, shell_env |
10 | 11 | |
11 | 12 | |
12 | -### Start of config | |
13 | - | |
14 | 13 | APP_USER = APP_NAME = VENV_NAME = 'colab' |
15 | -REPO_URL = 'To be defined' | |
16 | - | |
14 | +REPO_URL = 'git@github.com:colab-community/colab.git' | |
17 | 15 | |
18 | 16 | environments = { |
19 | 17 | 'dev': { |
... | ... | @@ -23,23 +21,9 @@ environments = { |
23 | 21 | 'is_vagrant': True, |
24 | 22 | 'superuser': 'vagrant', |
25 | 23 | }, |
26 | - 'qa': { | |
27 | - 'hosts': [], | |
28 | - 'port': 22, | |
29 | - 'is_vagrant': False, | |
30 | - 'superuser': 'root', | |
31 | - }, | |
32 | - 'prod': { | |
33 | - 'hosts': [], | |
34 | - 'port': 22, | |
35 | - 'is_vagrant': False, | |
36 | - 'superuser': 'root', | |
37 | - }, | |
38 | 24 | } |
39 | 25 | DEFAULT_ENVIRONMENT = 'dev' |
40 | 26 | |
41 | -### End of config | |
42 | - | |
43 | 27 | env.user = APP_USER |
44 | 28 | env.use_shell = False |
45 | 29 | |
... | ... | @@ -52,11 +36,24 @@ SETTINGS_PATH = os.path.join(MANAGE_PATH, APP_NAME) |
52 | 36 | |
53 | 37 | |
54 | 38 | @task |
55 | -def environment(name): | |
39 | +def environment(name=DEFAULT_ENVIRONMENT): | |
56 | 40 | """Set the environment where the tasks will be executed""" |
41 | + global REPO_URL | |
42 | + | |
43 | + try: | |
44 | + import project_cfg | |
45 | + except ImportError: | |
46 | + pass | |
47 | + else: | |
48 | + REPO_URL = project_cfg.repository_url | |
49 | + environments.update(project_cfg.environments) | |
50 | + | |
51 | + if name not in environments: | |
52 | + error(colors.red('Environment `{}` does not exist.'.format(name))) | |
53 | + | |
57 | 54 | env.update(environments[name]) |
58 | 55 | env.environment = name |
59 | -environment(DEFAULT_ENVIRONMENT) | |
56 | +environment() | |
60 | 57 | |
61 | 58 | |
62 | 59 | def aptget_install(pkg): | ... | ... |