text
stringlengths
185
73.3k
repo
stringlengths
7
100
path
stringlengths
4
146
language
stringclasses
7 values
hash
stringlengths
16
16
score
float64
7
8.5
stars
int64
0
237k
"""Servicio centralizado y reusable de bitácora de auditoría (append-only).""" from __future__ import annotations import json import re from collections.abc import Mapping from dataclasses import asdict, is_dataclass from datetime import date, datetime from decimal import Decimal, InvalidOperation from typing import ...
cacao-accounting/cacao-accounting
cacao_accounting/audit_trail_service.py
.py
ed99e5d594f1a375
7.5
9
# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: 2025 - 2026 William José Moreno Reyes """Protección contra credential stuffing por cuenta de usuario. Implementa cooldown temporal exponencial con auto-unlock para cuentas que exceden un umbral de intentos de inicio de sesión fallidos. Política de bloque...
cacao-accounting/cacao-accounting
cacao_accounting/auth/account_throttling.py
.py
3592f8a1c48da264
7.5
9
# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: 2025 - 2026 William José Moreno Reyes """Verificación de dispositivos, OTP y recuperación de contraseña.""" from __future__ import annotations import secrets import uuid from datetime import datetime, timedelta, timezone from sqlalchemy import select f...
cacao-accounting/cacao-accounting
cacao_accounting/auth/device_verification.py
.py
6c13758042d738ef
7.5
9
# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: 2025 - 2026 William José Moreno Reyes """Utilidades de autenticación.""" import re from typing import Optional from argon2 import PasswordHasher from argon2.exceptions import VerifyMismatchError from flask import current_app, redirect, session, url_for ...
cacao-accounting/cacao-accounting
cacao_accounting/auth/helpers.py
.py
9f40e89b0f56f92b
7.5
9
"""Fachada de compatibilidad para el módulo bancos.""" from __future__ import annotations from typing import Any from cacao_accounting.bancos import routes as _routes from cacao_accounting.bancos import services as _services from cacao_accounting.bancos.routes import ( # noqa: F401 bancos as bancos, ) from ca...
cacao-accounting/cacao-accounting
cacao_accounting/bancos/__init__.py
.py
742d902e3e11a104
7.5
9
# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: 2025 - 2026 William José Moreno Reyes """Servicio de cálculo y negocio para el Pronóstico de Flujo de Caja.""" import calendar from datetime import date, timedelta from decimal import Decimal from sqlalchemy import func, or_ from sqlalchemy.exc import Op...
cacao-accounting/cacao-accounting
cacao_accounting/bancos/cash_forecast_service.py
.py
394873559d46a67f
7.5
9
# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: 2025 - 2026 William José Moreno Reyes """Formularios web del modulo de bancos.""" from flask_wtf import FlaskForm from wtforms import SelectField, StringField, TextAreaField from wtforms.validators import DataRequired, Optional class FormularioBanco(Fl...
cacao-accounting/cacao-accounting
cacao_accounting/bancos/forms.py
.py
faa79f6ffdb64045
7.5
9
# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: 2025 - 2026 William José Moreno Reyes """Soporte para caché de la aplicación adaptándose al modo de ejecución.""" from typing import Any from flask import Flask from cacao_accounting.runtime_mode import is_desktop_mode, is_truthy try: from flask_cach...
cacao-accounting/cacao-accounting
cacao_accounting/cache.py
.py
bba317059484b6a0
7.5
9
import datetime as dt import logging import os from tabulate import tabulate from sleuth.services import ( disable_key, get_iam_users, prepare_slack_message, prepare_sns_message, send_slack_message, send_sns_message, ) LOGGER = logging.getLogger("sleuth") class Key: username = "" ke...
trussworks/terraform-aws-iam-sleuth
sleuth/sleuth/auditor.py
.py
93deced7c831da2e
7.54
11
import datetime import pytest from freezegun import freeze_time from sleuth.auditor import Key @freeze_time("2019-01-16") class TestKey: def test_normal(self): """Normal happy path, key is good""" created = datetime.datetime(2019, 1, 1, tzinfo=datetime.timezone.utc) last_used = datetime....
trussworks/terraform-aws-iam-sleuth
sleuth/tests/test_auditor.py
.py
6d10ee67831553ec
7.04
11
import datetime from sleuth.auditor import Key, User from sleuth.services import format_slack_id, prepare_slack_message, prepare_sns_message created = datetime.datetime(2019, 1, 1, tzinfo=datetime.timezone.utc) lastused = created = datetime.datetime(2019, 1, 3, tzinfo=datetime.timezone.utc) # 4 users to represent the...
trussworks/terraform-aws-iam-sleuth
sleuth/tests/test_services.py
.py
9c1fbd1a8f3e165c
8.04
11
"""Assemble tools for the jump-start agent.""" from __future__ import annotations from pathlib import Path from agno.tools import tool from jump_start.manifest import generate_manifest_json from jump_start.scaffold import DEFAULT_OUTPUT_PARENT, REPO_ROOT, DemoSpec, scaffold_demo from jump_start.templates import list...
jbcodeforce/flink-studies
assistants/jump_start_demo/agent/jump_start_agent/tools/builder.py
.py
0f3873daa97fa26d
7.64
18
"""Wrap cc_deploy manifest generation via flink-sql tools.""" from __future__ import annotations import json import subprocess from pathlib import Path REPO_ROOT = Path(__file__).resolve().parents[4] CC_TOOLS = REPO_ROOT / "code" / "flink-sql" / "tools" def generate_manifest( sql_dir: Path, *, prefix: ...
jbcodeforce/flink-studies
assistants/jump_start_demo/tools/jump_start/manifest.py
.py
6a4bdf8ea4735c6f
7.64
18
"""Create e2e demo directory trees from a DemoSpec.""" from __future__ import annotations import re from dataclasses import dataclass, field from pathlib import Path from jump_start.templates import render_template REPO_ROOT = Path(__file__).resolve().parents[4] DEFAULT_OUTPUT_PARENT = REPO_ROOT / "e2e-demos" VALI...
jbcodeforce/flink-studies
assistants/jump_start_demo/tools/jump_start/scaffold.py
.py
ba35f5d953fdb3c3
7.64
18
"""Baseline for the `get_summary` per-catalog fan-out (`ztf_viewer/pages/viewer.py`). `get_summary` loops `for catalog, query in catalog_query_objects().items(): table = await query.find(...)`, serially awaiting each catalog's cone-search query. This harness reproduces that loop shape over **stub** catalogs -- each `f...
snad-space/ztf-viewer
plans/misc/fanout_bench.py
.py
8c631766e27f9426
7.6
15
"""Does moving figure rendering off `asyncio.to_thread` and onto the process pool stop a concurrent figure flood from starving unrelated event-loop work? `plans/misc/gil_bench.py` already showed matplotlib Agg PNG barely scales on threads (1.25x on 4) while the PGF/LaTeX PDF path scales well (3.33x, because it waits o...
snad-space/ztf-viewer
plans/misc/figure_pool_bench.py
.py
d755e00b1b445076
7.6
15
"""Cold `get_summary` wall-clock, against real upstreams -- not stubs. `plans/misc/fanout_bench.py` times the loop *shape* over sleep stubs and imports nothing from `ztf_viewer`; it cannot measure the real change. This script calls the real, unwrapped `ztf_viewer.pages.viewer.get_summary` for a real object, against th...
snad-space/ztf-viewer
plans/misc/get_summary_bench.py
.py
afbb475e396e1923
7.6
15
"""Drives a *running* instance of the app over HTTP and reports latency percentiles. Every other script in `plans/misc/` measures a loop shape or a function in-process, over stub objects or synthetic payloads -- useful for isolating one mechanism, but none of them go through uvicorn, the ASGI app, or the process/threa...
snad-space/ztf-viewer
plans/misc/load_test.py
.py
2e744ca36ce119f4
8.1
15
"""Module-level worker functions for `tests/test_procpool.py`. Kept in their own module, not inline in the test file, because spawn (macOS default) re-imports the target module by name in the child process: a function defined inside a test body cannot be pickled and shipped across that boundary. """ import os from z...
snad-space/ztf-viewer
tests/_procpool_workers.py
.py
27f134d2378f2732
8.1
15
"""Tests for AlerceQuery — covers the fix for issue #574. ALeRCE sometimes returns non-PEP-440 classifier_version values (e.g. 'beta'). The fix makes __parse_classifier_version fall back to Version('0.0.0') instead of raising packaging.version.InvalidVersion. """ import packaging.version import pytest def _parse(s)...
snad-space/ztf-viewer
tests/catalogs/conesearch/test_alerce.py
.py
eed047a870ebbf27
8.1
15
from numpy.testing import assert_allclose async def test_cone_search(): """Regression test against the real Otter server. Coordinates taken from the example in https://github.com/astro-otter/otter/issues/45#issuecomment-4092184705 (ra=185.0, dec=12.0, sep=1.0 deg → radius_arcsec=3600). The expec...
snad-space/ztf-viewer
tests/catalogs/conesearch/test_otter.py
.py
5dbc823d1da41fd3
7.1
15
import pytest from astropy.coordinates import SkyCoord from numpy.testing import assert_array_less # Coordinates of a known ZTF object with PS1 coverage _RA = 230.71268 _DEC = 41.05182 _RADIUS_DEG = 0.05 @pytest.fixture(scope="module") def stack_table(): import asyncio from ztf_viewer.catalogs.conesearch.pa...
snad-space/ztf-viewer
tests/catalogs/conesearch/test_panstarrs.py
.py
647bb085da38c1a2
8.1
15
"""Shared test configuration. The catalog tests query real services. That is deliberate — they exercise our parsing against what the services really return, which is the part worth testing — but it means a test can fail for reasons that have nothing to do with this repository: a read timeout, a dropped connection, a s...
snad-space/ztf-viewer
tests/conftest.py
.py
ee2ee2c891a793af
8.1
15
"""Unit tests for `ztf_viewer.pages.figure` and `ztf_viewer.figure_render`. `tests/test_golden_http.py`'s figure tests hit the real ZTF DR API and are network-marked, so they only assert the HTTP surface (status, mimetype, magic bytes) and skip cleanly when the network is unavailable. These tests cover what that one c...
snad-space/ztf-viewer
tests/pages/test_figure.py
.py
4a438cc43e2c4b7b
8.1
15
"""`get_csv`'s per-OID fan-out: concurrency and exception-filtering semantics. `get_csv` gathers `find_ztf_oid.get_lc`/`get_meta` and `ztf_ref.get` across every requested OID. These tests pin two things a rewrite of that fan-out could silently break: the per-OID work actually overlaps in wall time, and only `NotFound`...
snad-space/ztf-viewer
tests/pages/test_lc_csv.py
.py
91d40f40fef8ee63
7.1
15
"""The app serves its own index and its `static/` directory. Imports `ztf_viewer.app` rather than `ztf_viewer.__main__`: the latter also registers the six plain routes, which are not ported yet and fail at import time. """ from pathlib import Path import pytest from dash import html from fastapi.testclient import Te...
snad-space/ztf-viewer
tests/test_app.py
.py
3a44957595071984
8.1
15
"""Decorator-level tests for the sync ``cache()``. ``tests/test_cache_contract.py`` is the spec and covers hit/miss/TTL/value fidelity on both backends. This file covers what the spec deliberately does not: guards and escape hatches specific to this implementation rather than to any cache. """ import pytest from ztf...
snad-space/ztf-viewer
tests/test_cache_sync.py
.py
d773a93aa829095f
7.1
15
"""Unit tests for `ztf_viewer.csv_render`, the module a pool worker re-imports for `get_csv`. Split out of `ztf_viewer.pages.lc_csv` so that re-import stays cheap: `lc_csv.py` pulls in the astroquery-backed catalog clients for its own routes, which costs seconds to import, while this module only needs pandas. """ imp...
snad-space/ztf-viewer
tests/test_csv_render.py
.py
ae923f289dd46eeb
8.1
15
"""Tests for ``ztf_viewer.exceptions``. The subprocess test is the point of this file: ``CatalogUnavailable`` used to import ``ztf_viewer.catalogs.conesearch`` just to run an ``isinstance`` check, and that package constructs every query object at import, some of which reach the network. A CDS outage therefore broke th...
snad-space/ztf-viewer
tests/test_exceptions.py
.py
9e6de1dc3954c65e
8.1
15
"""Guard that ``flask`` never creeps back into the package. ``ztf_viewer`` runs entirely on FastAPI/Starlette now; ``flask`` is only a transitive dependency (via ``dash``), not something any module here should import. This is a plain passing assertion, not an ``xfail``: it holds today, and the point of the test is to ...
snad-space/ztf-viewer
tests/test_flask_import_guard.py
.py
634ba6bbf87b62b5
8.1
15
"""Tests for the shared async HTTP client and its timeout helper. No network access here: the client-identity tests only check which loop a client is bound to, and the timeout test drives ``ztf_viewer.util.async_timeout`` directly against a coroutine that never resolves, exactly the shape a hung upstream call has. """...
snad-space/ztf-viewer
tests/test_http.py
.py
04232f298aee2d89
8.1
15
"""Tests for the per-loop resource registry.""" import asyncio import gc from ztf_viewer.loop_registry import LoopRegistry def test_not_created_at_construction() -> None: """Building the registry must not call the factory.""" calls = [] LoopRegistry(lambda: calls.append(1)) assert calls == [] def ...
snad-space/ztf-viewer
tests/test_loop_registry.py
.py
711a3cd7d142c847
7.1
15
"""Coverage for the ``network`` marker implemented in ``tests/conftest.py``. That hook rewrites a test's outcome — a ``network``-marked test that fails with a transport error is reported as a skip instead of a failure — and an outcome is not observable from inside the test it belongs to: by the time the hook runs, the...
snad-space/ztf-viewer
tests/test_network_marker.py
.py
1a879259f50e2249
7.1
15
"""Tests for the process-wide CPU-bound offload pool. `run_in_process`/`_pool` exercise the real, module-level singleton -- it is never shut down here, since that would be irreversible for the rest of the session. The crash/shutdown tests build their own throwaway `_ProcessPool` instances instead, both to keep spawn c...
snad-space/ztf-viewer
tests/test_procpool.py
.py
a9b7980c3ed9f3d2
8.1
15
"""Tests for the async SNAD catalog port (``ztf_viewer/catalogs/snad/catalog.py``). No network access: the refresh goes through a fake ``httpx.AsyncClient`` built on ``httpx.MockTransport``, so these exercise the same client plumbing as production (``ztf_viewer.http.get_client``) without hitting ``snad.space``. """ i...
snad-space/ztf-viewer
tests/test_snad_catalog.py
.py
a8896fa298cde11b
7.1
15
"""Callbacks are registered directly with ``app.callback``; most are ``async def``. A handful stayed plain ``def`` on purpose: pure presentation/formatting logic with no network, disk, or cache access, so running them inline on the event loop costs less than a thread hop would. Every name below was read and confirmed ...
snad-space/ztf-viewer
tests/test_sync_callbacks.py
.py
8a48ffb9eed4d908
8.1
15
import os import unittest import time import string import json import confluent.docker_utils as utils IMAGE_NAME = 'confluentinc/cp-enterprise-control-center' CURRENT_DIR = os.path.dirname(os.path.abspath(__file__)) FIXTURES_DIR = os.path.join(CURRENT_DIR, "fixtures") KAFKA_READY = "bash -c 'cub kafka-ready {brokers...
confluentinc/control-center-images
control-center/test/test_control_center.py
.py
481fab4b05e6db89
7.15
19
import logging import os import secrets from time import time from typing import Any from cross_inertia.fastapi import InertiaDep from cross_inertia.fastapi.experimental import inertia_lifespan from fastapi import FastAPI, HTTPException, Request, Response, WebSocket from fastapi.responses import ( FileResponse, ...
patrick91/latest.cat
main.py
.py
72e4af72e34e0377
7.64
18
import io from pathlib import Path from PIL import Image, ImageDraw, ImageFont from services.og_meta import OG_IMAGE_HEIGHT, OG_IMAGE_WIDTH, SITE_NAME class OGImageGenerator: """Service for generating Open Graph images using static background + text overlay""" WIDTH = OG_IMAGE_WIDTH HEIGHT = OG_IMAGE_H...
patrick91/latest.cat
services/og_image.py
.py
52d0d51d5b6b83f7
7.64
18
"""Centralized Open Graph metadata configuration. This module ensures OG tags stay in sync between server, templates, and image generation. """ from typing import TypedDict class OGMeta(TypedDict): """Open Graph metadata structure""" title: str description: str url: str image: str # Site-wide...
patrick91/latest.cat
services/og_meta.py
.py
f32d68dc42f140b7
7.64
18
# SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD # SPDX-License-Identifier: Unlicense OR CC0-1.0 import logging import re import socket import sys import dns.message import dns.query import dns.rdataclass import dns.rdatatype import dns.resolver # Configure logging logging.basicConfig(level=log...
citelab/gini
backend/gini32/gbridge/managed_components/espressif__mdns/tests/host_test/dnsfixture.py
.py
601e19959ff436ca
8.1
15
# SPDX-FileCopyrightText: 2024-2026 Espressif Systems (Shanghai) CO LTD # SPDX-License-Identifier: Unlicense OR CC0-1.0 import logging import subprocess import sys import time from pathlib import Path import pexpect import pytest from bonjour_order_responder import DEFAULTS from dnsfixture import DnsPythonWrapper # C...
citelab/gini
backend/gini32/gbridge/managed_components/espressif__mdns/tests/host_test/pytest_mdns.py
.py
dfe88895849322a6
8.1
15
#!/usr/bin/env python3 """Console client for a running gRouter — the real CLI over its control socket. The gRouter runs as a daemon, so its interactive CLI isn't on stdin. It instead listens on a Unix socket (<confdir>/<name>.ctl); this client sends a command line and prints whatever the command produced. Use it inter...
citelab/gini
backend/grouter-build/grconsole.py
.py
69906760dd935a35
7.6
15
#!/usr/bin/env python3 """End-to-end round-trip proof for the REAL C gRouter (single router). A 10.0.1.10 <--> tun1 10.0.1.1 [ R ] 10.0.2.1 tun2 <--> B 10.0.2.10 A pings B across subnets; B (a real ICMP responder) replies; A receives the reply. We confirm BOTH directions forward with TTL decremented 64 -> 63. S...
citelab/gini
backend/grouter-build/tests/forward_test.py
.py
b0a9f126d7d15e02
7.1
15
#!/usr/bin/env python3 """Two-router multi-hop proof for the REAL C gRouter. A 10.0.1.10 -- tun1[ R1 ]tun2 10.0.2.1 <==> 10.0.2.2 tun1[ R2 ]tun2 -- B 10.0.3.10 10.0.1.0/24 10.0.2.0/24 (router-router) 10.0.3.0/24 Two genuine gRouter processes joined by a router-to-router tun link. A pings ...
citelab/gini
backend/grouter-build/tests/multihop_test.py
.py
53b7b9cd2dea12c7
8.1
15
#!/usr/bin/env python3 """The gRouter control socket exposes the real CLI to a console / the Router Lab. Launches a router, then drives its <name>.ctl Unix socket the way grconsole.py and the GUI do: each command runs through the real CLI dispatch and returns its printed output. GROUTER_BIN=/path/to/grouter python3...
citelab/gini
backend/grouter-build/tests/test_rctl.py
.py
51f7406763c16f06
8.1
15
#!/usr/bin/env python3 """Minimal OpenFlow 1.0 switch — proves a controller completes the 1.0 handshake. Mimics exactly what the gRouter's OpenFlow switch does on the wire (HELLO → FEATURES_REPLY → echo/barrier keepalive), so we can confirm POX `gar` (Python 3) accepts a 1.0 datapath and binds its app, independent of ...
citelab/gini
backend/sdn/of_hello_probe.py
.py
005e01dbb772f4f7
7.6
15
# Copyright 2017,2018 James McCauley # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at: # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in ...
citelab/gini
backend/sdn/pox/pox/config/__init__.py
.py
00888803c1e60fe3
7.6
15
# Copyright 2013 James McCauley # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at: # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writi...
citelab/gini
backend/sdn/pox/pox/datapaths/__init__.py
.py
de7dc2923e28e1e9
7.6
15
# Copyright 2013 James McCauley # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at: # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writi...
citelab/gini
backend/sdn/pox/pox/datapaths/ctl.py
.py
6c7581ca9c46818f
7.6
15
# Copyright 2017 James McCauley # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at: # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writi...
citelab/gini
backend/sdn/pox/pox/datapaths/hub.py
.py
876d280bbee952bc
7.6
15
# Copyright 2012 James McCauley # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at: # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writi...
citelab/gini
backend/sdn/pox/pox/forwarding/hub.py
.py
64abeed53dc1041c
7.6
15
# Copyright 2012 James McCauley # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at: # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writi...
citelab/gini
backend/sdn/pox/pox/forwarding/l2_flowvisor.py
.py
177d6b7c0586a5ec
7.6
15
# Copyright 2011-2012 James McCauley # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at: # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in ...
citelab/gini
backend/sdn/pox/pox/forwarding/l2_learning.py
.py
55ac1aa8cdeb0ecf
7.6
15
# Copyright 2012-2013 James McCauley # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at: # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in ...
citelab/gini
backend/sdn/pox/pox/forwarding/l2_multi.py
.py
2a4dd5620b4da61c
7.6
15
# Copyright 2012 James McCauley # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at: # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writi...
citelab/gini
backend/sdn/pox/pox/forwarding/l2_nx.py
.py
0ad658ce079cc53b
7.6
15
# Copyright 2013 James McCauley # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at: # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writi...
citelab/gini
backend/sdn/pox/pox/forwarding/l2_nx_self_learning.py
.py
d88de0f372665c24
7.6
15
# Copyright 2012 James McCauley # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at: # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writi...
citelab/gini
backend/sdn/pox/pox/forwarding/l2_pairs.py
.py
bd5e77efc8095002
7.6
15
"""Factory for Phalanx support code components.""" from pathlib import Path from .constants import GOOGLE_CLOUD_RUN_ID_LABEL from .models.vault import VaultCredentials from .services.application import ApplicationService from .services.cluster import GKEPhalanxClusterService from .services.environment import Environm...
lsst-sqre/phalanx
src/phalanx/factory.py
.py
23c2c3ce2b043652
7.66
20
"""Utility functions used when running under GitHub Actions. The utility functions in this module can all be called unconditionally. They will detect whether the Phalanx command-line tool is being run under GitHub Actions and, if so, add additional GitHub-specific markers to the output to improve display in GitHub Act...
lsst-sqre/phalanx
src/phalanx/github.py
.py
42cf53f0ad4ca2db
7.66
20
"""Pydantic models for Phalanx applications.""" from enum import Enum from typing import Any from pydantic import BaseModel, Field from .secrets import ConditionalSecretConfig, Secret __all__ = [ "Application", "ApplicationConfig", "ApplicationInstance", "DocLink", "Project", ] class DocLink(B...
lsst-sqre/phalanx
src/phalanx/models/applications.py
.py
6a284b734273878b
7.66
20
"""Pydantic models for Phalanx environments.""" from collections import defaultdict from enum import Enum from typing import Self, override from pydantic import ( AnyHttpUrl, AnyUrl, BaseModel, ConfigDict, Field, GetJsonSchemaHandler, field_validator, ) from pydantic.alias_generators impor...
lsst-sqre/phalanx
src/phalanx/models/environments.py
.py
4d473d8f3a924eeb
7.66
20
"""Models representing Kubernetes resources.""" from enum import Enum from ipaddress import IPv4Address from typing import Literal from pydantic import AliasPath, BaseModel, ConfigDict, Field from ..constants import ( PREVIOUS_EXTERNAL_TRAFFIC_POLICY_ANNOTATION, PREVIOUS_LOAD_BALANCER_IP_ANNOTATION, PREV...
lsst-sqre/phalanx
src/phalanx/models/kubernetes.py
.py
5cfa2179911f7598
7.66
20
"""Service for manipulating Phalanx applications.""" import base64 import json from collections.abc import Iterable from pathlib import Path from typing import Any import jinja2 from ..exceptions import ApplicationExistsError from ..models.applications import Project from ..models.environments import Environment fro...
lsst-sqre/phalanx
src/phalanx/services/application.py
.py
e0e28ef22e980fbe
7.66
20
"""Service to coordinate other services for cluster recovery.""" from google.api_core.exceptions import NotFound from ..constants import RECOVER_IGNORE_SERVICES from ..models.vault import VaultCredentials from .cluster import GKEPhalanxClusterService from .google_cloud import GoogleCloudService from .recovery_environ...
lsst-sqre/phalanx
src/phalanx/services/gke_recovery.py
.py
7dc30e8ebadaaf1a
7.66
20
"""Operations for backing up and restoring GKE clusters.""" from google.cloud.compute_v1beta import Address, Firewall from google.cloud.container_v1 import Cluster from google.cloud.gke_backup_v1 import Backup, Restore from ..constants import ( GOOGLE_CLOUD_CERT_MANAGER_FIREWALL_RULE, GOOGLE_CLOUD_RUN_ID_LABE...
lsst-sqre/phalanx
src/phalanx/services/google_cloud.py
.py
078e2a6f30a9afec
7.66
20
"""Service for manipulating Phalanx environments during cluster recovery. This is very similar to installing an environment for the first time, but there are differences in the order that specific resources and namespaces must be installed. """ from datetime import timedelta from phalanx.services.cluster import GKEP...
lsst-sqre/phalanx
src/phalanx/services/recovery_environment.py
.py
9d1c015e4f7c8127
7.66
20
"""Service to manage Vault authentication.""" import json from contextlib import suppress from datetime import UTC, datetime, timedelta from pathlib import Path import jinja2 from hvac.exceptions import Forbidden from safir.datetime import format_datetime_for_logging from ..constants import VAULT_WRITE_TOKEN_WARNING...
lsst-sqre/phalanx
src/phalanx/services/vault.py
.py
e6c0f9dbb013541c
7.66
20
"""Wrapper around executing external commands.""" import subprocess from datetime import timedelta from pathlib import Path from ..exceptions import CommandFailedError, CommandTimedOutError __all__ = ["Command"] class Command: """Wrapper around executing external commands. This class provides some generic...
lsst-sqre/phalanx
src/phalanx/storage/command.py
.py
d2517477780a69df
7.66
20
"""Retrieve secrets stored in 1Password via 1Password Connect.""" import os from collections import defaultdict from onepasswordconnectsdk import new_client from onepasswordconnectsdk.client import FailedToRetrieveItemException from pydantic import SecretStr from ..exceptions import ( MissingOnepasswordSecretsEr...
lsst-sqre/phalanx
src/phalanx/storage/onepassword.py
.py
2dc52256440b50f1
7.66
20
"""Store, retrieve, and manipulate data stored in Vault.""" from contextlib import suppress from datetime import timedelta import hvac from hvac.exceptions import Forbidden, InvalidPath from pydantic import SecretStr from ..exceptions import VaultNotFoundError from ..models.environments import EnvironmentBaseConfig ...
lsst-sqre/phalanx
src/phalanx/storage/vault.py
.py
54acb0919cccce0d
7.66
20
"""Utility functions for manipulating YAML. In several places in the Phalanx code, we want to be able to wrap long strings to make them more readable or be able to dump `collections.defaultdict` objects without adding special object tagging. This module collects utility functions to make this easier. """ from collect...
lsst-sqre/phalanx
src/phalanx/yaml.py
.py
29d67761681dbbe1
7.66
20
"""Tests for the application command-line subcommand.""" import shutil import subprocess from pathlib import Path import pytest import yaml from git.repo import Repo from git.util import Actor from phalanx.factory import Factory from phalanx.models.applications import Project from ..support.cli import run_cli from ...
lsst-sqre/phalanx
tests/cli/application_test.py
.py
89166d699029ac53
7.16
20
"""Tests for recover restore.""" from pathlib import Path from pytest_mock.plugin import MockerFixture from ..support.cli import run_cli from ..support.data import PhalanxData from ..support.recover import MockRecover ENVIRONMENT_NAME = "idfdev" COMMAND = ( "recover", "restore", "--vault-role-id", "...
lsst-sqre/phalanx
tests/cli/recover_restore_test.py
.py
4452b6baf7740da9
7.16
20
# Copyright 2021 Red Hat # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software...
app-sre/sretoolbox
sretoolbox/binaries/base.py
.py
1dbf71edbcdd0bb6
7.56
12
# Copyright 2021 Red Hat # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software...
app-sre/sretoolbox
sretoolbox/binaries/kubectl_package.py
.py
4561747a3fae6304
7.56
12
# Copyright 2021 Red Hat # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software...
app-sre/sretoolbox
sretoolbox/binaries/mtcli.py
.py
c29d767bfcf865b7
7.56
12
# Copyright 2021 Red Hat # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software...
app-sre/sretoolbox
sretoolbox/binaries/oc.py
.py
2bb5d03360091ab1
7.56
12
# Copyright 2021 Red Hat # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software...
app-sre/sretoolbox
sretoolbox/binaries/operator_sdk.py
.py
f4de4a0f237f6179
7.56
12
# Copyright 2021 Red Hat # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software...
app-sre/sretoolbox
sretoolbox/binaries/opm.py
.py
c4b1aa79dd7f04fb
7.56
12
# Copyright 2021 Red Hat # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software...
app-sre/sretoolbox
sretoolbox/container/skopeo.py
.py
1457996bc66d8dde
7.56
12
# Copyright 2021 Red Hat # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software...
app-sre/sretoolbox
sretoolbox/utils/concurrent.py
.py
d42fe76080e17eab
7.56
12
# Copyright 2021 Red Hat # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software...
app-sre/sretoolbox
sretoolbox/utils/datatransformation.py
.py
440c20c51784b1bd
7.56
12
# Copyright 2021 Red Hat # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software...
app-sre/sretoolbox
sretoolbox/utils/logger.py
.py
58e82c18a1fca957
7.56
12
# Copyright (c) 2013, SaltyCrane # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the fo...
app-sre/sretoolbox
sretoolbox/utils/retry.py
.py
3db89dc7452d93ff
7.56
12
# Copyright 2021 Red Hat # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software...
app-sre/sretoolbox
sretoolbox/utils/threaded.py
.py
ac5330de385d4d84
7.56
12
# Copyright 2021 Red Hat # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software...
app-sre/sretoolbox
tests/test_datatransformation.py
.py
3ee459554b61b901
8.06
12
# Copyright 2021 Red Hat # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software...
app-sre/sretoolbox
tests/test_logger.py
.py
fe3848b27ddf895c
7.06
12
from __future__ import annotations import re import pytest from sretoolbox.utils.k8s import unique_job_name @pytest.mark.parametrize( "name,suffix,expected_pattern", [ # Basic usage with defaults ("myjob", "", r"^myjob-[a-f0-9]{8}$"), # With custom suffix ("myjob", "custom",...
app-sre/sretoolbox
tests/test_utils_k8s.py
.py
4cce85602058a483
8.06
12
# Copyright 2021 Red Hat # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software...
app-sre/sretoolbox
tests/test_utils_threaded.py
.py
4355ed494b81359a
7.06
12
#!/usr/bin/env python """ Curl like tool in python """ import argparse import sys import requests def send_get_request(url, headers=None): """ this function does most of the heavy lifting """ try: response = requests.get(url, headers=headers, timeout=5) response.raise_for_status() ...
veltzer/demos-orc-docker
compose/exercises/health_check/first/curl.py
.py
2d3bbb26127b147a
7.5
9
#!/usr/bin/env python3 """ Web server app """ import os.path import flask from flask import request # UPLOAD_FOLDER = "/home/mark/upload_data" UPLOAD_FOLDER = "/data" UPLOAD_HTML = """ <html> <body> <title>Upload new File</title> <h1>Upload new File</h1> <form method="post" enctype="mul...
veltzer/demos-orc-docker
exercises/from_flask_to_docker_to_minikube/app.py
.py
7572c7d8f93e8ac8
7.5
9
#!/usr/bin/env python3 """ Web server that can add two numbers """ import sys import flask import requests FORM = """ <html><body> <form action="/add" method="get"> <label for="a">A:</label> <input type="text" id="a" name="a"></input><br><br> <label for="b">B:</label> <input type="text" id="b" name="b"></input><br...
veltzer/demos-orc-docker
exercises/micro_services_one_uses_another/app_a.py
.py
56d734fc089cee0f
7.5
9
""" Copyright BOOSTRY Co., Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distr...
BoostryJP/ibet-Wallet-API
app/api/routers/admin.py
.py
272ee7d54629c223
7.5
9
""" Copyright BOOSTRY Co., Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distr...
BoostryJP/ibet-Wallet-API
app/contracts/contract.py
.py
63bc85c9cd91987b
7.5
9
""" Copyright BOOSTRY Co., Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distr...
BoostryJP/ibet-Wallet-API
app/database/__init__.py
.py
474b0668f0899597
7.5
9
""" Copyright BOOSTRY Co., Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distr...
BoostryJP/ibet-Wallet-API
app/middleware/cache_control.py
.py
45290f0a3953fc7c
7.5
9
""" Copyright BOOSTRY Co., Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distr...
BoostryJP/ibet-Wallet-API
app/middleware/response_logger.py
.py
fc888be9940abc33
7.5
9
""" Copyright BOOSTRY Co., Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distr...
BoostryJP/ibet-Wallet-API
app/middleware/strip_trailing_slash.py
.py
a42a3e93342356bf
7.5
9
""" Copyright BOOSTRY Co., Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distr...
BoostryJP/ibet-Wallet-API
app/model/db/base.py
.py
c646c144dc2da833
7.5
9