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 |
|---|---|---|---|---|---|---|
#!/usr/bin/env python3
# Copyright 2023 Canonical Ltd.
# See LICENSE file for licensing details.
"""Handler for TLS/mTLS events."""
import base64
import copy
import json
import logging
import re
from typing import TYPE_CHECKING
from charms.certificate_transfer_interface.v1.certificate_transfer import (
Certifica... | canonical/kafka-k8s-operator | src/events/tls.py | .py | 942740dad185bd63 | 7.48 | 8 |
#!/usr/bin/env python3
# Copyright 2023 Canonical Ltd.
# See LICENSE file for licensing details.
"""Manager for handling Kafka machine health."""
import json
import logging
import subprocess
from statistics import mean
from typing import TYPE_CHECKING
from ops.framework import Object
from literals import JVM_MEM_MA... | canonical/kafka-k8s-operator | src/health.py | .py | 86d52156efdca9a2 | 7.48 | 8 |
#!/usr/bin/env python3
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.
"""Manager for handling Balancer."""
import json
import logging
import re
import time
from subprocess import CalledProcessError
from typing import TYPE_CHECKING, Any, cast
import requests
from ops.pebble import ExecError... | canonical/kafka-k8s-operator | src/managers/balancer.py | .py | 7ba390357c5f7846 | 7.48 | 8 |
#!/usr/bin/env python3
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.
"""Manager for handling KRaft Controller."""
import logging
import os
from subprocess import CalledProcessError
from ops.pebble import ExecError
from tenacity import retry, stop_after_attempt, wait_fixed
from core.clust... | canonical/kafka-k8s-operator | src/managers/controller.py | .py | d0a840cb64934c1e | 7.48 | 8 |
#!/usr/bin/env python3
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.
"""Manager for handling Kafka Kubernetes resources for a single Kafka pod."""
import json
import logging
import math
import time
from functools import cache
from lightkube.core.client import Client
from lightkube.core.ex... | canonical/kafka-k8s-operator | src/managers/k8s.py | .py | 68b82d62a56f9849 | 7.48 | 8 |
#!/usr/bin/env python3
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.
"""KafkaSnap class and methods."""
import csv
import datetime
import logging
import re
from io import StringIO
from charmlibs import pathops
from ops import Container, pebble
from ops.pebble import ExecError
from tenacit... | canonical/kafka-k8s-operator | src/workload.py | .py | fdef37f8be078274 | 7.48 | 8 |
#!/usr/bin/env python3
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.
import base64
import logging
import os
import re
import secrets
import string
logger = logging.getLogger(__name__)
def safe_get_file(filepath: str) -> list[str] | None:
"""Load file contents from charm workload.
... | canonical/kafka-k8s-operator | tests/integration/app-charm/src/utils.py | .py | 3ed89d471351f93d | 7.98 | 8 |
"""
Script to extract mTLS certificates from REWE APK.
Extracts PKCS#12, PEM or keystore assets and outputs certs/client.pem and certs/client.key.
"""
import os
import sys
import zipfile
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.serialization import pkcs12
# PKCS12 ... | FaserF/ha-rewe | .github/scripts/extract_rewe_certs.py | .py | 3111bddecc9586b5 | 7.62 | 16 |
"""REWE Discounts – Home Assistant Custom Component."""
from __future__ import annotations
import logging
import math
from pathlib import Path
from typing import Any
from homeassistant import config_entries, core
from homeassistant.const import EVENT_HOMEASSISTANT_STARTED
from homeassistant.exceptions import ConfigE... | FaserF/ha-rewe | custom_components/rewe/__init__.py | .py | 43ab619dacf46251 | 7.62 | 16 |
"""Pure Python client for REWE Mobile API using curl_cffi and mTLS."""
from __future__ import annotations
import logging
from typing import Any
from curl_cffi import requests
_LOGGER = logging.getLogger(__name__)
class ReweAPIClient:
"""API client that interacts directly with REWE mobile endpoints using mTLS.... | FaserF/ha-rewe | custom_components/rewe/api.py | .py | 4a73cd19b77ecff6 | 7.62 | 16 |
"""REWE Discounts button platform."""
from __future__ import annotations
import logging
from typing import Any
from homeassistant import config_entries
from homeassistant.components.button import ButtonEntity
from homeassistant.core import HomeAssistant
from homeassistant.helpers.device_registry import DeviceInfo
f... | FaserF/ha-rewe | custom_components/rewe/button.py | .py | 6e4f5cbf52291c2e | 7.62 | 16 |
"""Config flow for REWE Discounts integration."""
from __future__ import annotations
import logging
from pathlib import Path
from typing import Any
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.core import callback
from homeassistant.helpers.selector import (
NumberSelector... | FaserF/ha-rewe | custom_components/rewe/config_flow.py | .py | 1439e33809418c6d | 7.62 | 16 |
"""REWE Discounts image platform for Loyalty Card QR code."""
from __future__ import annotations
import hashlib
import io
import logging
from typing import Any
from homeassistant import config_entries
from homeassistant.components.image import ImageEntity
from homeassistant.const import ATTR_ATTRIBUTION
from homeass... | FaserF/ha-rewe | custom_components/rewe/image.py | .py | 7ef939bc45f63b52 | 7.62 | 16 |
"""Test the REWE Discounts button platform."""
from unittest.mock import AsyncMock, MagicMock
from homeassistant.core import HomeAssistant
from pytest_homeassistant_custom_component.common import MockConfigEntry
from custom_components.rewe.button import ReweForceUpdateButton, async_setup_entry
from custom_components... | FaserF/ha-rewe | tests/test_button.py | .py | 95d2f450012276d9 | 7.12 | 16 |
"""Test the certificate extraction script."""
import datetime
import io
import os
import sys
import zipfile
from pathlib import Path
from cryptography import x509
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric import rsa
from cryptography.hazmat.primitives.seri... | FaserF/ha-rewe | tests/test_extract_certs.py | .py | 23a1d8ac16131e57 | 8.12 | 16 |
"""Torch datasets over outfit tuples.
Datasets hold positive and negative tuples; *generators* control how the
tuples are (re)created at the beginning of every epoch via :meth:`next`.
- :class:`PairwiseOutfit`: one positive + one negative outfit per sample
(used for training with the pairwise ranking loss).
- :clas... | lzcn/lpae-net | datasets/dataset.py | .py | 20d9841acc8946d4 | 7.62 | 16 |
"""Datum: binds an item-id -> item-key mapping to a data reader."""
import json
import os
from typing import List, Optional
import torch
from datasets.reader import DataReader, get_reader
def load_json(fn: str) -> List[List[str]]:
"""Load ``items.json``: a list of lists of item keys, one list per category."""
... | lzcn/lpae-net | datasets/datum.py | .py | ab012b79b906fe30 | 7.62 | 16 |
"""Generators that produce positive / negative outfit tuples for each epoch."""
import logging
from typing import Dict, Optional, Type
import numpy as np
from datasets import utils
_generator_registry: Dict[str, Type["Generator"]] = {}
class Generator:
"""Base class of tuple generators.
Subclasses are re... | lzcn/lpae-net | datasets/generator.py | .py | db2190257a32c157 | 7.62 | 16 |
"""Ranking metrics computed over per-user score/label collections."""
from collections import defaultdict
from typing import Callable, Dict, List
import numpy as np
import sklearn.metrics
def to_canonical(posi, nega):
"""Convert (positive scores, negative scores) to (y_true, y_score)."""
posi, nega = np.asa... | lzcn/lpae-net | datasets/metrics.py | .py | 945d1c90f27c077a | 7.62 | 16 |
"""Readers that map an item key to its data (e.g. pre-extracted features)."""
import io
import logging
import os
import pickle
from abc import ABC, abstractmethod
from typing import Any, Callable, Optional
import lmdb
import numpy as np
import PIL.Image
import torch
logger = logging.getLogger(__name__)
class DataR... | lzcn/lpae-net | datasets/reader.py | .py | 4c08f07bac0b6a72 | 7.62 | 16 |
"""Outfit tuple utilities.
Tuple format (headerless CSV):
[user_id, size, item_1, ..., item_K, type_1, ..., type_K]
- user_id : int, user index
- size : int, number of valid items (<= K)
- item : int, index into ``items.json`` (padded with -1)
- type : int, category index (padded with -1)... | lzcn/lpae-net | datasets/utils.py | .py | 8f68f579919e2074 | 7.62 | 16 |
#!/usr/bin/env python
"""Train and evaluate LPAE-Net (CVPR 2021) on outfit recommendation datasets.
Datasets are downloaded from Hugging Face into ``data/`` -- see README.md.
Examples::
# Train LPAE-u on Polyvore-630
python main.py train \
--cfg configs/polyvore_630_lpae_u_resnet34_nn.yaml \
... | lzcn/lpae-net | main.py | .py | 5baf885fb692abb8 | 7.62 | 16 |
"""Torchvision CNN backbones with the classification head removed."""
from typing import Tuple
import torch.nn as nn
def build_backbone(name: str, pretrained: bool = True) -> Tuple[nn.Module, int]:
"""Return ``(backbone, num_features)`` for a torchvision model.
The final classification layer is replaced by... | lzcn/lpae-net | models/backbones.py | .py | 5153fa60e4a3fc2c | 7.62 | 16 |
"""LPAE-Net: Learnable Prototype Anchor Embedding Network (CVPR 2021).
Two model variants are provided:
- :class:`LPAENet`: user-specific learnable anchor prototypes in a memory
module (``lpae_u``) optionally combined with shared anchors (``lpae_g``).
- :class:`LatentFactorNet`: user embeddings matched to outfit em... | lzcn/lpae-net | models/lpae_net.py | .py | 2d7d212200175e93 | 7.62 | 16 |
"""Training bookkeeping: scalar meters and best-checkpoint management."""
from collections import defaultdict, deque
from pathlib import Path
import torch
class AverageMeters:
"""Windowed moving average over named scalars."""
def __init__(self, win_size: int = 50):
self._values = defaultdict(lambda... | lzcn/lpae-net | runner/checkpoint.py | .py | aa8c74f35c9f1351 | 7.62 | 16 |
"""Builders that turn the ``data`` section of a config into readers and loaders.
Split layout expected under ``data.root``::
{phase}_pos positive tuples (required)
{phase}_neg fixed negative tuples (used when neg_ratio <= 0)
{phase}_pos_fitb FITB questions, one correct outfit per line
... | lzcn/lpae-net | runner/data.py | .py | 25cc3a0fc969698a | 7.62 | 16 |
"""Evaluation loops: AUC / NDCG ranking metrics and the FITB task."""
import numpy as np
import torch
from tqdm import tqdm
from datasets import metrics as M
from datasets.metrics import UserBundleMetric
from runner.data import build_datum, build_loader
from runner.utils import get_logger
LOGGER = get_logger("main")... | lzcn/lpae-net | runner/evaluator.py | .py | 4eb058f059a681ac | 7.62 | 16 |
"""Model construction, checkpoint loading and optimizer setup."""
import torch
from models import LPAENet, LPAENetParam, LatentFactorNet, LatentFactorNetParam
from runner.utils import get_logger
LOGGER = get_logger("main")
def build_net(cfg, device) -> torch.nn.Module:
"""Instantiate the network from the ``net... | lzcn/lpae-net | runner/model.py | .py | 37acfc83a20ac3f2 | 7.62 | 16 |
"""Compatibility training loop (pairwise ranking objective)."""
import time
from pathlib import Path
import torch
from runner.checkpoint import AverageMeters, CheckpointSaver
from runner.data import build_datum, build_loader
from runner.model import build_net, build_optimizer
from runner.utils import get_logger
LOG... | lzcn/lpae-net | runner/trainer.py | .py | 46dcf13b44553dcd | 7.62 | 16 |
"""Runtime utilities: logging, random seeding, device selection and YAML I/O."""
import logging
import os
import random
import sys
from pathlib import Path
import numpy as np
import torch
import yaml
def get_logger(name: str = "main") -> logging.Logger:
return logging.getLogger(name)
def setup_logging(log_dir... | lzcn/lpae-net | runner/utils.py | .py | 181ba12da64a2bf4 | 7.62 | 16 |
#!/srv/venv/bin/python3
"""
home.py - The zlma home page
"""
import sys
sys.path.append('/srv/www/zlma')
from zlma_buttons import Zlma_buttons
class Zlma_home:
def __init__(self):
"""
Initialize globals, create page header, set background
"""
self.title = "zlma home page"
print('Content-Type: te... | openmainframeproject/zvm-community-tools | zlma/srv/www/zlma/home.py | .py | 43b2d9d2b8b3df6a | 7.54 | 11 |
#!/srv/venv/bin/python3
#
# zlmabuttons.py - action buttons common to all zlma pages:
# 'commands', 'consoles', 'finder', 'vif', 'help'
#
class Zlma_buttons:
def __init__(self, page: str):
"""
draw buttons common to zlma pages in a table
"""
self.green="style=\"background-color:#8CFF66\... | openmainframeproject/zvm-community-tools | zlma/srv/www/zlma/zlma_buttons.py | .py | 00c1bb92aca02342 | 7.54 | 11 |
#!/srv/venv/bin/python3
"""
consolez.py - draw one Web page for console management
Python conversion of consolez bash script
"""
import os
import sys
import subprocess
from pathlib import Path
sys.path.append('/srv/www/zlma')
from zlma_buttons import Zlma_buttons
# Add necessary paths
sys.path.insert(0, '/usr/local/... | openmainframeproject/zvm-community-tools | zlma/srv/www/zlmarw/consolez.py | .py | 44c36b6a6498bcb7 | 7.54 | 11 |
#!/srv/venv/bin/python3
"""
consuifuncs.py - functions common to consolez Web UI interface
Python conversion of consuifuncs bash script
"""
import os
import sys
import urllib.parse
from pathlib import Path
# Add the sbin directory to path to import consfuncs
sys.path.insert(0, '/usr/local/sbin')
try:
from consfu... | openmainframeproject/zvm-community-tools | zlma/srv/www/zlmarw/consuifuncs.py | .py | 51820109c090c1eb | 7.54 | 11 |
#!/srv/venv/bin/python3
"""
cpcmds.py - For admins run any CP command specified
Python conversion of cpcmds bash script
"""
import os
import sys
import subprocess
import urllib.parse
from pathlib import Path
sys.path.append('/srv/www/zlma')
from zlma_buttons import Zlma_buttons
# Add necessary paths
sys.path.insert(... | openmainframeproject/zvm-community-tools | zlma/srv/www/zlmarw/cpcmds.py | .py | 098dec21240ed97f | 7.54 | 11 |
#!/srv/venv/bin/python3
"""
onecons.py - show console data for one user ID
Python conversion of onecons bash script
Sample URL: zlnx1.example.com/zlmarw/onecons?TCPIP&LPAR1
"""
import os
import sys
import subprocess
import urllib.parse
from pathlib import Path
# Add necessary paths
sys.path.insert(0, '/usr/local/sbi... | openmainframeproject/zvm-community-tools | zlma/srv/www/zlmarw/onecons.py | .py | e7c126365eeafb74 | 7.54 | 11 |
#!/srv/venv/bin/python3
"""
onelpar.py - draw a Web page showing user IDs that have saved console data and
for admins user IDs that are logged on but don't have any saved data
"""
import os
import sys
import subprocess
import urllib.parse
from pathlib import Path
# Add necessary paths
sys.path.insert(0, ... | openmainframeproject/zvm-community-tools | zlma/srv/www/zlmarw/onelpar.py | .py | ef549ecffd07c003 | 7.54 | 11 |
#!/srv/venv/bin/python3
"""
searchcons.py - Draw a page that enables the searching of saved console data
on the Linux side
Python conversion of searchcons bash script
"""
import os
import sys
import subprocess
import urllib.parse
from pathlib import Path
# Add necessary paths
sys.path.insert(0, '/usr... | openmainframeproject/zvm-community-tools | zlma/srv/www/zlmarw/searchcons.py | .py | 9eedc17dfcd8bbf4 | 7.54 | 11 |
#!/srv/venv/bin/python3
#import html
import os
import subprocess
import sys
from urllib.parse import parse_qs
sys.path.append('/srv/www/zlma')
from zlma_buttons import Zlma_buttons
class Vif_cmd:
def __init__(self):
"""
Initialize globals, create page header, set background
"""
self.base_title = "zlm... | openmainframeproject/zvm-community-tools | zlma/srv/www/zlmarw/vifcmd.py | .py | 7fbd76255d16c613 | 7.54 | 11 |
#!/srv/venv/bin/python3
"""
vifdisk.py: perform 'vif disk' commands
'sub_cmd' passed with QUERY_STRING can be 'copy', 'create', 'delete' or 'share'
"""
import os
import subprocess
import sys
from urllib.parse import parse_qs
sys.path.append('/srv/www/zlma')
from zlma_buttons import Zlma_buttons
class Vif_disk:
def ... | openmainframeproject/zvm-community-tools | zlma/srv/www/zlmarw/vifdisk.py | .py | a163d9e1677700c0 | 7.54 | 11 |
#!/srv/venv/bin/python3
import urllib.parse
import subprocess
import sys
sys.path.append('/srv/www/zlma')
from zlma_buttons import Zlma_buttons
class Vif_hyp_disk:
def __init__(self):
"""
get arguments to call the 'vif hypervisor disk' command
"""
self.title = "zlma vif hypervisor disk"
print('C... | openmainframeproject/zvm-community-tools | zlma/srv/www/zlmarw/vifhypdisk.py | .py | 1f630bed8d331113 | 7.54 | 11 |
#!/srv/venv/bin/python3
"""
vifimgcreate.py - create a new Linux VM or golden image
"""
#import urllib.parse
import os
import subprocess
import sys
from urllib.parse import parse_qs
sys.path.append('/srv/www/zlma')
from zlma_buttons import Zlma_buttons
sys.path.append('/usr/local/sbin')
from zlma_conf import Zlma_conf
... | openmainframeproject/zvm-community-tools | zlma/srv/www/zlmarw/vifimgcreate.py | .py | 7af454f8260b43bf | 7.54 | 11 |
#!/usr/bin/env python3
#import warnings
#warnings.filterwarnings("ignore", category=DeprecationWarning)
import cgi
import html
import subprocess
import sys
sys.path.append('/srv/www/zlma')
from zlma_buttons import Zlma_buttons
class VifVmCreate:
def __init__(self):
self.title = "zlma vif - Create VM"
... | openmainframeproject/zvm-community-tools | zlma/srv/www/zlmarw/vifvmcreate.py | .py | 502809337b35c1b8 | 7.54 | 11 |
#!/srv/venv/bin/python3
"""
vifvmpower.py - VM power operations (start, stop, stopall)
"""
import cgi
import subprocess
import sys
import html
sys.path.append('/srv/www/zlma')
from zlma_buttons import Zlma_buttons
sys.path.append('/usr/local/sbin')
from zlma_conf import Zlma_conf
class Vif_vm_power:
def __init__(sel... | openmainframeproject/zvm-community-tools | zlma/srv/www/zlmarw/vifvmpower_old.py | .py | 004a76b0b7d4416e | 7.54 | 11 |
#!/srv/venv/bin/python3
"""
vifvmset.py - set VM properties (delete, set, network)
"""
import cgi
import subprocess
import sys
sys.path.append('/srv/www/zlma')
from zlma_buttons import Zlma_buttons
sys.path.append('/usr/local/sbin')
from zlma_conf import Zlma_conf
class Vif_vm_set:
def __init__(self):
"""
ge... | openmainframeproject/zvm-community-tools | zlma/srv/www/zlmarw/vifvmset.py | .py | 606e9f84b95c8a11 | 7.54 | 11 |
#
# zlma_conf - load the zlma configuration file
#
import json
import os
class Zlma_conf:
def __init__(self):
self.db_user = "root" # default database user
self.db_pw = "pi" # default database password
self.db_host = "127.0.0.1" # default database host... | openmainframeproject/zvm-community-tools | zlma/usr/local/sbin/zlma_conf.py | .py | 3740d952b3e47c24 | 7.54 | 11 |
#
# zlma_srvrs - get s390x server data from "zlma webdata"
#
import logging
import os
import sys
import requests
import subprocess
sys.path.append('/usr/local/sbin')
from zlma_conf import Zlma_conf # to read /etc/zlma.conf
class Zlma_srvrs:
def __init__(self):
self.conf = Zlma_conf() #... | openmainframeproject/zvm-community-tools | zlma/usr/local/sbin/zlma_srvrs.py | .py | e4a07f7c52b54330 | 7.54 | 11 |
#
# zlma_conf - load the zlma configuration file
#
import json
import os
class Zlma_conf:
def __init__(self):
self.db_user = "root" # default database user
self.db_pw = "pi" # default database password
self.db_host = "127.0.0.1" # default database host... | openmainframeproject/zvm-community-tools | zlma/zlma_conf/__init__.py | .py | 7de3eccc90c44cd7 | 7.54 | 11 |
import datetime
import json
import os
import time
import pandas as pd
import requests
import streamlit as st
from dotenv import load_dotenv
from requests.exceptions import ConnectionError as rConnectionError
from requests.exceptions import ConnectTimeout, ReadTimeout
from streamlit.logger import get_logger
from .mode... | AndreWohnsland/CocktailBerry-Stats | frontend/data.py | .py | 6c4653883c11f71f | 7.48 | 8 |
import datetime
import warnings
from typing import Any
import pandas as pd
import plotly.express as px
import plotly.graph_objects as go
import streamlit as st
from .models import CocktailSchema, InstallationSchema
# ignore the frame.append deprecation warning cause by plotly
warnings.filterwarnings("ignore")
_TREEM... | AndreWohnsland/CocktailBerry-Stats | frontend/plots.py | .py | c57c74b3f1de1900 | 7.48 | 8 |
import streamlit as st
def api_guidelines() -> None:
"""Show the needed information to get the API key for CocktailBerry."""
st.header("❓ How to participate")
st.markdown(
"""
The tl;dr is you need to build your own [CocktailBerry](https://github.com/AndreWohnsland/CocktailBerry)
m... | AndreWohnsland/CocktailBerry-Stats | frontend/views/api.py | .py | 0aeae6b53ce88455 | 7.48 | 8 |
import pandas as pd
import streamlit as st
from .. import data, plots
from ..models import CocktailSchema
LANGUAGE_SPLIT_DESC = "Split by Language Used"
def display_data(filtered_df: pd.DataFrame, recipes_limit: int, last_day: bool) -> None:
"""Generate all the data views (plots and tables) from the data."""
... | AndreWohnsland/CocktailBerry-Stats | frontend/views/data.py | .py | 850699abc150f4fa | 7.48 | 8 |
import streamlit as st
from ..models import DataFrameStats
def display_introduction(df_stats: DataFrameStats, installations: int) -> None:
"""Display some basic information and stats about the data & project."""
st.header("🍹CocktailBerry Dashboard")
st.markdown("Dashboard for all the [CocktailBerry](htt... | AndreWohnsland/CocktailBerry-Stats | frontend/views/introduction.py | .py | 5afd593809798329 | 7.48 | 8 |
from pathlib import Path
from typing import TYPE_CHECKING, Optional
import streamlit as st
from PIL import Image
if TYPE_CHECKING:
from streamlit.delta_generator import DeltaGenerator
_BASE_PATH = Path(__file__).parents[1].absolute()
_PICTURE_FOLDER = _BASE_PATH / "assets"
_NAME_AW = "Andre Wohnsland"
def disp... | AndreWohnsland/CocktailBerry-Stats | frontend/views/machine.py | .py | 7d1a953a0ee56c03 | 7.48 | 8 |
from datetime import date, datetime
import pandas as pd
import streamlit as st
from ..models import CocktailSchema, DataFrameStats
def generate_sidebar(
df: pd.DataFrame,
) -> tuple[
list[str],
list[str],
list[str],
int,
bool,
tuple[date, date] | tuple[None, None],
DataFrameStats,
]:... | AndreWohnsland/CocktailBerry-Stats | frontend/views/sidebar.py | .py | d7d4dc26c3dfb778 | 7.48 | 8 |
# SPDX-FileCopyrightText: 2024 Tobias Kaiser <mail@tb-kaiser.de>
# SPDX-License-Identifier: Apache-2.0
from .. import TclTool
from pathlib import Path
import os
class Vivado(TclTool):
def cmdline(self):
return ["vivado",
"-mode", "tcl",
"-nojournal",
"-source", self.scr... | TobiasKaiser/notcl | notcl/apps/vivado.py | .py | e0fac2f28eacb715 | 7.64 | 18 |
# SPDX-FileCopyrightText: 2024 Tobias Kaiser <mail@tb-kaiser.de>
# SPDX-License-Identifier: Apache-2.0
from .message import RawMessage, Message
from . import msg_classes as msg
class BridgeClient:
"""This is a dummy client for testing BridgeServer.
In production, this client is implemented in Tcl."""
def ... | TobiasKaiser/notcl | notcl/bridge_client.py | .py | a42d65be1891eb7d | 7.64 | 18 |
# SPDX-FileCopyrightText: 2024 Tobias Kaiser <mail@tb-kaiser.de>
# SPDX-License-Identifier: Apache-2.0
import tempfile
from contextlib import contextmanager, closing
from pathlib import Path
from enum import Enum
import os
import errno
import fcntl
import struct
import select
import termios
from .message import RawMe... | TobiasKaiser/notcl | notcl/bridge_server.py | .py | 7e92d51a8df88ad0 | 7.64 | 18 |
# SPDX-FileCopyrightText: 2024 Tobias Kaiser <mail@tb-kaiser.de>
# SPDX-License-Identifier: Apache-2.0
import re
from base64 import b64encode, b64decode
class RawMessage(dict):
"""Keys can only contain a-z, A-Z and underscores.
RawMessages can be decoded to Messages."""
@classmethod
def from_pipe(cls,... | TobiasKaiser/notcl | notcl/message.py | .py | 765bdcd45d0285ef | 7.64 | 18 |
# SPDX-FileCopyrightText: 2024 Tobias Kaiser <mail@tb-kaiser.de>
# SPDX-License-Identifier: Apache-2.0
import re
from functools import reduce
"""
The Return value of a Tcl command or procedure is basically a string. Without
knowledge about the structure or type of the return value, it is not possible to
convert this ... | TobiasKaiser/notcl | notcl/tclobj.py | .py | 59b0be15ceb2b297 | 7.64 | 18 |
# SPDX-FileCopyrightText: 2024 Tobias Kaiser <mail@tb-kaiser.de>
# SPDX-License-Identifier: Apache-2.0
from ..bridge_server import BridgeServer
from ..bridge_client import BridgeClient
import os
import threading
from .. import msg_classes as msg
from contextlib import contextmanager
@contextmanager
def bridge_server... | TobiasKaiser/notcl | notcl/tests/test_bridge.py | .py | 6cd8de8e159c4bd9 | 7.14 | 18 |
# SPDX-FileCopyrightText: 2026 Tobias Kaiser <mail@tb-kaiser.de>
# SPDX-License-Identifier: Apache-2.0
import subprocess
from .. import TclTool, TclError
class Tclsh(TclTool):
def cmdline(self):
return ["tclsh", self.script_name()]
def test_subprocess_inside_context():
"""subprocess.check_output must... | TobiasKaiser/notcl | notcl/tests/test_concurrency.py | .py | 6b0fe60a3cf6df84 | 8.14 | 18 |
# SPDX-FileCopyrightText: 2024 Tobias Kaiser <mail@tb-kaiser.de>
# SPDX-License-Identifier: Apache-2.0
"""
Tests for Ctrl+C (SIGINT) handling.
On Ctrl+C, the terminal sends SIGINT to the whole foreground process group,
i.e. to Python and the Tcl tool alike. Each scenario below runs in a child
Python process with its ... | TobiasKaiser/notcl | notcl/tests/test_sigint.py | .py | a5d635ce11092b51 | 8.14 | 18 |
# SPDX-FileCopyrightText: 2024 Tobias Kaiser <mail@tb-kaiser.de>
# SPDX-License-Identifier: Apache-2.0
import os
import sys
import pytest
import subprocess
from pathlib import Path
from textwrap import dedent
from .. import TclTool, TclError, ChildProcessEarlyExit
class Tclsh(TclTool):
def cmdline(self):
... | TobiasKaiser/notcl | notcl/tests/test_tclsh.py | .py | c3e759d565cbd4d3 | 8.14 | 18 |
#
# Copyright 2015-2025 Joe Block <jpb@unixorn.net>
#
# 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... | unixorn/gitlike-commands | gitlike_commands/__init__.py | .py | 6decfe22eb966db7 | 7.42 | 6 |
#!/usr/bin/env python
# application commands are deprecated, do not spend time refactoring them
# Service teams are trained to use them as a replacement for cf app(s)
import time
from datetime import datetime
from datetime import timedelta
import click
from prettytable import PrettyTable
from dbt_platform_helper.do... | uktrade/platform-tools | dbt_platform_helper/commands/application.py | .py | 19e7c4e8c1ee21d1 | 7.5 | 9 |
import click
from dbt_platform_helper.domain.config import Config
from dbt_platform_helper.platform_exception import PlatformException
from dbt_platform_helper.providers.aws.sso_auth import SSOAuthProvider
from dbt_platform_helper.providers.io import ClickIOProvider
from dbt_platform_helper.utils.aws import get_aws_se... | uktrade/platform-tools | dbt_platform_helper/commands/config.py | .py | e2980681a1fb329f | 7.5 | 9 |
#!/usr/bin/env python
import click
from dbt_platform_helper.domain.copilot import Copilot
from dbt_platform_helper.domain.copilot_environment import CopilotTemplating
from dbt_platform_helper.domain.versioning import PlatformHelperVersioning
from dbt_platform_helper.providers.config import ConfigProvider
from dbt_pla... | uktrade/platform-tools | dbt_platform_helper/commands/copilot.py | .py | 2fd514baa0fadaad | 7.5 | 9 |
#!/usr/bin/env python
import click
from dbt_platform_helper.domain.pipelines import Pipelines
from dbt_platform_helper.domain.versioning import PlatformHelperVersioning
from dbt_platform_helper.providers.config import ConfigProvider
from dbt_platform_helper.providers.config_validator import ConfigValidator
from dbt_pl... | uktrade/platform-tools | dbt_platform_helper/commands/pipeline.py | .py | 0e0a5f2a762143f6 | 7.5 | 9 |
#!/usr/bin/env python
import click
from dbt_platform_helper.domain.secrets import Secrets
from dbt_platform_helper.domain.versioning import PlatformHelperVersioning
from dbt_platform_helper.platform_exception import PlatformException
from dbt_platform_helper.providers.io import ClickIOProvider
from dbt_platform_help... | uktrade/platform-tools | dbt_platform_helper/commands/secrets.py | .py | 58d13e2e472cd4f4 | 7.5 | 9 |
import click
from dbt_platform_helper.domain.service import ServiceManager
from dbt_platform_helper.platform_exception import PlatformException
from dbt_platform_helper.providers.ecs import ECS
from dbt_platform_helper.providers.io import ClickIOProvider
from dbt_platform_helper.providers.parameter_store import Parame... | uktrade/platform-tools | dbt_platform_helper/commands/service.py | .py | 735c74746e94a0e5 | 7.5 | 9 |
/*
* Copyright (c) 2024. Hopsworks AB
*
* 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 ag... | logicalclocks/hopsworks-api | java/flink/src/test/java/com/logicalclocks/hsfs/flink/engine/TestFlinkEngine.java | .java | 50474462abe78877 | 7.12 | 16 |
from tkinter import ttk
# has placeholder
class Combobox(ttk.Combobox):
"""
A custom Combobox widget with placeholder text functionality.
Parameters:
container : widget
The parent widget.
placeholder : str, optional
The placeholder text to display when no selection is made... | youssefhoummad/pdf-tools | widgets/combobox.py | .py | 85d834d0d524a857 | 7.42 | 6 |
import ctypes
from typing import Callable
GWL_WND_PROC = -4
WM_DROP_FILES = 0x233
_MAX_SESSIONS = 10
_GetWindowLong = ctypes.windll.user32.GetWindowLongPtrA
_SetWindowLong = ctypes.windll.user32.SetWindowLongPtrA
_typ = ctypes.c_uint64
_prototype = ctypes.WINFUNCTYPE(_typ, _typ, _typ, _typ, _typ)
# سجل... | youssefhoummad/pdf-tools | widgets/dnd.py | .py | 9a2e3184e8f37c7f | 7.42 | 6 |
import tkinter as tk
from tkinter import ttk
class Entry(ttk.Entry):
"""
Entry يسمح فقط بـ:
- الأرقام 0-9
- الإشارة -
- الفاصلة ,
ويرفض:
- فواصل متتابعة ,,
- شرطات متتابعة --
"""
_ALLOWED_CHARS = set("0123456789-,")
def __init__(self, master=None, place... | youssefhoummad/pdf-tools | widgets/entry.py | .py | c850d81fa923ebec | 7.42 | 6 |
from textwrap import dedent
import json
import shutil
from pathlib import Path
from collections import Counter
import logging
import argparse
import subprocess
import meshio
STLFILE = "surface_mesh.stl"
MSHFILE = "surface_mesh.msh"
GEOFILE = "surface_mesh.geo"
COARSE_FOLDER = "coarse"
ORIGINAL_FOLDER = "original"
ge... | ComputationalPhysiology/cardiac-geometries | src/cardiac_geometries/bai_atlas.py | .py | ed964b9de3c3a998 | 7.48 | 8 |
"""Module containing utility functions & constants for FIPS compliant digests."""
import os
from typing import Dict
from typing import Tuple
from bci_tester.data import OS_VERSION
#: openssl digests that are not FIPS compliant
NONFIPS_DIGESTS: Tuple[str, ...] = (
"blake2b512",
"blake2s256",
"md5",
"r... | SUSE/BCI-tests | bci_tester/fips.py | .py | 859b0426669a72df | 8.04 | 11 |
"""Module with helper utilities around SELinux."""
from pathlib import Path
try:
from typing import Literal
except ImportError:
# typing.Literal is available on python3.8+
# https://docs.python.org/3/library/typing.html#typing.Literal
from typing_extensions import Literal
def selinux_status(
_se... | SUSE/BCI-tests | bci_tester/selinux.py | .py | d8e502f4f96514ce | 7.04 | 11 |
"""This module contains general purpose utility functions."""
import os
import re
import xml.etree.ElementTree as ET
from dataclasses import dataclass
from typing import Dict
from typing import List
from typing import Optional
try:
from typing import Literal
except ImportError:
from typing_extensions import L... | SUSE/BCI-tests | bci_tester/util.py | .py | 985cf09ac5fdc322 | 8.04 | 11 |
import logging
import os
import shlex
import time
from pathlib import Path
from subprocess import check_output
from typing import Iterator
from typing import Tuple
import pytest
from _pytest.fixtures import SubRequest
from pytest_container import GitRepositoryBuild
from pytest_container import OciRuntimeBase
from pyte... | SUSE/BCI-tests | conftest.py | .py | 332d7c2b33f852fe | 8.04 | 11 |
"""Basic tests for the 389-ds Application container image."""
from typing import List
import pytest
from _pytest.mark import ParameterSet
from pytest_container.container import ContainerData
from pytest_container.container import DerivedContainer
from pytest_container.container import container_and_marks_from_pytest_... | SUSE/BCI-tests | tests/test_389ds.py | .py | 1fd86ad212af2173 | 8.04 | 11 |
"""This module contains the tests for the AMD GPU container."""
import pytest
from pytest_container.container import ContainerData
from bci_tester.data import AMD_CONTAINERS
from bci_tester.data import OS_VERSION
CONTAINER_IMAGES = AMD_CONTAINERS
@pytest.mark.parametrize(
"container_per_test",
AMD_CONTAINE... | SUSE/BCI-tests | tests/test_amd.py | .py | 110e040043923fef | 7.04 | 11 |
"""Tests for the base container itself (the one that is already present on
registry.suse.com)
"""
from pathlib import Path
from typing import Dict
import pytest
from pytest_container import DerivedContainer
from pytest_container.container import BindMount
from pytest_container.container import ContainerData
from pyt... | SUSE/BCI-tests | tests/test_base.py | .py | c8a80b3e89ca332e | 8.04 | 11 |
"""Tests for the BCI ISC Bind (DNS) container"""
from datetime import timedelta
from pathlib import Path
from typing import Dict
from typing import List
from typing import Union
import dns.query
import pytest
from dns import message
from dns import name
from dns import rdatatype
from dns import resolver
from dns.rrse... | SUSE/BCI-tests | tests/test_bind.py | .py | aff010d4568b841f | 8.04 | 11 |
"""Test module performing simple smoke tests for the busybox container image."""
from typing import Dict
import pytest
from pytest_container import MultiStageBuild
from pytest_container import get_extra_run_args
from pytest_container.helpers import get_extra_build_args
from pytest_container.runtime import LOCALHOST
... | SUSE/BCI-tests | tests/test_busybox.py | .py | 74c280dbe010dbbb | 8.04 | 11 |
"""This module contains the tests for the cosign container, the image with cosign pre-installed."""
from bci_tester.data import COSIGN_CONTAINERS
CONTAINER_IMAGES = COSIGN_CONTAINERS
def test_cosign_version(auto_container, host, container_runtime):
"""Test that we can invoke `cosign version` successfully."""
... | SUSE/BCI-tests | tests/test_cosign.py | .py | f47957577140ae95 | 8.04 | 11 |
"""Tests for the distribution container"""
import textwrap
import requests
from pytest_container import OciRuntimeBase
from bci_tester.data import DISTRIBUTION_CONTAINER
CONTAINER_IMAGES = [DISTRIBUTION_CONTAINER]
def test_registry_service(
host, auto_container_per_test, tmp_path, container_runtime: OciRuntim... | SUSE/BCI-tests | tests/test_distribution.py | .py | b635b85d9bf6ecbd | 8.04 | 11 |
"""Tests for the .Net container based on SLE with the rpms build from
Microsoft's binaries.
"""
import re
import xml.etree.ElementTree as ET
from typing import List
from typing import Tuple
import pytest
from _pytest.mark import ParameterSet
from pytest_container import GitRepositoryBuild
from pytest_container impor... | SUSE/BCI-tests | tests/test_dotnet.py | .py | 3dae93dec81db125 | 8.04 | 11 |
"""Tests for the gcc containers."""
import pytest
from pytest_container import DerivedContainer
from pytest_container import container_and_marks_from_pytest_param
from pytest_container.container import ContainerData
from bci_tester.data import GCC_CONTAINERS
CONTAINER_IMAGES = GCC_CONTAINERS
_HELLO_VERSION = "2.12.... | SUSE/BCI-tests | tests/test_gcc.py | .py | d6bfb66cea9b6fb5 | 8.04 | 11 |
"""Tests for the Go language container."""
import re
from pathlib import Path
from typing import Tuple
import pytest
from packaging import version
from pytest_container import GitRepositoryBuild
from pytest_container.container import ContainerData
from pytest_container.runtime import LOCALHOST
from bci_tester.data i... | SUSE/BCI-tests | tests/test_go.py | .py | 65a4113f3a889440 | 8.04 | 11 |
"""Tests for the Grafana containers."""
import pytest
import requests
import tenacity
from pytest_container.container import ContainerData
from bci_tester.data import GRAFANA_CONTAINERS
@pytest.mark.parametrize("container", GRAFANA_CONTAINERS, indirect=True)
def test_prometheus_healthy(container: ContainerData) -> ... | SUSE/BCI-tests | tests/test_grafana.py | .py | d287ff25456ed1c8 | 8.04 | 11 |
"""This module contains the tests for the init container, the image with
systemd pre-installed.
"""
import datetime
import json
import re
import pytest
from pytest_container import OciRuntimeBase
from pytest_container.container import ContainerData
from pytest_container.runtime import LOCALHOST
from bci_tester.data... | SUSE/BCI-tests | tests/test_init.py | .py | a4ed0b88ea49ecec | 8.04 | 11 |
"""Tests for validating the KEA DHCP Server image."""
import json
import os
import re
import pytest
from pytest_container import DerivedContainer
from pytest_container.container import ContainerLauncher
from pytest_container.runtime import OciRuntimeBase
from bci_tester.data import KEA_CONTAINERS
from bci_tester.run... | SUSE/BCI-tests | tests/test_kea.py | .py | 73f7b86b349be252 | 7.04 | 11 |
"""Tests for the SLE15 kernel-module container."""
import re
import pytest
from _pytest.mark import ParameterSet
from pytest_container import DerivedContainer
from pytest_container import GitRepositoryBuild
from pytest_container import container_and_marks_from_pytest_param
from pytest_container.container import Conta... | SUSE/BCI-tests | tests/test_kernel_module.py | .py | 1e6834de052958e0 | 8.04 | 11 |
"""Tests for the MariaDB related application container images."""
import os
from itertools import product
from pathlib import Path
from typing import Any
from typing import List
from typing import Optional
from typing import Union
import pymysql
import pytest
from _pytest.mark import ParameterSet
from pymysql.err imp... | SUSE/BCI-tests | tests/test_mariadb.py | .py | 387aa1d31b54953b | 7.04 | 11 |
"""Tests for the minimal BCI container (the container without zypper but with rpm)."""
from typing import Dict
import pytest
from pytest_container.runtime import LOCALHOST
from bci_tester.data import MICRO_CONTAINER
from bci_tester.data import MICRO_FIPS_CONTAINER
from bci_tester.data import MINIMAL_CONTAINER
from b... | SUSE/BCI-tests | tests/test_minimal.py | .py | 021b1214940ebac8 | 8.04 | 11 |
"""Integration tests via multistage container builds."""
import pytest
from _pytest.config import Config
from pytest_container import GitRepositoryBuild
from pytest_container import MultiStageBuild
from pytest_container import get_extra_build_args
from pytest_container import get_extra_run_args
from pytest_container.r... | SUSE/BCI-tests | tests/test_multistage.py | .py | fa881912d28d8d0e | 7.04 | 11 |
"""This module contains the tests for the nano container, the image with only CA and timezone pre-installed."""
from typing import Dict
import pytest
from _pytest.config import Config
from pytest_container import MultiStageBuild
from pytest_container import get_extra_build_args
from pytest_container import get_extra_... | SUSE/BCI-tests | tests/test_nano.py | .py | bc396235b7196c05 | 8.04 | 11 |
"""This module contains the tests for the nginx container, the image with nginx pre-installed."""
import requests
from tenacity import retry
from tenacity import stop_after_attempt
from tenacity import wait_exponential
from bci_tester.data import NGINX_CONTAINERS
CONTAINER_IMAGES = NGINX_CONTAINERS
def test_nginx_... | SUSE/BCI-tests | tests/test_nginx.py | .py | 4f537fa111b7ca0c | 8.04 | 11 |
"""Tests for the Node.js base container images."""
from textwrap import dedent
import pytest
from pytest_container import GitRepositoryBuild
from pytest_container.container import ContainerData
from pytest_container.runtime import LOCALHOST
from bci_tester.data import NODEJS_BASE_CONTAINERS
from bci_tester.data impo... | SUSE/BCI-tests | tests/test_node.py | .py | fcdad1e1d655ebd2 | 8.04 | 11 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.