python类conf()的实例源码

templates.py 文件源码 项目:djanoDoc 作者: JustinChavez 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def handle_template(self, template, subdir):
        """
        Determines where the app or project templates are.
        Use django.__path__[0] as the default because we don't
        know into which directory Django has been installed.
        """
        if template is None:
            return path.join(django.__path__[0], 'conf', subdir)
        else:
            if template.startswith('file://'):
                template = template[7:]
            expanded_template = path.expanduser(template)
            expanded_template = path.normpath(expanded_template)
            if path.isdir(expanded_template):
                return expanded_template
            if self.is_url(template):
                # downloads the file and returns the path
                absolute_path = self.download(template)
            else:
                absolute_path = path.abspath(expanded_template)
            if path.exists(absolute_path):
                return self.extract(absolute_path)

        raise CommandError("couldn't handle %s template %s." %
                           (self.app_or_project, template))
yamlconf.py 文件源码 项目:RPKI-toolkit 作者: pavel-odintsov 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def dump_rsyncd(self):
    lines = []
    if self.runs_pubd:
      lines.extend((
        "# Automatically generated, do not edit",
        "port         = %d"           % self.rsync_port,
        "address      = %s"           % self.hostname,
        "log file     = rsyncd.log",
        "read only    = yes",
        "use chroot   = no",
        "[rpki]",
        "path         = %s"           % self.publication_base_directory,
        "comment      = RPKI test"))
    if self.is_root:
      assert self.runs_pubd
      lines.extend((
        "[root]",
        "path         = %s"           % self.publication_root_directory,
        "comment      = RPKI test root"))
    if lines:
      with open(self.path("rsyncd.conf"), "w") as f:
        if not quiet:
          print "Writing", f.name
        f.writelines(line + "\n" for line in lines)
templates.py 文件源码 项目:CSCE482-WordcloudPlus 作者: ggaytan00 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def handle_template(self, template, subdir):
        """
        Determines where the app or project templates are.
        Use django.__path__[0] as the default because we don't
        know into which directory Django has been installed.
        """
        if template is None:
            return path.join(django.__path__[0], 'conf', subdir)
        else:
            if template.startswith('file://'):
                template = template[7:]
            expanded_template = path.expanduser(template)
            expanded_template = path.normpath(expanded_template)
            if path.isdir(expanded_template):
                return expanded_template
            if self.is_url(template):
                # downloads the file and returns the path
                absolute_path = self.download(template)
            else:
                absolute_path = path.abspath(expanded_template)
            if path.exists(absolute_path):
                return self.extract(absolute_path)

        raise CommandError("couldn't handle %s template %s." %
                           (self.app_or_project, template))
templates.py 文件源码 项目:tissuelab 作者: VirtualPlants 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def handle_template(self, template, subdir):
        """
        Determines where the app or project templates are.
        Use django.__path__[0] as the default because we don't
        know into which directory Django has been installed.
        """
        if template is None:
            return path.join(django.__path__[0], 'conf', subdir)
        else:
            if template.startswith('file://'):
                template = template[7:]
            expanded_template = path.expanduser(template)
            expanded_template = path.normpath(expanded_template)
            if path.isdir(expanded_template):
                return expanded_template
            if self.is_url(template):
                # downloads the file and returns the path
                absolute_path = self.download(template)
            else:
                absolute_path = path.abspath(expanded_template)
            if path.exists(absolute_path):
                return self.extract(absolute_path)

        raise CommandError("couldn't handle %s template %s." %
                           (self.app_or_project, template))
runtests.py 文件源码 项目:django-learning 作者: adoggie 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def run_tests():
    # Making Django run this way is a two-step process. First, call
    # settings.configure() to give Django settings to work with:
    from django.conf import settings
    settings.configure(**SETTINGS_DICT)

    # Then, call django.setup() to initialize the application cache
    # and other bits:
    import django
    if hasattr(django, 'setup'):
        django.setup()

    # Now we instantiate a test runner...
    from django.test.utils import get_runner
    TestRunner = get_runner(settings)

    # And then we run tests and return the results.
    test_runner = TestRunner(verbosity=1, interactive=True)
    failures = test_runner.run_tests(['registration.tests'])
    sys.exit(bool(failures))
templates.py 文件源码 项目:producthunt 作者: davidgengler 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def handle_template(self, template, subdir):
        """
        Determines where the app or project templates are.
        Use django.__path__[0] as the default because we don't
        know into which directory Django has been installed.
        """
        if template is None:
            return path.join(django.__path__[0], 'conf', subdir)
        else:
            if template.startswith('file://'):
                template = template[7:]
            expanded_template = path.expanduser(template)
            expanded_template = path.normpath(expanded_template)
            if path.isdir(expanded_template):
                return expanded_template
            if self.is_url(template):
                # downloads the file and returns the path
                absolute_path = self.download(template)
            else:
                absolute_path = path.abspath(expanded_template)
            if path.exists(absolute_path):
                return self.extract(absolute_path)

        raise CommandError("couldn't handle %s template %s." %
                           (self.app_or_project, template))
