Initial commit

This commit is contained in:
Pünkösd Marcell 2021-12-12 00:42:00 +01:00
commit 3a4a0758c8
4 changed files with 190 additions and 0 deletions

106
.gitignore vendored Normal file
View File

@ -0,0 +1,106 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# pyenv
.python-version
# celery beat schedule file
celerybeat-schedule
# SageMath parsed files
*.sage.py
# dotenv
.env
# virtualenv
.venv
venv/
ENV/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
# IDE settings
.vscode/
.idea/

34
birb_scheduler/config.py Normal file
View File

@ -0,0 +1,34 @@
import os
import sys
from dataclasses import dataclass
from typing import List
@dataclass
class SiteDescription:
name: str
baseurl: str
def parse_site_list(raw_site_list: str) -> List[SiteDescription]:
parsed_sites = []
for pair in raw_site_list.split(' '):
name, baseurl = pair.split(';', 1)
parsed_sites.append(
SiteDescription(
name=name,
baseurl=baseurl
)
)
return parsed_sites
class Config:
INTERVAL = int(os.environ.get("INTERVAL", 30))
SITE_LIST = parse_site_list(os.environ.get("SITES"))
SENTRY_DSN = os.environ.get("SENTRY_DSN")
RELEASE_ID = os.environ.get("RELEASE_ID", "test")
RELEASEMODE = os.environ.get("RELEASEMODE", "dev")
DEBUG = ('--debug' in sys.argv) or bool(os.environ.get("DEBUG", "").upper() in ['YES', 'TRUE', '1'])

45
birb_scheduler/main.py Normal file
View File

@ -0,0 +1,45 @@
#!/usr/bin/env pyton3
import logging
import sys
import sentry_sdk
from sentry_sdk.integrations.logging import LoggingIntegration
from config import Config
from apscheduler.schedulers.blocking import BlockingScheduler
def run():
logging.info("Csirip")
def main():
sentry_logging = LoggingIntegration(
level=logging.INFO,
event_level=logging.ERROR
)
if Config.SENTRY_DSN:
sentry_sdk.init(
dsn=Config.SENTRY_DSN,
integrations=[sentry_logging],
traces_sample_rate=0.0,
send_default_pii=True,
release=Config.RELEASE_ID,
environment=Config.RELEASEMODE,
_experiments={"auto_enabling_integrations": True}
)
logging.basicConfig(
stream=sys.stdout,
format="%(asctime)s - %(name)s [%(levelname)s]: %(message)s",
level=logging.DEBUG if Config.DEBUG else logging.INFO
)
scheduler = BlockingScheduler()
scheduler.add_job(run, trigger='interval', seconds=Config.INTERVAL)
scheduler.start()
if __name__ == '__main__':
main()

5
requirements.txt Normal file
View File

@ -0,0 +1,5 @@
requests~=2.26.0
redis~=4.0.2
apscheduler~=3.8.1
kubernetes~=20.13.0
sentry_sdk~=1.5.0