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


Python settings.PROJECT_DIR属性代码示例

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


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

示例1: handle

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import PROJECT_DIR [as 别名]
def handle(self, *args, **options):

        # 1. remove migration files
        custom_apps = [i.replace('apps.', '') for i in settings.INSTALLED_APPS if
                       i.startswith('apps.')]
        for app_name in custom_apps:
            app_migrations_path = os.path.join(settings.PROJECT_DIR, f'apps/{app_name}/migrations')
            shutil.rmtree(app_migrations_path, ignore_errors=True)

        # drop migrations table
        with connection.cursor() as cursor:
            cursor.execute('DROP TABLE django_migrations;')

        # re-create migration files
        call_command('makemigrations', 'common')
        call_command('makemigrations')

        # re-fill migrations
        call_command('migrate', '--fake') 
开发者ID:LexPredict,项目名称:lexpredict-contraxsuite,代码行数:21,代码来源:force_reinitiate_migrations.py

示例2: send_post_register_email

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import PROJECT_DIR [as 别名]
def send_post_register_email(request, user):
    # Send optional email after successful registration (issue #261)
    template_path = path.join(settings.PROJECT_DIR, 'gui', 'templates')
    subject = 'gui/accounts/post_register_subject.txt'
    subject_path = path.join(template_path, subject)
    body_file_prefix = 'gui/accounts/post_register_email'
    body = None

    if path.exists(subject_path) and path.exists(path.join(template_path, body_file_prefix + '.html')):
        body = body_file_prefix + '.html'
    elif path.exists(subject_path) and path.exists(path.join(template_path, body_file_prefix + '.txt')):
        body = body_file_prefix + '.txt'

    if body:
        sendmail(user, subject, body, dc=request.dc)
    else:
        logger.info('Post registration email subject template: "%s" or body template: "%s" does not exists.' %
                    (subject_path, path.join(template_path, body_file_prefix + '.[html|txt]'))) 
开发者ID:erigones,项目名称:esdc-ce,代码行数:20,代码来源:views.py

示例3: download

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import PROJECT_DIR [as 别名]
def download(request, key, format, page_size="A4"):
    wallet = get_object_or_404(Wallet, key=key)
    page_size_prefix = ""
    if page_size == "US":
        page_size_prefix = "us-"
    fn = '/static/%s/tips-%s%s.%s' % (format,
                                      page_size_prefix, wallet.key, format)
    i = 0

    while not os.path.exists("%s/%s" % (settings.PROJECT_DIR, fn)):
        if i == 0:
            result = celery_generate_pdf.delay(wallet)
            time.sleep(25)
        if i > 0:
            ctx = {'result': result.ready(), 'info': result.info}
            return render_to_response("not_yet.html", context_instance=RequestContext(request, ctx))
        i += 1

    return HttpResponseRedirect(fn) 
开发者ID:norn,项目名称:bctip,代码行数:21,代码来源:views.py

示例4: handle

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import PROJECT_DIR [as 别名]
def handle(self, *args, **options):
        if not Role.objects.exists():
            fixture_path = os.path.join(
                str(settings.PROJECT_DIR),
                'fixtures',
                'common',
                '1_Role.json'
            )
            call_command('loaddata', fixture_path, app_label='users') 
开发者ID:LexPredict,项目名称:lexpredict-contraxsuite,代码行数:11,代码来源:load_roles.py

示例5: download_pdf

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import PROJECT_DIR [as 别名]
def download_pdf(data: pd.DataFrame, file_name='output'):
    data_html = data.to_html(index=False)
    try:
        data_pdf = pdf.from_string(data_html, False)
    except OSError:
        env = Environment(loader=FileSystemLoader(settings.PROJECT_DIR('templates')))
        template = env.get_template('pdf_export.html')
        template_vars = {"title": file_name.capitalize(),
                         "table": data_html}
        data_pdf = HTML(string=template.render(template_vars)).write_pdf()
    response = HttpResponse(content_type='application/pdf')
    response['Content-Disposition'] = 'attachment; filename="{}.{}"'.format(file_name, 'pdf')
    response.write(data_pdf)
    return response 
开发者ID:LexPredict,项目名称:lexpredict-contraxsuite,代码行数:16,代码来源:utils.py

