예제 #1
0
파일: bootstrap.py 프로젝트: oriel-hub/api
def main(argv):
    # check python version is high enough
    ve_mgr.check_python_version(2, 6, __file__)

    force_update = False
    full_rebuild = False
    fake_update = False
    clean_ve = False
    devel = False

    if argv:
        try:
            opts, args = getopt.getopt(
                argv[1:], 'hfqr',
                ['help', 'force', 'quiet', 'full-rebuild', 'dev'])
        except getopt.error as msg:
            return print_error_msg('Bad options: %s' % msg)
        # process options
        for o, a in opts:
            if o in ("-h", "--help"):
                print_help_text()
                return 0
            if o in ("-f", "--force"):
                force_update = True
            if o in ("-r", "--full-rebuild"):
                full_rebuild = True
            if o in ("-d", "--dev"):
                devel = True
        if len(args) > 1:
            return print_error_msg("Can only have one argument - you had %s" %
                                   (' '.join(args)))
        if len(args) == 1:
            if args[0] == 'fake':
                fake_update = True
            elif args[0] == 'clean':
                clean_ve = True

        # check for incompatible flags
        if force_update and fake_update:
            return print_error_msg("Cannot use --force with fake")
        if full_rebuild and fake_update:
            return print_error_msg("Cannot use --full-rebuild with fake")
        if full_rebuild and clean_ve:
            return print_error_msg("Cannot use --full-rebuild with clean")

    environment = 'dev' if devel is True else None
    updater = ve_mgr.UpdateVE(environment=environment)

    if fake_update:
        return updater.update_ve_timestamp()
    elif clean_ve:
        return updater.delete_virtualenv()
    else:
        updater.update_git_submodule()
        return updater.update_ve(full_rebuild, force_update)
예제 #2
0
# check python version is high enough
ve_mgr.check_python_version(2, 6, __file__)

# ignore the usual virtualenv
# note that for runserver Django will start a child process, so that it
# can kill and restart the child process. So we use the environment to pass
# the argument along.
if '--ignore-ve' in sys.argv:
    sys.argv.remove('--ignore-ve')
    os.environ['IGNORE_DOTVE'] = 'true'

# VIRTUAL_ENV will be set if we are already inside a virtualenv (either because
# of standard virtualenv activate, or because go_to_ve() set it).
if 'IGNORE_DOTVE' not in os.environ and 'VIRTUAL_ENV' not in os.environ:
    # if it appears that the virtualenv is out of date then stop here
    updater = ve_mgr.UpdateVE()
    if updater.virtualenv_needs_update():
        print "VirtualEnv needs to be updated"
        print 'Run "deploy/bootstrap.py'
        sys.exit(1)

    # now we should enter the virtualenv. We will only get
    # this far if the virtualenv is up to date.
    updater.go_to_ve(__file__, sys.argv[1:])

# run django - the usual manage.py stuff
if __name__ == "__main__":
    sys.path.append(DEPLOY_DIR)
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")

    try: