当前位置: 首页>>代码示例>>Python>>正文


Python color.color_style方法代码示例

本文整理汇总了Python中django.core.management.color.color_style方法的典型用法代码示例。如果您正苦于以下问题:Python color.color_style方法的具体用法?Python color.color_style怎么用?Python color.color_style使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django.core.management.color的用法示例。


在下文中一共展示了color.color_style方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_empty_source_table

# 需要导入模块: from django.core.management import color [as 别名]
# 或者: from django.core.management.color import color_style [as 别名]
def create_empty_source_table(self, clazz, source_table_name, source_db_connection, extra_fields={}):
        project = Project(key='sutter_county', id=0)
        db_entity = DbEntity(key=Keys.DB_ABSTRACT_BASE_AGRICULTURE_FEATURE, feature_class_configuration=dict(
            abstract_class=full_module_path(clazz)
        ))
        SourceClass = FeatureClassCreator(project, db_entity, no_ensure=True).dynamic_model_class(base_only=True, schema='public', table=source_table_name)
        # class SourceClass(clazz):
        #     class Meta(clazz.Meta):
        #         db_table = source_table_name
        create_tables_for_dynamic_classes(SourceClass)
        for field in SourceClass._meta.fields[1:]:
            setattr(field, 'null', True)

        drop_table = "DROP TABLE IF EXISTS {final_table} CASCADE;".format(final_table=source_table_name)

        sql, refs = source_db_connection.creation.sql_create_model(SourceClass, color_style())
        add_geometry_fields = '''
            ALTER TABLE {final_table} ADD COLUMN geography_id VARCHAR;
            ALTER TABLE {final_table} ADD COLUMN wkb_geometry GEOMETRY;'''.format(final_table=source_table_name)

        sql = drop_table + sql[0] + add_geometry_fields
        for dbfield, fieldtype in extra_fields.items():
            sql += 'ALTER TABLE {final_table} ADD COLUMN {field} {type}'.format(
                final_table=source_table_name, field=dbfield, type=fieldtype)
        source_db_connection.cursor().execute(sql) 
开发者ID:CalthorpeAnalytics,项目名称:urbanfootprint,代码行数:27,代码来源:load_ag_scenario_table.py

示例2: livereload_request

# 需要导入模块: from django.core.management import color [as 别名]
# 或者: from django.core.management.color import color_style [as 别名]
def livereload_request(self, **options):
        """
        Performs the LiveReload request.
        """
        style = color_style()
        verbosity = int(options['verbosity'])
        host = '%s:%d' % (
            options['livereload_host'],
            options['livereload_port'],
        )
        try:
            urlopen('http://%s/forcereload' % host)
            self.message('LiveReload request emitted.\n',
                         verbosity, style.HTTP_INFO)
        except IOError:
            pass 
开发者ID:tjwalch,项目名称:django-livereload-server,代码行数:18,代码来源:runserver.py

示例3: populate_exam_run_fk

# 需要导入模块: from django.core.management import color [as 别名]
# 或者: from django.core.management.color import color_style [as 别名]
def populate_exam_run_fk(apps, schema_editor):
    ProctoredExamGrade = apps.get_model('grades', 'ProctoredExamGrade')
    ExamAuthorization = apps.get_model('exams', 'ExamAuthorization')
    style = color_style()
    fake_exam_grades = []

    exam_grades = ProctoredExamGrade.objects.filter(exam_run__isnull=True)
    for exam_grade in exam_grades.iterator():
        try:
            exam_grade.exam_run = ExamAuthorization.objects.get(
                id=exam_grade.client_authorization_id
            ).exam_run
            exam_grade.save()
        except ValueError:
            fake_exam_grades.append(exam_grade)
            continue

    for fake_exam_grade in fake_exam_grades:
        sys.stdout.write(
            style.ERROR(
                '\nInvalid client_authorization_id {0} for ProctoredExamGrade {1}'.format(
                    fake_exam_grade.client_authorization_id, fake_exam_grade.id
                )
            )
        ) 
开发者ID:mitodl,项目名称:micromasters,代码行数:27,代码来源:0008_populate_exam_run_for_exam_grades.py

示例4: main_help_text

