當前位置: 首頁>>代碼示例>>Python>>正文


Python settings.SITE_ROOT屬性代碼示例

本文整理匯總了Python中django.conf.settings.SITE_ROOT屬性的典型用法代碼示例。如果您正苦於以下問題:Python settings.SITE_ROOT屬性的具體用法?Python settings.SITE_ROOT怎麽用?Python settings.SITE_ROOT使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在django.conf.settings的用法示例。


在下文中一共展示了settings.SITE_ROOT屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: run_playbook

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import SITE_ROOT [as 別名]
def run_playbook(self, ansible_vars):
        """
        Run the playbook to perform the server reconfiguration.

        This is factored out into a separate method so it can be mocked out in the tests.
        """
        if settings.DISABLE_LOAD_BALANCER_CONFIGURATION:
            self.logger.info(
                'Direct load balancer reconfiguration disabled. Skipping %s configuration...',
                self
            )
            return

        playbook_path = pathlib.Path(settings.SITE_ROOT) / "playbooks/load_balancer_conf/load_balancer_conf.yml"
        returncode = ansible.capture_playbook_output(
            requirements_path=str(playbook_path.parent / "requirements.txt"),
            inventory_str=self.domain,
            vars_str=ansible_vars,
            playbook_path=str(playbook_path),
            username=self.ssh_username,
            logger_=self.logger,
        )
        if returncode != 0:
            self.logger.error("Playbook to reconfigure load-balancing server %s failed.", self)
            raise ReconfigurationFailed 
開發者ID:open-craft,項目名稱:opencraft,代碼行數:27,代碼來源:load_balancer.py

示例2: manage_services_playbook

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import SITE_ROOT [as 別名]
def manage_services_playbook(self, action, services="all"):
        """
        Return a Playbook instance for creating LMS users.
        """
        playbook_settings = yaml.dump(
            {
                "supervisord_action": action,
                "services": services,
            },
            default_flow_style=False
        )

        return Playbook(
            version=None,
            source_repo=os.path.join(settings.SITE_ROOT, 'playbooks/manage_services'),
            requirements_path='requirements.txt',
            playbook_path='manage_services.yml',
            variables=playbook_settings,
        ) 
開發者ID:open-craft,項目名稱:opencraft,代碼行數:21,代碼來源:openedx_appserver.py

示例3: test_manage_instance_services

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import SITE_ROOT [as 別名]
def test_manage_instance_services(self, mocks, mock_consul):
        """
        Test if manage instance services is correctly running the playbook
        """
        instance = OpenEdXInstanceFactory(internal_lms_domain='test.activate.opencraft.co.uk')
        appserver_id = instance.spawn_appserver()
        appserver = instance.appserver_set.get(pk=appserver_id)
        expected_playbook = Playbook(
            version=None,
            source_repo=os.path.join(settings.SITE_ROOT, 'playbooks/manage_services'),
            playbook_path='manage_services.yml',
            requirements_path='requirements.txt',
            variables='services: all\nsupervisord_action: start\n'
        )

        appserver.manage_instance_services(active=True)

        self.assertEqual(mocks.mock_run_appserver_playbooks.call_count, 1)
        mocks.mock_run_appserver_playbooks.assert_called_once_with(
            playbook=expected_playbook,
            working_dir=expected_playbook.source_repo,
        ) 
開發者ID:open-craft,項目名稱:opencraft,代碼行數:24,代碼來源:test_openedx_appserver.py

示例4: action

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import SITE_ROOT [as 別名]
def action(request):
    server = request.POST['server']
    supervisor = _get_supervisor(server)
    try:
        if 'action_start_all' in request.POST:
            supervisor.supervisor.startAllProcesses()
            return HttpResponse(json.dumps("ok"),
                                content_type='application/json')
        elif 'action_stop_all' in request.POST:
            supervisor.supervisor.stopAllProcesses()
            return HttpResponse(json.dumps("ok"),
                                content_type='application/json')
        program = "{}:{}".format(request.POST['group'], request.POST['program'])
        if 'action_start' in request.POST:
            supervisor.supervisor.startProcess(program)
        elif 'action_stop' in request.POST:
            supervisor.supervisor.stopProcess(program)
        elif 'action_restart' in request.POST:
            supervisor.supervisor.stopProcess(program)
            supervisor.supervisor.startProcess(program)

    finally:
        supervisor("close")()
    return redirect(settings.SITE_ROOT) 
