Revision b216cb77

b/conf/ci/manage.py
1
#!/usr/bin/env python2.6
2
# -*- coding: utf-8 -*-
3
from os import path
4
import shutil, sys, virtualenv, subprocess
5

  
6
PROJECT_ROOT = path.abspath(path.dirname(__file__))
7
REQUIREMENTS = path.join(PROJECT_ROOT, 'requirements.pip')
8

  
9
VE_ROOT = path.join(PROJECT_ROOT, '.ve')
10
VE_TIMESTAMP = path.join(VE_ROOT, 'timestamp')
11

  
12
envtime = path.exists(VE_ROOT) and path.getmtime(VE_ROOT) or 0
13
envreqs = path.exists(VE_TIMESTAMP) and path.getmtime(VE_TIMESTAMP) or 0
14
envspec = path.getmtime(REQUIREMENTS)
15

  
16
def go_to_ve():
17
    # going into ve
18
    if not sys.prefix == VE_ROOT:
19
        if sys.platform == 'win32':
20
            python = path.join(VE_ROOT, 'Scripts', 'python.exe')
21
        else:
22
            python = path.join(VE_ROOT, 'bin', 'python')
23
            
24
        retcode = subprocess.call([python, __file__] + sys.argv[1:])
25
        sys.exit(retcode)
26

  
27
update_ve = 'update_ve' in sys.argv
28
if update_ve or envtime < envspec or envreqs < envspec:
29
    if update_ve:
30
        # install ve
31
        if envtime < envspec:
32
            if path.exists(VE_ROOT):
33
                shutil.rmtree(VE_ROOT)
34
            virtualenv.logger = virtualenv.Logger(consumers=[])
35
            virtualenv.create_environment(VE_ROOT, site_packages=True)
36

  
37
        go_to_ve()    
38

  
39
        # check requirements
40
        if update_ve or envreqs < envspec:
41
            import pip
42
            pip.main(initial_args=['install', '-r', REQUIREMENTS])
43
            file(VE_TIMESTAMP, 'w').close()
44
        sys.exit(0)
45
    else:
46
        print "VirtualEnv need to be updated"
47
        print "Run ./manage.py update_ve"
48
        sys.exit(1)
49

  
50
go_to_ve()
51

  
52
# run django
53
from django.core.management import execute_manager
54
try:
55
    import settings # Assumed to be in the same directory.
56
except ImportError:
57
    import sys
58
    sys.stderr.write("Error: Can't find the file 'settings.py' in the directory")
59
    sys.exit(1)
60

  
61
if __name__ == "__main__":
62
    execute_manager(settings)
b/conf/ci/pip-1.2.conf
3 3
pyzmq==2.0.10.1
4 4
pycurl==7.19.0
5 5
python-dateutil==1.4.1
6
django-hudson
7
MySQL-python==1.2.3
8
psycopg2==2.4
6 9

  
b/conf/ci/settings.py.mysql
111 111
    'django.contrib.sites',
112 112
    'django.contrib.messages',
113 113
    'django.contrib.admin',
114
    'django_hudson',
114 115
    # 'django.contrib.admindocs',
115 116
    'synnefo.auth',
116 117
    'synnefo.api',
b/conf/ci/settings.py.postgres
108 108
    'django.contrib.sites',
109 109
    'django.contrib.messages',
110 110
    'django.contrib.admin',
111
    'django_hudson',
111 112
    # 'django.contrib.admindocs',
112 113
    'synnefo.auth',
113 114
    'synnefo.api',
b/conf/ci/settings.py.sqlite
105 105
    'django.contrib.sites',
106 106
    'django.contrib.messages',
107 107
    'django.contrib.admin',
108
    'django_hudson',
108 109
    # 'django.contrib.admindocs',
109 110
    'synnefo.auth',
110 111
    'synnefo.api',

Also available in: Unified diff