示例6: handle

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import PROJECT_DIR [as 别名]
def handle(self, *args, **options):
        if not ReviewStatusGroup.objects.exists():
            fixture_path = os.path.join(
                str(settings.PROJECT_DIR),
                'fixtures',
                'common',
                '2_ReviewStatusGroup.json'
            )
            call_command('loaddata', fixture_path, app_label='common') 
开发者ID:LexPredict,项目名称:lexpredict-contraxsuite,代码行数:11,代码来源:load_review_status_groups.py

示例7: handle

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import PROJECT_DIR [as 别名]
def handle(self, *args, **options):
        if not ReviewStatus.objects.exists():
            fixture_path = os.path.join(
                str(settings.PROJECT_DIR),
                'fixtures',
                'common',
                '3_ReviewStatus.json'
            )
            call_command('loaddata', fixture_path, app_label='common') 
开发者ID:LexPredict,项目名称:lexpredict-contraxsuite,代码行数:11,代码来源:load_review_statuses.py

示例8: handle

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import PROJECT_DIR [as 别名]
def handle(self, *args, **options):
        if not FieldAnnotationStatus.objects.exists():
            fixture_path = os.path.join(
                str(settings.PROJECT_DIR),
                'fixtures',
                'common',
                '4_FieldAnnotationStatus.json'
            )
            call_command('loadnewdata', fixture_path, app_label='common') 
开发者ID:LexPredict,项目名称:lexpredict-contraxsuite,代码行数:11,代码来源:load_annotation_statuses.py

示例9: get

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import PROJECT_DIR [as 别名]
def get(cls):
        if cls.__instance is None:
            # initialise the 'inner' PluginManagerDecorator
            cls.__instance = yapsy.PluginManager.PluginManager()
            cls.__instance.setPluginPlaces([settings.PLUGIN_DIR, os.path.join(
                settings.PROJECT_DIR, 'server/plugins')])
            cls.__instance.collectPlugins()
            # Move this attribute because we don't use the container
            # object in Sal. Set it once here rather than at every
            # retrieval!
            for plugin in cls.__instance.getAllPlugins():
                plugin.plugin_object.path = plugin.path
            logger.debug("PluginManagerSingleton initialised")
        return cls.__instance 
开发者ID:salopensource,项目名称:sal,代码行数:16,代码来源:plugin.py

示例10: create_apps_dir

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import PROJECT_DIR [as 别名]
def create_apps_dir(apps_dir=getattr(settings, 'APPS_DIR', None)):
    if not apps_dir:
        project_dir = getattr(settings, 'BASE_DIR', settings.PROJECT_DIR)
        apps_dir = os.path.abspath(os.path.join(
            os.path.dirname(project_dir), "apps"))
    if not os.path.exists(apps_dir):
        create_direcotry(apps_dir)
        if not os.access(apps_dir, os.W_OK):
            change_path_permission(apps_dir) 
开发者ID:cartologic,项目名称:cartoview,代码行数:11,代码来源:utils.py

示例11: ssl_certificate

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import PROJECT_DIR [as 别名]
def ssl_certificate(self):
        """PUT /system/settings/ssl-certificate - runs a script, which checks the certificate by running openssl,
        replaces the PEM file and reloads haproxy"""
        assert self.request.dc.id == DefaultDc().id

        ser = SSLCertificateSerializer(self.request, data=self.data)

        if not ser.is_valid():
            return FailureTaskResponse(self.request, ser.errors, dc_bound=False)

        cert = ser.object['cert']
        update_script = os.path.join(settings.PROJECT_DIR, self.SSL_CERTIFICATE_UPDATE_CMD)
        res = {
            'action': 'SSL Certificate Update',
            'returncode': '???',
            'message': ''
        }

        cert_file = NamedTemporaryFile(dir=settings.TMPDIR, mode='w', delete=False)
        cert_file.write(cert)
        cert_file.close()

        try:
            proc = Popen(['sudo', update_script, cert_file.name], bufsize=0, close_fds=True, stdout=PIPE, stderr=STDOUT)
            res['message'], _ = proc.communicate()
            res['returncode'] = proc.returncode
        finally:
            os.remove(cert_file.name)

        if proc.returncode == 0:
            response_class = SuccessTaskResponse
        else:
            response_class = FailureTaskResponse

        return response_class(self.request, res, msg=LOG_SYSTEM_SETTINGS_UPDATE, detail_dict=res, dc_bound=False) 