開發者ID:GambitResearch,項目名稱:suponoff,代碼行數:26,代碼來源:views.py

示例5: handle

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import SITE_ROOT [as 別名]
def handle(self, *args, **options):
        if settings.TELEGRAM_TOKEN is None:
            return "Abort: settings.TELEGRAM_TOKEN is not set"

        form = {
            "url": settings.SITE_ROOT + reverse("hc-telegram-webhook"),
            "allowed_updates": ["message"],
        }

        url = SETWEBHOOK_TMPL % settings.TELEGRAM_TOKEN
        r = requests.post(url, json=form)

        if r.status_code != 200:
            return "Fail: status=%d, %s" % (r.status_code, r.content)

        return "Done, Telegram's webhook set to: %s" % form["url"] 
開發者ID:healthchecks,項目名稱:healthchecks,代碼行數:18,代碼來源:settelegramwebhook.py

示例6: add_discord

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import SITE_ROOT [as 別名]
def add_discord(request, code):
    project = _get_project_for_user(request, code)
    redirect_uri = settings.SITE_ROOT + reverse("hc-add-discord-complete")
    state = token_urlsafe()
    auth_url = "https://discordapp.com/api/oauth2/authorize?" + urlencode(
        {
            "client_id": settings.DISCORD_CLIENT_ID,
            "scope": "webhook.incoming",
            "redirect_uri": redirect_uri,
            "response_type": "code",
            "state": state,
        }
    )

    ctx = {"page": "channels", "project": project, "authorize_url": auth_url}

    request.session["add_discord"] = (state, str(project.code))
    return render(request, "integrations/add_discord.html", ctx) 
開發者ID:healthchecks,項目名稱:healthchecks,代碼行數:20,代碼來源:views.py

示例7: handle

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import SITE_ROOT [as 別名]
def handle(self, *args, **options):
        r = requests.post('http://api.patreon.com/oauth2/token', data={
            'grant_type': 'refresh_token',
            'refresh_token': os.getenv('PATREON_REFRESH_TOKEN'),
            'client_id': os.getenv('PATREON_CLIENT_ID'),
            'client_secret': os.getenv('PATREON_CLIENT_SECRET'),
        })

        tokens = r.json()

        print(tokens)

        if 'error' in tokens:
            exit()

        with open(os.path.join(settings.SITE_ROOT, 'settings/secrets.py'), 'r') as f:
            settings_data = f.read()

        settings_data = settings_data.replace(os.getenv('PATREON_REFRESH_TOKEN'), tokens['refresh_token'])
        settings_data = settings_data.replace(os.getenv('PATREON_ACCESS_TOKEN'), tokens['access_token'])

        print(settings_data)

        with open(os.path.join(settings.SITE_ROOT, 'settings/secrets.py'), 'w') as f:
            f.write(settings_data) 
開發者ID:rocket-league-replays,項目名稱:rocket-league-replays,代碼行數:27,代碼來源:update_patreon_tokens.py

示例8: enable_bulk_emails_playbook

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import SITE_ROOT [as 別名]
def enable_bulk_emails_playbook(self):
        """
        Return a Playbook instance for enabling the Bulk Email feature.
        """
        return Playbook(
            version=None,
            source_repo=os.path.join(settings.SITE_ROOT, 'playbooks/enable_bulk_emails'),
            requirements_path='requirements.txt',
            playbook_path='enable_bulk_emails.yml',
            variables='{}',
        ) 
開發者ID:open-craft,項目名稱:opencraft,代碼行數:13,代碼來源:openedx_appserver.py

