Пример #1
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import re
import sys
import os

from celery.__main__ import main

# prepare environment variables
from ccg_django_utils.conf import setup_prod_env
setup_prod_env("yabi")
os.environ["YABI_CELERY_WORKER"] = "1"

if __name__ == '__main__':
    sys.argv[0] = sys.argv[0].replace("yabicelery", "celery")
    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
    sys.exit(main())
Пример #2
0
"""
import os
import os.path
from sys import path

# snippet to enable the virtualenv if installed as rpm
activate_this=os.path.join(os.path.dirname(os.path.abspath(__file__)), 'bin', 'activate_this.py')
if os.path.exists(activate_this):
    exec(compile(open(activate_this).read(), activate_this, 'exec'), dict(__file__=activate_this))
del activate_this

SITE_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
path.append(SITE_ROOT)

from ccg_django_utils.conf import setup_prod_env
setup_prod_env(os.path.basename(os.path.dirname(__file__)))

# This application object is used by any WSGI server configured to use this
# file. This includes Django's development server, if the WSGI_APPLICATION
# setting points here.
from django.core.wsgi import get_wsgi_application
_application = get_wsgi_application()

def application(wenv, start_response):
    # Before entering the django app, transfer the SCRIPT_NAME http
    # header into an environment variable so settings can pick it up.
    mount_point = wenv.get("HTTP_SCRIPT_NAME", wenv.get("SCRIPT_NAME", None))
    if mount_point:
        os.environ["SCRIPT_NAME"] = mount_point
        wenv["HTTP_SCRIPT_NAME"] = wenv["SCRIPT_NAME"] = mount_point
    return _application(wenv, start_response)
Пример #3
0
import os.path
from sys import path

# snippet to enable the virtualenv if installed as rpm
activate_this = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'bin',
                             'activate_this.py')
if os.path.exists(activate_this):
    exec(compile(open(activate_this).read(), activate_this, 'exec'),
         dict(__file__=activate_this))
del activate_this

SITE_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
path.append(SITE_ROOT)

from ccg_django_utils.conf import setup_prod_env
setup_prod_env(os.path.basename(os.path.dirname(__file__)))

# This application object is used by any WSGI server configured to use this
# file. This includes Django's development server, if the WSGI_APPLICATION
# setting points here.
from django.core.wsgi import get_wsgi_application
_application = get_wsgi_application()


def application(wenv, start_response):
    # Before entering the django app, transfer the SCRIPT_NAME http
    # header into an environment variable so settings can pick it up.
    mount_point = wenv.get("HTTP_SCRIPT_NAME", wenv.get("SCRIPT_NAME", None))
    if mount_point:
        os.environ["SCRIPT_NAME"] = mount_point
        wenv["HTTP_SCRIPT_NAME"] = wenv["SCRIPT_NAME"] = mount_point
Пример #4
0
# snippet to enable the virtualenv
activate_this = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'bin',
                             'activate_this.py')
if os.path.exists(activate_this):
    exec(compile(open(activate_this).read(), activate_this, 'exec'),
         dict(__file__=activate_this))
del activate_this

webapp_root = os.path.dirname(os.path.abspath(__file__))

# determine app instance (kindred or turtle) based on path to webapp
app_instance = os.path.basename(webapp_root)

# prepare the settings module for the WSGI app
from ccg_django_utils.conf import setup_prod_env  # noqa
setup_prod_env(app_instance, package_name="kindred")

from django.core.wsgi import get_wsgi_application  # noqa
_application = get_wsgi_application()


# This is the WSGI application booter
def application(environ, start):
    if "HTTP_SCRIPT_NAME" in environ:
        environ['SCRIPT_NAME'] = environ['HTTP_SCRIPT_NAME']
        os.environ['SCRIPT_NAME'] = environ['HTTP_SCRIPT_NAME']
    else:
        os.environ['SCRIPT_NAME'] = environ['SCRIPT_NAME']
    if 'DJANGODEV' in environ:
        os.environ['DJANGODEV'] = environ['DJANGODEV']
    return _application(environ, start)
Пример #5
0
#!/usr/bin/env python
import os
import sys
import pwd

production_user = "******"

if production_user:
    (uid, gid, gecos, homedir) = pwd.getpwnam(production_user)[2:6]
    try:
        os.setgid(gid)
        os.setuid(uid)
    except OSError as e:
        sys.stderr.write("%s\nThis program needs to be run as the " % e)
        sys.stderr.write("%s user, or root.\n" % production_user)
        sys.exit(1)
    else:
        os.environ["HOME"] = homedir

if __name__ == "__main__":
    if production_user:
        # setup the settings module for the django app
        from ccg_django_utils.conf import setup_prod_env
        setup_prod_env("mastrms")
    else:
        os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mastrms.settings")

    from django.core.management import execute_from_command_line

    execute_from_command_line(sys.argv)
Пример #6
0
production_user = "******"
in_production = os.path.basename(sys.argv[0]) == PROG

if in_production:
    (uid, gid, gecos, homedir) = pwd.getpwnam(production_user)[2:6]
    try:
        os.setgid(gid)
        os.setuid(uid)
    except OSError as e:
        sys.stderr.write("%s\nThis program needs to be run as the " % e)
        sys.stderr.write("%s user, or root.\n" % production_user)
        sys.exit(1)
    else:
        os.environ["HOME"] = homedir

if __name__ == "__main__":
    if in_production:
        print("{0} Django manage in production".format(PROG))
        # setup the settings module for the django app
        from ccg_django_utils.conf import setup_prod_env

        setup_prod_env(PROG)
    else:
        print("{0} Django manage develop".format(PROG))
        os.environ.setdefault("DJANGO_SETTINGS_MODULE", "%s.settings" % PROG)

    from django.core.management import execute_from_command_line

    execute_from_command_line(sys.argv)