# 需要导入模块: from django.core.management import color [as 别名]
# 或者: from django.core.management.color import color_style [as 别名]
def main_help_text(self, commands_only=False):
        """
        Returns the script's main help text, as a string.
        """
        if commands_only:
            usage = sorted(get_commands().keys())
        else:
            usage = [
                "",
                "Type '%s help <subcommand>' for help on a specific subcommand." % self.prog_name,
                "",
                "Available subcommands:",
            ]
            commands_dict = collections.defaultdict(lambda: [])
            for name, app in six.iteritems(get_commands()):
                if app == 'django.core':
                    app = 'django'
                else:
                    app = app.rpartition('.')[-1]
                commands_dict[app].append(name)
            style = color_style()
            for app in sorted(commands_dict.keys()):
                usage.append("")
                usage.append(style.NOTICE("[%s]" % app))
                for name in sorted(commands_dict[app]):
                    usage.append("    %s" % name)
            # Output an extra note if settings are not properly configured
            if self.settings_exception is not None:
                usage.append(style.NOTICE(
                    "Note that only Django core commands are listed "
                    "as settings are not properly configured (error: %s)."
                    % self.settings_exception))

        return '\n'.join(usage) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:36,代码来源:__init__.py

示例5: __init__

# 需要导入模块: from django.core.management import color [as 别名]
# 或者: from django.core.management.color import color_style [as 别名]
def __init__(self, stdout=None, stderr=None, no_color=False):
        self.stdout = OutputWrapper(stdout or sys.stdout)
        self.stderr = OutputWrapper(stderr or sys.stderr)
        if no_color:
            self.style = no_style()
        else:
            self.style = color_style()
            self.stderr.style_func = self.style.ERROR

        # `requires_model_validation` is deprecated in favor of
        # `requires_system_checks`. If both options are present, an error is
        # raised. Otherwise the present option is used. If none of them is
        # defined, the default value (True) is used.
        has_old_option = hasattr(self, 'requires_model_validation')
        has_new_option = hasattr(self, 'requires_system_checks')

        if has_old_option:
            warnings.warn(
                '"requires_model_validation" is deprecated '
                'in favor of "requires_system_checks".',
                RemovedInDjango19Warning)
        if has_old_option and has_new_option:
            raise ImproperlyConfigured(
                'Command %s defines both "requires_model_validation" '
                'and "requires_system_checks", which is illegal. Use only '
                '"requires_system_checks".' % self.__class__.__name__)

        self.requires_system_checks = (
            self.requires_system_checks if has_new_option else
            self.requires_model_validation if has_old_option else
            True) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:33,代码来源:base.py

示例6: __init__

# 需要导入模块: from django.core.management import color [as 别名]
# 或者: from django.core.management.color import color_style [as 别名]
def __init__(self, *args, **kwargs):
        self.style = color_style()
        super(WSGIRequestHandler, self).__init__(*args, **kwargs) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:5,代码来源:basehttp.py

示例7: __init__

# 需要导入模块: from django.core.management import color [as 别名]
# 或者: from django.core.management.color import color_style [as 别名]
def __init__(self, *args, **kwargs):
        self.style = color_style()
        super().__init__(*args, **kwargs) 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:5,代码来源:log.py

示例8: main_help_text

# 需要导入模块: from django.core.management import color [as 别名]
# 或者: from django.core.management.color import color_style [as 别名]
def main_help_text(self, commands_only=False):
        """Return the script's main help text, as a string."""
        if commands_only:
            usage = sorted(get_commands())
        else:
            usage = [
                "",
                "Type '%s help <subcommand>' for help on a specific subcommand." % self.prog_name,
                "",
                "Available subcommands:",
            ]
            commands_dict = defaultdict(lambda: [])
            for name, app in get_commands().items():
                if app == 'django.core':
                    app = 'django'
                else:
                    app = app.rpartition('.')[-1]
                commands_dict[app].append(name)
            style = color_style()
            for app in sorted(commands_dict):
                usage.append("")
                usage.append(style.NOTICE("[%s]" % app))
                for name in sorted(commands_dict[app]):
                    usage.append("    %s" % name)
            # Output an extra note if settings are not properly configured
            if self.settings_exception is not None:
                usage.append(style.NOTICE(
                    "Note that only Django core commands are listed "
                    "as settings are not properly configured (error: %s)."
                    % self.settings_exception))

        return '\n'.join(usage) 
开发者ID:gojuukaze,项目名称:DeerU,代码行数:34,代码来源:__init__.py

示例9: run_migrations