开发者ID:erigones,项目名称:esdc-ce,代码行数:37,代码来源:api_views.py

示例12: _es_api_url

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import PROJECT_DIR [as 别名]
def _es_api_url(site_link):
    """Update API_URL in es"""
    es_src = os.path.join(settings.PROJECT_DIR, 'bin', 'es')
    es_dst = os.path.join(settings.PROJECT_DIR, 'var', 'www', 'static', 'api', 'bin', 'es')
    api_url = "API_URL = '%s'" % (site_link + '/api')
    logger.info('Replacing API_URL in %s with "%s"', es_dst, api_url)

    with open(es_src) as es1:
        # noinspection PyTypeChecker
        with os.fdopen(os.open(es_dst, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o644), 'w') as es2:
            es2.write(es1.read().replace("API_URL = 'http://127.0.0.1:8000/api'", api_url)) 
开发者ID:erigones,项目名称:esdc-ce,代码行数:13,代码来源:init.py

示例13: get_git_version

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import PROJECT_DIR [as 别名]
def get_git_version(self):
        with lcd(self.PROJECT_DIR):
            _tag = self.local(self.cmd_tag, capture=True).strip().split('/')[-1]
            _sha = self.local(self.cmd_sha, capture=True).strip()

            return _tag, _sha 
开发者ID:erigones,项目名称:esdc-ce,代码行数:8,代码来源:_base.py

示例14: celery_generate_pdf

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import PROJECT_DIR [as 别名]
def celery_generate_pdf(wallet):
    activate(wallet.target_language)
    tips = Tip.objects.filter(wallet=wallet).order_by('id')
    ctx = {'wallet':wallet, 'tips':tips}
    ctx['cur_sign'] = CURRENCY_SIGNS[wallet.divide_currency]
    #print "asdff"
    #_startDate = home.home_startdate.strftime('%m/%d/%Y')
    # let's begin
    unique_tmp = '/tmp/w%s.odt'%wallet.id
    shutil.copyfile(settings.WEBODT_TEMPLATE_PATH +"/"+ wallet.template, unique_tmp)
    inpt = zipfile.ZipFile(unique_tmp, "a" )
    text = StringIO.StringIO()
    for tip in tips:
        inpt.writestr("Pictures/%s.png"%tip.id, qrcode_img(tip.get_absolute_url()) )
    manifest = Template( inpt.read( 'META-INF/manifest.xml' ) )
    inpt.writestr("META-INF/manifest.xml", manifest.render( Context(ctx) ))
    inpt.close()
    # fuu
    #template = webodt.ODFTemplate(unique_tmp) #webodt.HTMLTemplate('test.html')
    #document = template.render(Context(ctx))
    document = odt_template(unique_tmp, Context(ctx))
    document_us = odt_template(unique_tmp, Context(ctx), page_size="US")

    #odt
    fn = settings.PROJECT_DIR+"/static/odt/tips-%s.odt"%wallet.key
    f = open(fn,'w')
    f.write(document)
    f.close()

    fn = settings.PROJECT_DIR+"/static/odt/tips-us-%s.odt"%wallet.key
    f = open(fn,'w')
    f.write(document_us)
    f.close()

    #pdf
    s=["unoconv", "-f", "pdf", "-o", settings.PROJECT_DIR+"/static/pdf/tips-%s.pdf"%wallet.key, settings.PROJECT_DIR+"/static/odt/tips-%s.odt"%wallet.key]
    subprocess.call(s)
    subp = subprocess.Popen(s, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    retval = subp.wait()

    s=["unoconv", "-f", "pdf", "-o", settings.PROJECT_DIR+"/static/pdf/tips-us-%s.pdf"%wallet.key, settings.PROJECT_DIR+"/static/odt/tips-us-%s.odt"%wallet.key]
    subprocess.call(s)
    subp = subprocess.Popen(s, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    retval = subp.wait()

    #png
    s=["convert", "-density", "300", "-trim", settings.PROJECT_DIR+"/static/pdf/tips-%s.pdf"%wallet.key, settings.PROJECT_DIR+"/static/png/tips-%s.png"%wallet.key]
    subprocess.call(s)
    subp = subprocess.Popen(s, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    retval = subp.wait()

    return True 
开发者ID:norn,项目名称:bctip,代码行数:54,代码来源:tasks.py


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