This repository has been archived on 2026-05-20. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
quetz/create_proxy_channel.py
T
ebner f260f463d8
Build and Publish Docker Image / docker (push) Successful in 56s
add additional mirrors
2026-03-24 13:18:18 +01:00

34 lines
1.2 KiB
Python

from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from quetz.db_models import Channel, Base
from quetz.config import Config
channels = {
"conda-forge": "https://conda.anaconda.org/conda-forge",
"paulscherrerinstitute": "https://anaconda.org/paulscherrerinstitute",
"slsdetectorgroup": "https://anaconda.org/slsdetectorgroup",
}
# Load your quetz config (picks up database.url from config.toml)
config = Config("/data/config.toml")
engine = create_engine(config.sqlalchemy_database_url)
SessionLocal = sessionmaker(bind=engine)
with SessionLocal() as db:
for channel_name, channel_url in channels.items():
existing = db.query(Channel).filter(Channel.name == channel_name).first()
if not existing:
channel = Channel(
name=channel_name,
description=f"Proxy of {channel_name}",
private=False,
mirror_channel_url=channel_url,
mirror_mode="proxy",
)
db.add(channel)
db.commit()
print(f"Channel created: {channel.name}")
else:
print(f"Skipping channel creation - channel already exists: {channel_name}")