# 需要导入模块: from django.core.management import color [as 别名]
# 或者: from django.core.management.color import color_style [as 别名]
def run_migrations(args, options, executor_codename, schema_name, allow_atomic=True, idx=None, count=None):
    from django.core.management import color
    from django.core.management.base import OutputWrapper
    from django.db import connections

    style = color.color_style()

    def style_func(msg):
        percent_str = ''
        if idx is not None and count is not None and count > 0:
            percent_str = '%d/%d (%s%%) ' % (idx + 1, count, int(100 * (idx + 1) / count))
        return '[%s%s:%s] %s' % (
            percent_str,
            style.NOTICE(executor_codename),
            style.NOTICE(schema_name),
            msg
        )

    connection = connections[options.get('database', get_tenant_database_alias())]
    connection.set_schema(schema_name)

    stdout = OutputWrapper(sys.stdout)
    stdout.style_func = style_func
    stderr = OutputWrapper(sys.stderr)
    stderr.style_func = style_func
    if int(options.get('verbosity', 1)) >= 1:
        stdout.write(style.NOTICE("=== Starting migration"))
    MigrateCommand(stdout=stdout, stderr=stderr).execute(*args, **options)

    try:
        transaction.commit()
        connection.close()
        connection.connection = None
    except transaction.TransactionManagementError:
        if not allow_atomic:
            raise

        # We are in atomic transaction, don't close connections
        pass

    connection.set_schema_to_public() 
开发者ID:django-tenants,项目名称:django-tenants,代码行数:43,代码来源:base.py

示例10: __init__

# 需要导入模块: from django.core.management import color [as 别名]
# 或者: from django.core.management.color import color_style [as 别名]
def __init__(self, *args, **kwargs):
        self.style = color_style()
        super(ServerFormatter, self).__init__(*args, **kwargs) 
开发者ID:Yeah-Kun,项目名称:python,代码行数:5,代码来源:log.py

示例11: main_help_text

# 需要导入模块: from django.core.management import color [as 别名]
# 或者: from django.core.management.color import color_style [as 别名]
def main_help_text(self, commands_only=False):
        """
        Returns the script's main help text, as a string.
        """
        if commands_only:
            usage = sorted(get_commands().keys())
        else:
            usage = [
                "",
                "Type '%s help <subcommand>' for help on a specific subcommand." % self.prog_name,
                "",
                "Available subcommands:",
            ]
            commands_dict = collections.defaultdict(lambda: [])
            for name, app in six.iteritems(get_commands()):
                if app == 'django.core':
                    app = 'django'
                else:
                    app = app.rpartition('.')[-1]
                commands_dict[app].append(name)
            style = color_style()
            for app in sorted(commands_dict.keys()):
                usage.append("")
                usage.append(style.NOTICE("[%s]" % app))
                for name in sorted(commands_dict[app]):
                    usage.append("    %s" % name)
        return '\n'.join(usage) 
开发者ID:blackye,项目名称:luscan-devel,代码行数:29,代码来源:__init__.py

示例12: __init__

# 需要导入模块: from django.core.management import color [as 别名]
# 或者: from django.core.management.color import color_style [as 别名]
def __init__(self):
        self.style = color_style() 
开发者ID:blackye,项目名称:luscan-devel,代码行数:4,代码来源:base.py

示例13: __init__

# 需要导入模块: from django.core.management import color [as 别名]
# 或者: from django.core.management.color import color_style [as 别名]
def __init__(self, outfile=sys.stdout):
        self.errors = []
        self.outfile = outfile
        self.style = color_style() 
开发者ID:blackye,项目名称:luscan-devel,代码行数:6,代码来源:validation.py

示例14: __init__

# 需要导入模块: from django.core.management import color [as 别名]
# 或者: from django.core.management.color import color_style [as 别名]
def __init__(self, *args, **kwargs):
        from django.conf import settings
        self.admin_static_prefix = urljoin(settings.STATIC_URL, 'admin/')
        # We set self.path to avoid crashes in log_message() on unsupported
        # requests (like "OPTIONS").
        self.path = ''
        self.style = color_style()
        super(WSGIRequestHandler, self).__init__(*args, **kwargs) 
开发者ID:blackye,项目名称:luscan-devel,代码行数:10,代码来源:basehttp.py

示例15: __init__

# 需要导入模块: from django.core.management import color [as 别名]
# 或者: from django.core.management.color import color_style [as 别名]
def __init__(self, stream):
        self.stream = stream
        self.errors = []
        self.color = color_style() 
开发者ID:elastic,项目名称:apm-agent-python,代码行数:6,代码来源:elasticapm.py


注:本文中的django.core.management.color.color_style方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。