Skip to content

Commit 6cb2f33

Browse files
author
Kairo Araujo
authored
Merge branch 'main' into rstuf-bootstrap
2 parents 058a23d + 447aef7 commit 6cb2f33

File tree

4 files changed

+86
-5
lines changed

4 files changed

+86
-5
lines changed

bin/redis-tls

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ REDIS_URL="$(echo $REDIS_URL | sed "s/:[0-9][0-9]*$/:$REDIS_PORT/g" )"
1414
# REDIS_URL.
1515
unset REDIS_PORT
1616

17+
# Ensure all clients have a 5-second timeout.
1718
# Configure the TLS settings for our Redis connection
18-
REDIS_URL="$REDIS_URL?ssl_cert_reqs=required&ssl_ca_certs=$(python -m certifi)"
19+
REDIS_URL="$REDIS_URL?socket_timeout=5&ssl_cert_reqs=required&ssl_ca_certs=$(python -m certifi)"

warehouse/cli/observations.py

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Licensed under the Apache License, Version 2.0 (the "License");
2+
# you may not use this file except in compliance with the License.
3+
# You may obtain a copy of the License at
4+
#
5+
# http://www.apache.org/licenses/LICENSE-2.0
6+
#
7+
# Unless required by applicable law or agreed to in writing, software
8+
# distributed under the License is distributed on an "AS IS" BASIS,
9+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
# See the License for the specific language governing permissions and
11+
# limitations under the License.
12+
13+
import random
14+
15+
import click
16+
17+
from warehouse.cli import warehouse
18+
19+
20+
@warehouse.group()
21+
def observations():
22+
"""
23+
Group for observation commands.
24+
"""
25+
26+
27+
@observations.command()
28+
@click.pass_obj
29+
def generate_random_observations(config): # pragma: no cover # dev-only tool
30+
"""
31+
Generate random Observations, DEVELOPMENT ONLY
32+
33+
Generates random observations for 10 projects in the database,
34+
along with any associated Observer models.
35+
It is only available in development mode, useful for
36+
"""
37+
# Imported here because we don't want to trigger an import from anything
38+
# but warehouse.cli at the module scope.
39+
from sqlalchemy import select
40+
41+
from warehouse.accounts.models import User
42+
from warehouse.config import Environment
43+
from warehouse.db import Session
44+
from warehouse.observations.models import ObservationKind
45+
from warehouse.packaging.models import Project
46+
47+
# bail early if not in development
48+
if not config.registry.settings.get("warehouse.env") == Environment.development:
49+
raise click.ClickException(
50+
"This command is only available in development mode."
51+
)
52+
53+
session = Session(bind=config.registry["sqlalchemy.engine"])
54+
55+
# A `request`-like object that implements the `db` method
56+
class MockRequest:
57+
def __init__(self):
58+
self.db = session
59+
60+
request = MockRequest()
61+
62+
# Get 10 users and project
63+
users = session.scalars(select(User).limit(10)).unique().all()
64+
projects = session.scalars(select(Project).limit(10)).all()
65+
66+
# generate 10 random observations for each project
67+
for project in projects:
68+
[
69+
project.record_observation(
70+
request=request,
71+
kind=random.choice(list(ObservationKind)),
72+
actor=random.choice(users),
73+
summary="CLI Generated",
74+
payload={"origin": "CLI"},
75+
)
76+
for _ in range(10)
77+
]
78+
session.commit() # Finally, commit the transaction
79+
80+
click.echo("Generated random observations for 10 projects.")

warehouse/locale/messages.pot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1103,7 +1103,7 @@ msgid "About PyPI navigation"
11031103
msgstr ""
11041104

11051105
#: warehouse/templates/base.html:291
1106-
msgid "PyPI on Twitter"
1106+
msgid "PyPI Blog"
11071107
msgstr ""
11081108

11091109
#: warehouse/templates/base.html:292

warehouse/templates/base.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@
6363

6464
{% macro trademarks(long=False) -%}
6565
{% if long %}
66-
{% trans wordmark="PyPI", name="Python Package Index", psf_href="https://python.org/psf-landing", trademarks_href=request.route_path('trademarks') %}
66+
{% trans wordmark="PyPI", name="Python Package Index", psf_href="https://www.python.org/psf-landing", trademarks_href=request.route_path('trademarks') %}
6767
"{{ wordmark }}", "{{ name }}", and the blocks logos are registered trademarks of the <a href="{{ psf_href }}" target="_blank" rel="noopener">Python Software Foundation</a> referring to the products and services associated with pypi.org. Any other use by any other party is prohibited.
6868
{% endtrans %}
6969
{% else %}
70-
{% trans wordmark="PyPI", name="Python Package Index", psf_href="https://python.org/psf-landing", trademarks_href=request.route_path('trademarks') %}
70+
{% trans wordmark="PyPI", name="Python Package Index", psf_href="https://www.python.org/psf-landing", trademarks_href=request.route_path('trademarks') %}
7171
"{{ wordmark }}", "{{ name }}", and the blocks logos are registered <a href="{{ trademarks_href }}">trademarks</a> of the <a href="{{ psf_href }}" target="_blank" rel="noopener">Python Software Foundation</a>.
7272
{% endtrans %}
7373
{% endif %}
@@ -288,7 +288,7 @@ <h2>{% trans %}Help{% endtrans %}</h2>
288288
<h2>{% trans %}About PyPI{% endtrans %}</h2>
289289
<nav aria-label="{% trans %}About PyPI navigation{% endtrans %}">
290290
<ul>
291-
<li><a href="https://twitter.com/PyPI" title="{% trans %}External link{% endtrans %}" target="_blank" rel="noopener">{% trans %}PyPI on Twitter{% endtrans %}</a></li>
291+
<li><a href="https://blog.pypi.org" title="{% trans %}External link{% endtrans %}" target="_blank" rel="noopener">{% trans %}PyPI Blog{% endtrans %}</a></li>
292292
<li><a href="https://dtdg.co/pypi" title="{% trans %}External link{% endtrans %}" target="_blank" rel="noopener">{% trans %}Infrastructure dashboard{% endtrans %}</a></li>
293293
<li><a href="{{ request.route_path('stats') }}">{% trans %}Statistics{% endtrans %}</a></li>
294294
<li><a href="{{ request.route_path('trademarks') }}">{% trans %}Logos & trademarks{% endtrans %}</a></li>

0 commit comments

Comments
 (0)