runtests.py 文件源码 项目:django-yandex-cash-register 作者: bzzzzzz 项目源码 文件源码 阅读 35 收藏 0 点赞 0 评论 0
def run_tests():
    # Making Django run this way is a two-step process. First, call
    # settings.configure() to give Django settings to work with:
    from django.conf import settings
    settings.configure(**SETTINGS_DICT)

    # Then, call django.setup() to initialize the application cache
    # and other bits:
    import django
    if hasattr(django, 'setup'):
        django.setup()

    # Now we instantiate a test runner...
    from django.test.utils import get_runner
    TestRunner = get_runner(settings)

    # And then we run tests and return the results.
    test_runner = TestRunner(verbosity=1, interactive=True)
    failures = test_runner.run_tests(['yandex_cash_register.tests'])
    sys.exit(bool(failures))
templates.py 文件源码 项目:django-rtc 作者: scifiswapnil 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def handle_template(self, template, subdir):
        """
        Determines where the app or project templates are.
        Use django.__path__[0] as the default because we don't
        know into which directory Django has been installed.
        """
        if template is None:
            return path.join(django.__path__[0], 'conf', subdir)
        else:
            if template.startswith('file://'):
                template = template[7:]
            expanded_template = path.expanduser(template)
            expanded_template = path.normpath(expanded_template)
            if path.isdir(expanded_template):
                return expanded_template
            if self.is_url(template):
                # downloads the file and returns the path
                absolute_path = self.download(template)
            else:
                absolute_path = path.abspath(expanded_template)
            if path.exists(absolute_path):
                return self.extract(absolute_path)

        raise CommandError("couldn't handle %s template %s." %
                           (self.app_or_project, template))
templates.py 文件源码 项目:geekpoint 作者: Lujinghu 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def handle_template(self, template, subdir):
        """
        Determines where the app or project templates are.
        Use django.__path__[0] as the default because we don't
        know into which directory Django has been installed.
        """
        if template is None:
            return path.join(django.__path__[0], 'conf', subdir)
        else:
            if template.startswith('file://'):
                template = template[7:]
            expanded_template = path.expanduser(template)
            expanded_template = path.normpath(expanded_template)
            if path.isdir(expanded_template):
                return expanded_template
            if self.is_url(template):
                # downloads the file and returns the path
                absolute_path = self.download(template)
            else:
                absolute_path = path.abspath(expanded_template)
            if path.exists(absolute_path):
                return self.extract(absolute_path)

        raise CommandError("couldn't handle %s template %s." %
                           (self.app_or_project, template))
setup.py 文件源码 项目:django-scim2 作者: 15five 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def run_tests():
    settings_mod = os.environ.get('DJANGO_SETTINGS_MODULE', 'test_settings')
    os.environ['DJANGO_SETTINGS_MODULE'] = settings_mod

    import django
    django.setup()
    from django.test.utils import get_runner
    from django.conf import settings

    test_filter = os.environ.get('TEST_FILTER')
    test_labels = [test_filter] if test_filter else []

    test_runner = get_runner(settings)
    failures = test_runner(
        pattern='test_*.py',
        verbosity=1,
        interactive=True
    ).run_tests(test_labels)
    sys.exit(failures)
templates.py 文件源码 项目:django-next-train 作者: bitpixdigital 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def handle_template(self, template, subdir):
        """
        Determines where the app or project templates are.
        Use django.__path__[0] as the default because we don't
        know into which directory Django has been installed.
        """
        if template is None:
            return path.join(django.__path__[0], 'conf', subdir)
        else:
            if template.startswith('file://'):
                template = template[7:]
            expanded_template = path.expanduser(template)
            expanded_template = path.normpath(expanded_template)
            if path.isdir(expanded_template):
                return expanded_template
            if self.is_url(template):
                # downloads the file and returns the path
                absolute_path = self.download(template)
            else:
                absolute_path = path.abspath(expanded_template)
            if path.exists(absolute_path):
                return self.extract(absolute_path)

        raise CommandError("couldn't handle %s template %s." %
                           (self.app_or_project, template))
fetch_gen_metadata.py 文件源码 项目:rfam-production 作者: Rfam 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def import_chromosome_names():
    """
    Parse GCA accession XML to import chromosome name and chromosome types
    into genseq table.
    """
    import django
    from django.conf import settings
    django.setup()
    from rfam_schemas.RfamLive.models import Genome, Genseq

    for genome in Genome.objects.exclude(assembly_acc__isnull=True).all():
        print genome.assembly_acc
        if 'GCF' in genome.assembly_acc:
            continue
        data = fetch_gca_data(genome.upid, genome.assembly_acc, 'kingdom')

        if 'fields' in data and 'chromosomes' in data and data['fields']['chromosomes']:
            for chromosome in data['fields']['chromosomes']:
                genseq = Genseq.objects.filter(rfamseq_acc=chromosome['accession'], upid=genome.upid).first()
                if genseq:
                    genseq.chromosome_type = chromosome['type']
                    genseq.chromosome_name = chromosome['name']
                    genseq.save()

