예제 #1
0
파일: ux.py 프로젝트: frmdstryr/hendrix
def djangoVsWsgi(options):
    # settings logic
    if not options['wsgi']:
        settings_mod = findSettingsModule()
        user_settings = options['settings']
        if not settings_mod and not user_settings:
            msg = (
                '\nEither specify:\n--settings mysettings.dot.path\nOR\n'
                'export DJANGO_SETTINGS_MODULE="mysettings.dot.path"\nOR\n'
                'in your manage.py file specify '
                'os.environ.setdefault("DJANGO_SETTINGS_MODULE", '
                '"mysettings.dot.path")'
            )
            raise SettingsError(chalk.format_red(msg), None, sys.exc_info()[2])
        elif user_settings:
            # if the user specified the settings to use then these take
            # precedence
            options['settings'] = user_settings
        elif settings_mod:
            options['settings'] = settings_mod
    else:
        try:
            base.HendrixDeploy.importWSGI(options['wsgi'])
        except ImportError:
            raise ImportError("The path '%s' does not exist" % options['wsgi'])

    return options
예제 #2
0
파일: ux.py 프로젝트: andybak/hendrix
def findSettingsModule():
    "Find the settings module dot path within django's mnanage.py file"
    try:
        with open('manage.py', 'r') as manage:
            manage_contents = manage.read()

            search = re.search(r"([\"\'](?P<module>[a-z\.]+)[\"\'])",
                               manage_contents)
            if search:  # django version < 1.7
                settings_mod = search.group("module")

            else:
                # in 1.7, manage.py settings declaration looks like:
                # os.environ.setdefault(
                #     "DJANGO_SETTINGS_MODULE", "example_app.settings"
                # )
                search = re.search("\".*?\"(,\\s)??\"(?P<module>.*?)\"\\)$",
                                   manage_contents, re.I | re.S | re.M)
                settings_mod = search.group("module")

        os.environ.setdefault('DJANGO_SETTINGS_MODULE', settings_mod)
    except IOError, e:
        msg = (str(e) + '\nPlease ensure that you are in the same directory '
               'as django\'s "manage.py" file.')
        raise IOError(chalk.format_red(msg)), None, sys.exc_info()[2]
예제 #3
0
파일: ux.py 프로젝트: frmdstryr/hendrix
def findSettingsModule():
    "Find the settings module dot path within django's manage.py file"
    try:
        with open('manage.py', 'r') as manage:
            manage_contents = manage.read()

            search = re.search(
                r"([\"\'](?P<module>[a-z\.]+)[\"\'])", manage_contents
            )
            if search:  # django version < 1.7
                settings_mod = search.group("module")

            else:
                # in 1.7, manage.py settings declaration looks like:
                # os.environ.setdefault(
                #     "DJANGO_SETTINGS_MODULE", "example_app.settings"
                # )
                search = re.search(
                    "\".*?\"(,\\s)??\"(?P<module>.*?)\"\\)$",
                    manage_contents, re.I | re.S | re.M
                )
                settings_mod = search.group("module")

        os.environ.setdefault('DJANGO_SETTINGS_MODULE', settings_mod)
    except IOError as e:
        msg = (
            str(e) + '\nPlease ensure that you are in the same directory '
            'as django\'s "manage.py" file.'
        )
        raise IOError(chalk.format_red(msg), None, sys.exc_info()[2])
    except AttributeError:
        settings_mod = ''
    return settings_mod
예제 #4
0
파일: ux.py 프로젝트: andybak/hendrix
def djangoVsWsgi(options):
    # settings logic
    if not options['wsgi']:
        settings_mod = findSettingsModule()
        user_settings = options['settings']
        if not settings_mod and not user_settings:
            msg = ('\nEither specify:\n--settings mysettings.dot.path\nOR\n'
                   'export DJANGO_SETTINGS_MODULE="mysettings.dot.path"\nOR\n'
                   'in your manage.py file specify '
                   'os.environ.setdefault("DJANGO_SETTINGS_MODULE", '
                   '"mysettings.dot.path")')
            raise SettingsError(chalk.format_red(msg)), None, sys.exc_info()[2]
        elif user_settings:
            # if the user specified the settings to use then these take
            # precedence
            options['settings'] = user_settings
        elif settings_mod:
            options['settings'] = settings_mod
    else:
        try:
            base.HendrixDeploy.importWSGI(options['wsgi'])
        except ImportError:
            raise ImportError("The path '%s' does not exist" % options['wsgi'])

    return options
예제 #5
0
파일: ux.py 프로젝트: dmpayton/hendrix
def findSettingsModule():
    "Find the settings module dot path within django's mnanage.py file"
    try:
        with open("manage.py", "r") as manage:
            manage_contents = manage.read()

            search = re.search(r"([\"\'](?P<module>[a-z\.]+)[\"\'])", manage_contents)
            if search:  # django version < 1.7
                settings_mod = search.group("module")

            else:
                # in 1.7, manage.py settings declaration looks like:
                # os.environ.setdefault("DJANGO_SETTINGS_MODULE", "example_app.settings")
                search = re.search('".*?"(,\\s)??"(?P<module>.*?)"\\)$', manage_contents, re.I | re.S | re.M)
                settings_mod = search.group("module")

        os.environ.setdefault("DJANGO_SETTINGS_MODULE", settings_mod)
    except IOError, e:
        msg = str(e) + "\nPlease ensure that you are in the same directory " 'as django\'s "manage.py" file.'
        raise IOError(chalk.format_red(msg)), None, sys.exc_info()[2]
예제 #6
0
파일: ux.py 프로젝트: pombredanne/hendrix
def djangoVsWsgi(options):
    # settings logic
    if not options["wsgi"]:
        settings_mod = findSettingsModule()
        user_settings = options["settings"]
        if not settings_mod and not user_settings:
            msg = (
                "\nEither specify:\n--settings mysettings.dot.path\nOR\n"
                'export DJANGO_SETTINGS_MODULE="mysettings.dot.path"\nOR\n'
                "in your manage.py file specify "
                'os.environ.setdefault("DJANGO_SETTINGS_MODULE", '
                '"mysettings.dot.path")'
            )
            raise SettingsError(chalk.format_red(msg)), None, sys.exc_info()[2]
        elif user_settings:
            # if the user specified the settings to use then these take
            # precedence
            options["settings"] = user_settings
        elif settings_mod:
            options["settings"] = settings_mod

    return options
예제 #7
0
파일: ux.py 프로젝트: damonworx/hendrix
def djangoVsWsgi(options):
    # settings logic
    if not options['wsgi']:
        user_settings = options['settings']
        settings_module = os.environ.get('DJANGO_SETTINGS_MODULE')
        if not settings_module and not user_settings:
            msg = (
                '\nEither specify:\n--settings mysettings.dot.path\nOR\n'
                'export DJANGO_SETTINGS_MODULE="mysettings.dot.path"'
            )
            raise SettingsError(chalk.format_red(msg)), None, sys.exc_info()[2]
        elif user_settings:
            options['settings'] = user_settings
        elif settings_module:
            options['settings'] = settings_module
    else:
        try:
            HendrixDeploy.importWSGI(options['wsgi'])
        except ImportError:
            raise ImportError("The path '%s' does not exist" % options['wsgi'])

    return options
예제 #8
0
 def formatException(self, ei):
     exception = super(ChalkFormatter, self).formatException(ei)
     return chalk.format_red(exception)
예제 #9
0
파일: logger.py 프로젝트: ipaste/derrick
 def formatException(self, ei):
     exception = super(ChalkFormatter, self).formatException(ei)
     return chalk.format_red(exception)