當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。