# -----------------------------------------------------------------------------
templates.py 文件源码 项目:LatinSounds_AppEnviaMail 作者: G3ek-aR 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def handle_template(self, template, subdir):
        """
        Determines where the app or project templates are.
        Use django.__path__[0] as the default because we don't
        know into which directory Django has been installed.
        """
        if template is None:
            return path.join(django.__path__[0], 'conf', subdir)
        else:
            if template.startswith('file://'):
                template = template[7:]
            expanded_template = path.expanduser(template)
            expanded_template = path.normpath(expanded_template)
            if path.isdir(expanded_template):
                return expanded_template
            if self.is_url(template):
                # downloads the file and returns the path
                absolute_path = self.download(template)
            else:
                absolute_path = path.abspath(expanded_template)
            if path.exists(absolute_path):
                return self.extract(absolute_path)

        raise CommandError("couldn't handle %s template %s." %
                           (self.app_or_project, template))
runner.py 文件源码 项目:maas 作者: maas 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def run_protractor():
    """Start Protractor with the MAAS JS E2E testing configuration.

    1. Start regiond.
    2. Start rackd.
    3. Start xvfb.
    4. Start chromium webdriver.
    5. Run protractor.
    6. Stop chromium webdriver.
    7. Stop xvfb.
    8. Stop rackd.
    9. Stop regiond.
    """
    with MAASRegionServiceFixture(), MAASClusterServiceFixture():
        with DisplayFixture(), ChromiumWebDriverFixture():
            protractor = Popen((
                "bin/protractor",
                "src/maastesting/protractor/protractor.conf.js"))
            protractor_exit = protractor.wait()
    sys.exit(protractor_exit)
templates.py 文件源码 项目:DjangoZeroToHero 作者: RayParra 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def handle_template(self, template, subdir):
        """
        Determines where the app or project templates are.
        Use django.__path__[0] as the default because we don't
        know into which directory Django has been installed.
        """
        if template is None:
            return path.join(django.__path__[0], 'conf', subdir)
        else:
            if template.startswith('file://'):
                template = template[7:]
            expanded_template = path.expanduser(template)
            expanded_template = path.normpath(expanded_template)
            if path.isdir(expanded_template):
                return expanded_template
            if self.is_url(template):
                # downloads the file and returns the path
                absolute_path = self.download(template)
            else:
                absolute_path = path.abspath(expanded_template)
            if path.exists(absolute_path):
                return self.extract(absolute_path)

        raise CommandError("couldn't handle %s template %s." %
                           (self.app_or_project, template))
templates.py 文件源码 项目:Roboism 作者: markroxor 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def handle_template(self, template, subdir):
        """
        Determines where the app or project templates are.
        Use django.__path__[0] as the default because we don't
        know into which directory Django has been installed.
        """
        if template is None:
            return path.join(django.__path__[0], 'conf', subdir)
        else:
            if template.startswith('file://'):
                template = template[7:]
            expanded_template = path.expanduser(template)
            expanded_template = path.normpath(expanded_template)
            if path.isdir(expanded_template):
                return expanded_template
            if self.is_url(template):
                # downloads the file and returns the path
                absolute_path = self.download(template)
            else:
                absolute_path = path.abspath(expanded_template)
            if path.exists(absolute_path):
                return self.extract(absolute_path)

        raise CommandError("couldn't handle %s template %s." %
                           (self.app_or_project, template))
templates.py 文件源码 项目:django-wechat-api 作者: crazy-canux 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def handle_template(self, template, subdir):
        """
        Determines where the app or project templates are.
        Use django.__path__[0] as the default because we don't
        know into which directory Django has been installed.
        """
        if template is None:
            return path.join(django.__path__[0], 'conf', subdir)
        else:
            if template.startswith('file://'):
                template = template[7:]
            expanded_template = path.expanduser(template)
            expanded_template = path.normpath(expanded_template)
            if path.isdir(expanded_template):
                return expanded_template
            if self.is_url(template):
                # downloads the file and returns the path
                absolute_path = self.download(template)
            else:
                absolute_path = path.abspath(expanded_template)
            if path.exists(absolute_path):
                return self.extract(absolute_path)

        raise CommandError("couldn't handle %s template %s." %
                           (self.app_or_project, template))
setup.py 文件源码 项目:django-easy-regist 作者: naritotakizawa 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def run_tests(self):
        # import here, cause outside the eggs aren't loaded
        import django
        from django.conf import settings
        from django.test.utils import get_runner
        os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.test_settings'
        django.setup()
        TestRunner = get_runner(settings)
        test_runner = TestRunner()
        failures = test_runner.run_tests(['tests'])
        sys.exit(bool(failures))


问题


面经


文章

微信
公众号

扫码关注公众号