示例9: get_index_template_data

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import SITE_ROOT [as 別名]
def get_index_template_data():
    metadata, tags_config, taggroups_dict = _get_metadata_conf()
    services_by_host = _get_data({}, metadata)

    all_tags = set()
    for server_data in services_by_host.values():
        for group in server_data.values():
            all_tags.update(group['tags'])

    tags_by_group = defaultdict(set)
    for tag_name in all_tags:
        tag = tags_config[tag_name]
        tags_by_group[tag.taggroup].add(tag_name)
    taggroups = []
    for name, tags in sorted(tags_by_group.items()):
        taggroups.append((taggroups_dict[name].label, sorted(tags)))

    # sort everything
    data = []
    for server, groups in sorted(services_by_host.items()):
        data.append((server, sorted(groups.items())))

    context = {
        "data": data,
        "taggroups": taggroups,
        'tags_config': tags_config,
        "SITE_ROOT": settings.SITE_ROOT,
    }
    return context 
開發者ID:GambitResearch,項目名稱:suponoff,代碼行數:31,代碼來源:views.py

示例10: notifications_url

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import SITE_ROOT [as 別名]
def notifications_url(self):
        return settings.SITE_ROOT + reverse("hc-notifications") 
開發者ID:healthchecks,項目名稱:healthchecks,代碼行數:4,代碼來源:models.py

示例11: reports_unsub_url

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import SITE_ROOT [as 別名]
def reports_unsub_url(self):
        signer = TimestampSigner(salt="reports")
        signed_username = signer.sign(self.user.username)
        path = reverse("hc-unsubscribe-reports", args=[signed_username])
        return settings.SITE_ROOT + path 
開發者ID:healthchecks,項目名稱:healthchecks,代碼行數:7,代碼來源:models.py

示例12: send_instant_login_link

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import SITE_ROOT [as 別名]
def send_instant_login_link(self, inviting_project=None, redirect_url=None):
        token = self.prepare_token("login")
        path = reverse("hc-check-token", args=[self.user.username, token])
        if redirect_url:
            path += "?next=%s" % redirect_url

        ctx = {
            "button_text": "Sign In",
            "button_url": settings.SITE_ROOT + path,
            "inviting_project": inviting_project,
        }
        emails.login(self.user.email, ctx) 
開發者ID:healthchecks,項目名稱:healthchecks,代碼行數:14,代碼來源:models.py

示例13: send_transfer_request

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import SITE_ROOT [as 別名]
def send_transfer_request(self, project):
        token = self.prepare_token("login")
        settings_path = reverse("hc-project-settings", args=[project.code])
        path = reverse("hc-check-token", args=[self.user.username, token])
        path += "?next=%s" % settings_path

        ctx = {
            "button_text": "Project Settings",
            "button_url": settings.SITE_ROOT + path,
            "project": project,
        }
        emails.transfer_request(self.user.email, ctx) 
開發者ID:healthchecks,項目名稱:healthchecks,代碼行數:14,代碼來源:models.py

示例14: send_set_password_link

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import SITE_ROOT [as 別名]
def send_set_password_link(self):
        token = self.prepare_token("set-password")
        path = reverse("hc-set-password", args=[token])
        ctx = {"button_text": "Set Password", "button_url": settings.SITE_ROOT + path}
        emails.set_password(self.user.email, ctx) 
開發者ID:healthchecks,項目名稱:healthchecks,代碼行數:7,代碼來源:models.py

示例15: send_sms_limit_notice

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import SITE_ROOT [as 別名]
def send_sms_limit_notice(self, transport):
        ctx = {"transport": transport, "limit": self.sms_limit}
        if self.sms_limit != 500 and settings.USE_PAYMENTS:
            ctx["url"] = settings.SITE_ROOT + reverse("hc-pricing")

        emails.sms_limit(self.user.email, ctx) 
開發者ID:healthchecks,項目名稱:healthchecks,代碼行數:8,代碼來源:models.py


注:本文中的django.conf.settings.SITE_ROOT屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。