mirror of
https://github.com/NohamR/prometheus-qbittorrent-exporter.git
synced 2026-12-02 23:08:16 +00:00
Compare commits
106
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c873cda618 | ||
|
|
1d154dd224 | ||
|
|
9ff35e48c3 | ||
|
|
a0929f84ba | ||
|
|
06f13a44a2 | ||
|
|
cbb2b6b4b1 | ||
|
|
e924e30cf8 | ||
|
|
1a04a83c4a | ||
|
|
03e4222043 | ||
|
|
03a9ac78c6 | ||
|
|
a60f3d23a3 | ||
|
|
dcaf2a6557 | ||
|
|
6d2d7e666a | ||
|
|
86b5feddf6 | ||
|
|
4385a0a78f | ||
|
|
71416a79ea | ||
|
|
330d8ec86a | ||
|
|
daed737f73 | ||
|
|
55e37eb814 | ||
|
|
ea4bdecdcf | ||
|
|
0ac406c476 | ||
|
|
3061eb1638 | ||
|
|
e56a713355 | ||
|
|
cd3911f53e | ||
|
|
50ca1e4162 | ||
|
|
45e8381d70 | ||
|
|
2f07f00592 | ||
|
|
e8c0141365 | ||
|
|
de1d0fa7d5 | ||
|
|
31f309c942 | ||
|
|
1fc4383a95 | ||
|
|
78cee60afd | ||
|
|
f4a5266125 | ||
|
|
40f721c447 | ||
|
|
a25ce3f7a2 | ||
|
|
2f32c69f50 | ||
|
|
5773684369 | ||
|
|
70ec628045 | ||
|
|
af0902b742 | ||
|
|
1d0707674a | ||
|
|
940b5c6242 | ||
|
|
f47ebe94d0 | ||
|
|
e1ed34147c | ||
|
|
1b2cf9065b | ||
|
|
5b2ed75850 | ||
|
|
bc8676ed30 | ||
|
|
fb12d50373 | ||
|
|
bb3695ece6 | ||
|
|
a9a3e5d1e6 | ||
|
|
6c885b5fa0 | ||
|
|
039f7a7ef4 | ||
|
|
8bdaa48c48 | ||
|
|
e8dd24f731 | ||
|
|
12dcad10d5 | ||
|
|
597307c230 | ||
|
|
a25005b6a0 | ||
|
|
cfe62f8115 | ||
|
|
b5d20e3fe6 | ||
|
|
0ff6a56f18 | ||
|
|
2d968bc8e8 | ||
|
|
8ab307a630 | ||
|
|
de00864f11 | ||
|
|
03d332979b | ||
|
|
1f6e8aa380 | ||
|
|
ef00d90e2f | ||
|
|
7f783f0b0a | ||
|
|
345888ef68 | ||
|
|
0e4c4a97ea | ||
|
|
d144f412ca | ||
|
|
9002a709b7 | ||
|
|
b91bff0f0c | ||
|
|
ed44d88c5b | ||
|
|
8f0a0381d3 | ||
|
|
b3e5e69f1f | ||
|
|
ef12d46431 | ||
|
|
9a19f46b7e | ||
|
|
a53c7ae08b | ||
|
|
17ebcb0834 | ||
|
|
7016e3de2b | ||
|
|
af51fd5b67 | ||
|
|
82151b1d82 | ||
|
|
b6e3131929 | ||
|
|
688fcc54cb | ||
|
|
bc79a0dd52 | ||
|
|
af732087e8 | ||
|
|
15130f1c95 | ||
|
|
53dc38f796 | ||
|
|
3bfc3f0673 | ||
|
|
eee65ec84e | ||
|
|
b4aefff06d | ||
|
|
baf14d495c | ||
|
|
003297ecfd | ||
|
|
2497249b8c | ||
|
|
9e9f4a9ce4 | ||
|
|
40d9bb964e | ||
|
|
0b3fb04728 | ||
|
|
13a52c40f2 | ||
|
|
109924d0da | ||
|
|
b391e5f83a | ||
|
|
b924dd2bbb | ||
|
|
28f1611079 | ||
|
|
55c4b3a5a7 | ||
|
|
3f7066c6ed | ||
|
|
6007908113 | ||
|
|
fb767eba1e | ||
|
|
252b9aee6f |
No files matched your search
@@ -0,0 +1,3 @@
|
|||||||
|
[run]
|
||||||
|
relative_files = True
|
||||||
|
omit = tests/*
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
__pycache__/
|
||||||
|
.coverage*
|
||||||
|
.github
|
||||||
|
.gitignore
|
||||||
|
.pdm*
|
||||||
|
.pre-commit-config.yaml
|
||||||
|
.vscode
|
||||||
|
build/
|
||||||
|
logo.png
|
||||||
|
tests
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: "pip"
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: "weekly"
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
name: Docker
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ master ]
|
||||||
|
release:
|
||||||
|
types: [ created ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: 'Checkout GitHub Action'
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v1
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
|
||||||
|
- name: Extract branch name
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
tag=${GITHUB_REF#refs/tags/}
|
||||||
|
tag=${tag#refs/heads/}
|
||||||
|
if echo $tag | grep -q -E "[0-9]+\.[0-9]+\.[0-9]+"; then
|
||||||
|
tag="v$tag"
|
||||||
|
fi
|
||||||
|
echo "##[set-output name=tag;]$tag"
|
||||||
|
id: extract_branch
|
||||||
|
|
||||||
|
- name: Login to DockerHub
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.REGISTRY_USERNAME }}
|
||||||
|
password: ${{ secrets.REGISTRY_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Build and push docker to DockerHub
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
push: true
|
||||||
|
platforms: linux/amd64,linux/arm64,linux/386
|
||||||
|
tags: |
|
||||||
|
${{ secrets.REGISTRY_USERNAME }}/prometheus-qbittorrent-exporter:latest
|
||||||
|
${{ secrets.REGISTRY_USERNAME }}/prometheus-qbittorrent-exporter:${{ steps.extract_branch.outputs.tag }}
|
||||||
|
|
||||||
|
- name: Login to Github Container Registry
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ secrets.REGISTRY_USERNAME }}
|
||||||
|
password: ${{ secrets.GHCR_PERSONAL_TOKEN }}
|
||||||
|
|
||||||
|
- name: Build and push docker to Github Container Registry
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
push: true
|
||||||
|
platforms: linux/amd64,linux/arm64,linux/386
|
||||||
|
tags: |
|
||||||
|
ghcr.io/${{ secrets.REGISTRY_USERNAME }}/prometheus-qbittorrent-exporter:latest
|
||||||
|
ghcr.io/${{ secrets.REGISTRY_USERNAME }}/prometheus-qbittorrent-exporter:${{ steps.extract_branch.outputs.tag }}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
name: Run Unit Test via Pytest
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- "master"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
lint-and-test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
pull-requests: write
|
||||||
|
contents: write
|
||||||
|
checks: write
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
python-version: ["3.11"]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
|
uses: actions/setup-python@v4
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
|
- name: Setup PDM
|
||||||
|
uses: pdm-project/setup-pdm@v3
|
||||||
|
- name: Install dependencies
|
||||||
|
run: pdm install
|
||||||
|
- name: Lint with black
|
||||||
|
uses: psf/black@stable
|
||||||
|
with:
|
||||||
|
options: "--check --verbose"
|
||||||
|
- name: Test with pytest
|
||||||
|
run: |
|
||||||
|
pdm run pytest --junit-xml=test-results.xml
|
||||||
|
- name: Publish Test Results
|
||||||
|
uses: EnricoMi/publish-unit-test-result-action@v2
|
||||||
|
if: always()
|
||||||
|
with:
|
||||||
|
files: |
|
||||||
|
test-results.xml
|
||||||
|
- name: Test with coverage
|
||||||
|
run: |
|
||||||
|
pdm run coverage run -m pytest -v -s
|
||||||
|
- name: Generate Coverage Report
|
||||||
|
run: |
|
||||||
|
pdm run coverage report -m
|
||||||
|
- name: Coverage comment
|
||||||
|
id: coverage_comment
|
||||||
|
uses: py-cov-action/python-coverage-comment-action@v3
|
||||||
|
with:
|
||||||
|
GITHUB_TOKEN: ${{ github.token }}
|
||||||
|
- name: Store Pull Request comment to be posted
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
if: steps.coverage_comment.outputs.COMMENT_FILE_WRITTEN == 'true'
|
||||||
|
with:
|
||||||
|
name: python-coverage-comment-action
|
||||||
|
path: python-coverage-comment-action.txt
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
name: Upload Python Package
|
||||||
|
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [created]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v1
|
||||||
|
- name: Set up Python
|
||||||
|
uses: actions/setup-python@v1
|
||||||
|
with:
|
||||||
|
python-version: '3.6'
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip install setuptools wheel twine
|
||||||
|
- name: Build and publish
|
||||||
|
env:
|
||||||
|
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
|
||||||
|
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
|
||||||
|
run: |
|
||||||
|
python -m build
|
||||||
|
twine upload dist/*
|
||||||
+138
@@ -0,0 +1,138 @@
|
|||||||
|
# Byte-compiled / optimized / DLL files
|
||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
*$py.class
|
||||||
|
|
||||||
|
# C extensions
|
||||||
|
*.so
|
||||||
|
|
||||||
|
# Distribution / packaging
|
||||||
|
.Python
|
||||||
|
build/
|
||||||
|
develop-eggs/
|
||||||
|
dist/
|
||||||
|
downloads/
|
||||||
|
eggs/
|
||||||
|
.eggs/
|
||||||
|
lib/
|
||||||
|
lib64/
|
||||||
|
parts/
|
||||||
|
sdist/
|
||||||
|
var/
|
||||||
|
wheels/
|
||||||
|
pip-wheel-metadata/
|
||||||
|
share/python-wheels/
|
||||||
|
*.egg-info/
|
||||||
|
.installed.cfg
|
||||||
|
*.egg
|
||||||
|
MANIFEST
|
||||||
|
|
||||||
|
# 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/
|
||||||
|
.nox/
|
||||||
|
.coverage
|
||||||
|
.coverage.*
|
||||||
|
.cache
|
||||||
|
nosetests.xml
|
||||||
|
coverage.xml
|
||||||
|
*.cover
|
||||||
|
*.py,cover
|
||||||
|
.hypothesis/
|
||||||
|
.pytest_cache/
|
||||||
|
|
||||||
|
# Translations
|
||||||
|
*.mo
|
||||||
|
*.pot
|
||||||
|
|
||||||
|
# Django stuff:
|
||||||
|
*.log
|
||||||
|
local_settings.py
|
||||||
|
db.sqlite3
|
||||||
|
db.sqlite3-journal
|
||||||
|
|
||||||
|
# Flask stuff:
|
||||||
|
instance/
|
||||||
|
.webassets-cache
|
||||||
|
|
||||||
|
# Scrapy stuff:
|
||||||
|
.scrapy
|
||||||
|
|
||||||
|
# Sphinx documentation
|
||||||
|
docs/_build/
|
||||||
|
|
||||||
|
# PyBuilder
|
||||||
|
target/
|
||||||
|
|
||||||
|
# Jupyter Notebook
|
||||||
|
.ipynb_checkpoints
|
||||||
|
|
||||||
|
# IPython
|
||||||
|
profile_default/
|
||||||
|
ipython_config.py
|
||||||
|
|
||||||
|
# pyenv
|
||||||
|
.python-version
|
||||||
|
|
||||||
|
# pipenv
|
||||||
|
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
||||||
|
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
||||||
|
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
||||||
|
# install all needed dependencies.
|
||||||
|
#Pipfile.lock
|
||||||
|
|
||||||
|
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
|
||||||
|
__pypackages__/
|
||||||
|
|
||||||
|
# Celery stuff
|
||||||
|
celerybeat-schedule
|
||||||
|
celerybeat.pid
|
||||||
|
|
||||||
|
# SageMath parsed files
|
||||||
|
*.sage.py
|
||||||
|
|
||||||
|
# Environments
|
||||||
|
.env
|
||||||
|
.venv
|
||||||
|
env/
|
||||||
|
venv/
|
||||||
|
ENV/
|
||||||
|
env.bak/
|
||||||
|
venv.bak/
|
||||||
|
|
||||||
|
# Spyder project settings
|
||||||
|
.spyderproject
|
||||||
|
.spyproject
|
||||||
|
|
||||||
|
# Rope project settings
|
||||||
|
.ropeproject
|
||||||
|
|
||||||
|
# mkdocs documentation
|
||||||
|
/site
|
||||||
|
|
||||||
|
# mypy
|
||||||
|
.mypy_cache/
|
||||||
|
.dmypy.json
|
||||||
|
dmypy.json
|
||||||
|
|
||||||
|
# Pyre type checker
|
||||||
|
.pyre/
|
||||||
|
|
||||||
|
# Ignore config.env
|
||||||
|
config.env
|
||||||
|
|
||||||
|
# Ignore pdm local files
|
||||||
|
.pdm-python
|
||||||
|
|
||||||
|
# Ignore ruff files
|
||||||
|
.ruff_cache
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
repos:
|
||||||
|
- repo: local
|
||||||
|
hooks:
|
||||||
|
- id: black
|
||||||
|
name: black
|
||||||
|
stages: [commit]
|
||||||
|
types: [python]
|
||||||
|
entry: pdm run black .
|
||||||
|
language: system
|
||||||
|
pass_filenames: false
|
||||||
|
always_run: true
|
||||||
|
- id: ruff
|
||||||
|
name: ruff
|
||||||
|
stages: [commit]
|
||||||
|
types: [python]
|
||||||
|
entry: pdm run ruff .
|
||||||
|
language: system
|
||||||
|
pass_filenames: false
|
||||||
|
always_run: true
|
||||||
|
fail_fast: true
|
||||||
|
- id: pytest
|
||||||
|
name: pytest
|
||||||
|
stages: [commit]
|
||||||
|
types: [python]
|
||||||
|
entry: pdm run pytest
|
||||||
|
language: system
|
||||||
|
pass_filenames: false
|
||||||
|
always_run: true
|
||||||
|
fail_fast: true
|
||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
FROM python:3.11-alpine
|
||||||
|
|
||||||
|
# Install package
|
||||||
|
WORKDIR /code
|
||||||
|
COPY . .
|
||||||
|
RUN pip3 install .
|
||||||
|
|
||||||
|
ENV QBITTORRENT_HOST=""
|
||||||
|
ENV QBITTORRENT_PORT=""
|
||||||
|
ENV QBITTORRENT_USER=""
|
||||||
|
ENV QBITTORRENT_PASS=""
|
||||||
|
ENV EXPORTER_PORT="8000"
|
||||||
|
ENV EXPORTER_LOG_LEVEL="INFO"
|
||||||
|
|
||||||
|
ENTRYPOINT ["qbittorrent-exporter"]
|
||||||
@@ -0,0 +1,674 @@
|
|||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
|
GNU General Public License for most of our software; it applies also to
|
||||||
|
any other work released this way by its authors. You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to prevent others from denying you
|
||||||
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
|
freedoms that you received. You must make sure that they, too, receive
|
||||||
|
or can get the source code. And you must show them these terms so they
|
||||||
|
know their rights.
|
||||||
|
|
||||||
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
|
|
||||||
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
|
that there is no warranty for this free software. For both users' and
|
||||||
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
|
changed, so that their problems will not be attributed erroneously to
|
||||||
|
authors of previous versions.
|
||||||
|
|
||||||
|
Some devices are designed to deny users access to install or run
|
||||||
|
modified versions of the software inside them, although the manufacturer
|
||||||
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
|
protecting users' freedom to change the software. The systematic
|
||||||
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
|
products. If such problems arise substantially in other domains, we
|
||||||
|
stand ready to extend this provision to those domains in future versions
|
||||||
|
of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
|
Finally, every program is threatened constantly by software patents.
|
||||||
|
States should not allow patents to restrict development and use of
|
||||||
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
|
avoid the special danger that patents applied to a free program could
|
||||||
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
|
patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the special requirements of the GNU Affero General Public License,
|
||||||
|
section 13, concerning interaction through a network will apply to the
|
||||||
|
combination as such.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program does terminal interaction, make it output a short
|
||||||
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
|
<program> Copyright (C) <year> <name of author>
|
||||||
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, your program's commands
|
||||||
|
might be different; for a GUI interface, you would use an "about box".
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU GPL, see
|
||||||
|
<https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
The GNU General Public License does not permit incorporating your program
|
||||||
|
into proprietary programs. If your program is a subroutine library, you
|
||||||
|
may consider it more useful to permit linking proprietary applications with
|
||||||
|
the library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License. But first, please read
|
||||||
|
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||||
@@ -1,40 +1,77 @@
|
|||||||
# Repository Coverage
|
# Prometheus qBittorrent exporter
|
||||||
|
|
||||||
[Full report](https://htmlpreview.github.io/?https://github.com/esanchezm/prometheus-qbittorrent-exporter/blob/python-coverage-comment-action-data/htmlcov/index.html)
|
<p align="center">
|
||||||
|
<img src="https://raw.githubusercontent.com/esanchezm/prometheus-qbittorrent-exporter/master/logo.png" height="230">
|
||||||
|
</p>
|
||||||
|
|
||||||
| Name | Stmts | Miss | Cover | Missing |
|
A prometheus exporter for qBitorrent. Get metrics from a server and offers them in a prometheus format.
|
||||||
|-------------------------------------- | -------: | -------: | ------: | --------: |
|
|
||||||
| qbittorrent\_exporter/\_\_init\_\_.py | 0 | 0 | 100% | |
|
     [](https://htmlpreview.github.io/?https://github.com/esanchezm/prometheus-qbittorrent-exporter/blob/python-coverage-comment-action-data/htmlcov/index.html)
|
||||||
| qbittorrent\_exporter/exporter.py | 132 | 42 | 68% |95-96, 220-224, 227, 230-234, 238-246, 251, 267-305, 309 |
|
|
||||||
| **TOTAL** | **132** | **42** | **68%** | |
|
## How to use it
|
||||||
|
|
||||||
|
You can install this exporter with the following command:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip3 install prometheus-qbittorrent-exporter
|
||||||
|
```
|
||||||
|
|
||||||
|
Then you can run it with
|
||||||
|
|
||||||
|
```
|
||||||
|
qbittorrent-exporter
|
||||||
|
```
|
||||||
|
|
||||||
|
Another option is run it in a docker container.
|
||||||
|
|
||||||
|
```
|
||||||
|
docker run \
|
||||||
|
-e QBITTORRENT_PORT=8080 \
|
||||||
|
-e QBITTORRENT_HOST=myserver.local \
|
||||||
|
-p 8000:8000 \
|
||||||
|
ghcr.io/esanchezm/prometheus-qbittorrent-exporter
|
||||||
|
```
|
||||||
|
Add this to your prometheus.yml
|
||||||
|
```
|
||||||
|
- job_name: "qbittorrent_exporter"
|
||||||
|
static_configs:
|
||||||
|
- targets: ['yourqbittorrentexporter:port']
|
||||||
|
```
|
||||||
|
The application reads configuration using environment variables:
|
||||||
|
|
||||||
|
| Environment variable | Default | Description |
|
||||||
|
| -------------------------- | ------------- | ----------- |
|
||||||
|
| `QBITTORRENT_HOST` | | qbittorrent server hostname |
|
||||||
|
| `QBITTORRENT_PORT` | | qbittorrent server port |
|
||||||
|
| `QBITTORRENT_USER` | `""` | qbittorrent username |
|
||||||
|
| `QBITTORRENT_PASS` | `""` | qbittorrent password |
|
||||||
|
| `EXPORTER_PORT` | `8000` | Exporter listening port |
|
||||||
|
| `EXPORTER_LOG_LEVEL` | `INFO` | Log level. One of: `DEBUG`, `INFO`, `WARNING`, `ERROR`, `CRITICAL` |
|
||||||
|
| `METRICS_PREFIX` | `qbittorrent` | Prefix to add to all the metrics |
|
||||||
|
| `VERIFY_WEBUI_CERTIFICATE` | `True` | Whether to verify SSL certificate when connecting to the qbittorrent server. Any other value but `True` will disable the verification |
|
||||||
|
|
||||||
|
|
||||||
## Setup coverage badge
|
## Metrics
|
||||||
|
|
||||||
Below are examples of the badges you can use in your main branch `README` file.
|
These are the metrics this program exports, assuming the `METRICS_PREFIX` is `qbittorrent`:
|
||||||
|
|
||||||
### Direct image
|
|
||||||
|
|
||||||
[](https://htmlpreview.github.io/?https://github.com/esanchezm/prometheus-qbittorrent-exporter/blob/python-coverage-comment-action-data/htmlcov/index.html)
|
| Metric name | Type | Description |
|
||||||
|
| --------------------------------------------------- | -------- | ---------------- |
|
||||||
|
| `qbittorrent_up` | gauge | Whether the qBittorrent server is answering requests from this exporter. A `version` label with the server version is added. |
|
||||||
|
| `qbittorrent_connected` | gauge | Whether the qBittorrent server is connected to the Bittorrent network. |
|
||||||
|
| `qbittorrent_firewalled` | gauge | Whether the qBittorrent server is connected to the Bittorrent network but is behind a firewall. |
|
||||||
|
| `qbittorrent_dht_nodes` | gauge | Number of DHT nodes connected to. |
|
||||||
|
| `qbittorrent_dl_info_data` | counter | Data downloaded since the server started, in bytes. |
|
||||||
|
| `qbittorrent_up_info_data` | counter | Data uploaded since the server started, in bytes. |
|
||||||
|
| `qbittorrent_torrents_count` | gauge | Number of torrents for each `category` and `status`. Example: `qbittorrent_torrents_count{category="movies",status="downloading"}`|
|
||||||
|
|
||||||
This is the one to use if your repository is private or if you don't want to customize anything.
|
## Screenshot
|
||||||
|
|
||||||
### [Shields.io](https://shields.io) Json Endpoint
|

|
||||||
|
|
||||||
[](https://htmlpreview.github.io/?https://github.com/esanchezm/prometheus-qbittorrent-exporter/blob/python-coverage-comment-action-data/htmlcov/index.html)
|
[More info](./grafana/README.md)
|
||||||
|
|
||||||
Using this one will allow you to [customize](https://shields.io/endpoint) the look of your badge.
|
## License
|
||||||
It won't work with private repositories. It won't be refreshed more than once per five minutes.
|
|
||||||
|
|
||||||
### [Shields.io](https://shields.io) Dynamic Badge
|
This software is released under the [GPLv3 license](LICENSE).
|
||||||
|
|
||||||
[](https://htmlpreview.github.io/?https://github.com/esanchezm/prometheus-qbittorrent-exporter/blob/python-coverage-comment-action-data/htmlcov/index.html)
|
|
||||||
|
|
||||||
This one will always be the same color. It won't work for private repos. I'm not even sure why we included it.
|
|
||||||
|
|
||||||
## What is that?
|
|
||||||
|
|
||||||
This branch is part of the
|
|
||||||
[python-coverage-comment-action](https://github.com/marketplace/actions/python-coverage-comment)
|
|
||||||
GitHub Action. All the files in this branch are automatically generated and may be
|
|
||||||
overwritten at any moment.
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="98" height="20" role="img" aria-label="Coverage: 68%"><title>Coverage: 68%</title><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="98" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="63" height="20" fill="#555"/><rect x="63" width="35" height="20" fill="#e05d44"/><rect width="98" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="325" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="530">Coverage</text><text x="325" y="140" transform="scale(.1)" fill="#fff" textLength="530">Coverage</text><text aria-hidden="true" x="795" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="250">68%</text><text x="795" y="140" transform="scale(.1)" fill="#fff" textLength="250">68%</text></g></svg>
|
|
||||||
|
Before Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1,6 @@
|
|||||||
|
QBITTORRENT_HOST=localhost
|
||||||
|
QBITTORRENT_PORT=8080
|
||||||
|
QBITTORRENT_USER=admin
|
||||||
|
QBITTORRENT_PASS=adminadmin
|
||||||
|
EXPORTER_PORT=8000
|
||||||
|
METRICS_PREFIX=qbittorrent
|
||||||
@@ -1 +0,0 @@
|
|||||||
{"coverage": 68.18181818181819, "raw_data": {"meta": {"version": "7.3.2", "timestamp": "2023-12-10T09:17:49.771082", "branch_coverage": false, "show_contexts": false}, "files": {"qbittorrent_exporter/__init__.py": {"executed_lines": [0], "summary": {"covered_lines": 0, "num_statements": 0, "percent_covered": 100.0, "percent_covered_display": "100", "missing_lines": 0, "excluded_lines": 0}, "missing_lines": [], "excluded_lines": []}, "qbittorrent_exporter/exporter.py": {"executed_lines": [1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 17, 18, 21, 22, 26, 27, 30, 31, 32, 36, 37, 38, 39, 40, 43, 44, 45, 46, 54, 58, 60, 61, 62, 66, 69, 72, 74, 78, 79, 80, 82, 84, 88, 89, 92, 93, 94, 98, 148, 150, 151, 152, 153, 154, 155, 156, 157, 159, 161, 162, 163, 164, 165, 167, 171, 178, 182, 184, 187, 197, 198, 199, 201, 202, 204, 205, 206, 207, 210, 213, 215, 218, 219, 226, 229, 237, 249, 265, 308], "summary": {"covered_lines": 90, "num_statements": 132, "percent_covered": 68.18181818181819, "percent_covered_display": "68", "missing_lines": 42, "excluded_lines": 0}, "missing_lines": [95, 96, 220, 223, 224, 227, 230, 231, 232, 233, 234, 238, 239, 240, 241, 242, 243, 244, 246, 251, 267, 268, 271, 272, 273, 275, 278, 281, 283, 284, 287, 288, 289, 292, 295, 296, 299, 300, 302, 303, 305, 309], "excluded_lines": []}}, "totals": {"covered_lines": 90, "num_statements": 132, "percent_covered": 68.18181818181819, "percent_covered_display": "68", "missing_lines": 42, "excluded_lines": 0}}, "coverage_path": "."}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
{"schemaVersion": 1, "label": "Coverage", "message": "68%", "color": "red"}
|
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
# Grafana dashboard
|
||||||
|
|
||||||
|
## Import
|
||||||
|
|
||||||
|
To import the dashboard into your grafana, download the [dashboard.json](https://raw.githubusercontent.com/esanchezm/prometheus-qbittorrent-exporter/master/grafana/dashboard.json) file and import it into your server. Select your prometheus instance and that should be all.
|
||||||
|
|
||||||
|
## Screenshot
|
||||||
|
|
||||||
|

|
||||||
@@ -0,0 +1,876 @@
|
|||||||
|
{
|
||||||
|
"annotations": {
|
||||||
|
"list": [
|
||||||
|
{
|
||||||
|
"builtIn": 1,
|
||||||
|
"datasource": {
|
||||||
|
"type": "datasource",
|
||||||
|
"uid": "grafana"
|
||||||
|
},
|
||||||
|
"enable": true,
|
||||||
|
"hide": true,
|
||||||
|
"iconColor": "rgba(0, 211, 255, 1)",
|
||||||
|
"name": "Annotations & Alerts",
|
||||||
|
"target": {
|
||||||
|
"limit": 100,
|
||||||
|
"matchAny": false,
|
||||||
|
"tags": [],
|
||||||
|
"type": "dashboard"
|
||||||
|
},
|
||||||
|
"type": "dashboard"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"editable": true,
|
||||||
|
"fiscalYearStartMonth": 0,
|
||||||
|
"graphTooltip": 0,
|
||||||
|
"id": 5,
|
||||||
|
"links": [],
|
||||||
|
"liveNow": false,
|
||||||
|
"panels": [
|
||||||
|
{
|
||||||
|
"datasource": {
|
||||||
|
"type": "prometheus",
|
||||||
|
"uid": "${data_source}"
|
||||||
|
},
|
||||||
|
"fieldConfig": {
|
||||||
|
"defaults": {
|
||||||
|
"mappings": [
|
||||||
|
{
|
||||||
|
"options": {
|
||||||
|
"0": {
|
||||||
|
"text": "Offline"
|
||||||
|
},
|
||||||
|
"1": {
|
||||||
|
"text": "Online"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"type": "value"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"options": {
|
||||||
|
"match": "null",
|
||||||
|
"result": {
|
||||||
|
"text": "Unknown"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"type": "special"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"thresholds": {
|
||||||
|
"mode": "absolute",
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"color": "yellow",
|
||||||
|
"value": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"color": "semi-dark-red",
|
||||||
|
"value": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"color": "semi-dark-green",
|
||||||
|
"value": 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"overrides": []
|
||||||
|
},
|
||||||
|
"gridPos": {
|
||||||
|
"h": 4,
|
||||||
|
"w": 3,
|
||||||
|
"x": 0,
|
||||||
|
"y": 0
|
||||||
|
},
|
||||||
|
"id": 2,
|
||||||
|
"options": {
|
||||||
|
"colorMode": "value",
|
||||||
|
"graphMode": "area",
|
||||||
|
"justifyMode": "auto",
|
||||||
|
"orientation": "auto",
|
||||||
|
"reduceOptions": {
|
||||||
|
"calcs": [
|
||||||
|
"last"
|
||||||
|
],
|
||||||
|
"fields": "",
|
||||||
|
"values": false
|
||||||
|
},
|
||||||
|
"textMode": "auto"
|
||||||
|
},
|
||||||
|
"pluginVersion": "9.4.3",
|
||||||
|
"targets": [
|
||||||
|
{
|
||||||
|
"datasource": {
|
||||||
|
"type": "prometheus",
|
||||||
|
"uid": "${data_source}"
|
||||||
|
},
|
||||||
|
"expr": "qbittorrent_up",
|
||||||
|
"format": "time_series",
|
||||||
|
"instant": false,
|
||||||
|
"interval": "",
|
||||||
|
"legendFormat": "",
|
||||||
|
"refId": "A"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"title": "Qbittorrent Status",
|
||||||
|
"transformations": [],
|
||||||
|
"type": "stat"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"datasource": {
|
||||||
|
"type": "prometheus",
|
||||||
|
"uid": "${data_source}"
|
||||||
|
},
|
||||||
|
"fieldConfig": {
|
||||||
|
"defaults": {
|
||||||
|
"mappings": [
|
||||||
|
{
|
||||||
|
"options": {
|
||||||
|
"0": {
|
||||||
|
"text": "Disconnected"
|
||||||
|
},
|
||||||
|
"1": {
|
||||||
|
"text": "Connected"
|
||||||
|
},
|
||||||
|
"-1": {
|
||||||
|
"text": "Firewalled"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"type": "value"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"thresholds": {
|
||||||
|
"mode": "absolute",
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"color": "yellow",
|
||||||
|
"value": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"color": "dark-red",
|
||||||
|
"value": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"color": "semi-dark-green",
|
||||||
|
"value": 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"overrides": []
|
||||||
|
},
|
||||||
|
"gridPos": {
|
||||||
|
"h": 4,
|
||||||
|
"w": 3,
|
||||||
|
"x": 3,
|
||||||
|
"y": 0
|
||||||
|
},
|
||||||
|
"id": 3,
|
||||||
|
"options": {
|
||||||
|
"colorMode": "value",
|
||||||
|
"graphMode": "none",
|
||||||
|
"justifyMode": "auto",
|
||||||
|
"orientation": "auto",
|
||||||
|
"reduceOptions": {
|
||||||
|
"calcs": [
|
||||||
|
"lastNotNull"
|
||||||
|
],
|
||||||
|
"fields": "",
|
||||||
|
"values": false
|
||||||
|
},
|
||||||
|
"textMode": "auto"
|
||||||
|
},
|
||||||
|
"pluginVersion": "9.4.3",
|
||||||
|
"targets": [
|
||||||
|
{
|
||||||
|
"expr": "qbittorrent_connected - qbittorrent_firewalled",
|
||||||
|
"format": "time_series",
|
||||||
|
"instant": true,
|
||||||
|
"interval": "",
|
||||||
|
"legendFormat": "Status",
|
||||||
|
"refId": "A"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"title": "Bittorrent network",
|
||||||
|
"transformations": [],
|
||||||
|
"type": "stat"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"datasource": {
|
||||||
|
"type": "prometheus",
|
||||||
|
"uid": "${data_source}"
|
||||||
|
},
|
||||||
|
"fieldConfig": {
|
||||||
|
"defaults": {
|
||||||
|
"mappings": [
|
||||||
|
{
|
||||||
|
"options": {
|
||||||
|
"0": {
|
||||||
|
"text": "No DHT"
|
||||||
|
},
|
||||||
|
"-1": {
|
||||||
|
"text": "Firewalled"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"type": "value"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"thresholds": {
|
||||||
|
"mode": "absolute",
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"color": "yellow",
|
||||||
|
"value": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"color": "dark-red",
|
||||||
|
"value": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"color": "semi-dark-green",
|
||||||
|
"value": 100
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"overrides": []
|
||||||
|
},
|
||||||
|
"gridPos": {
|
||||||
|
"h": 4,
|
||||||
|
"w": 3,
|
||||||
|
"x": 6,
|
||||||
|
"y": 0
|
||||||
|
},
|
||||||
|
"id": 13,
|
||||||
|
"options": {
|
||||||
|
"colorMode": "value",
|
||||||
|
"graphMode": "none",
|
||||||
|
"justifyMode": "auto",
|
||||||
|
"orientation": "auto",
|
||||||
|
"reduceOptions": {
|
||||||
|
"calcs": [
|
||||||
|
"lastNotNull"
|
||||||
|
],
|
||||||
|
"fields": "",
|
||||||
|
"values": false
|
||||||
|
},
|
||||||
|
"textMode": "auto"
|
||||||
|
},
|
||||||
|
"pluginVersion": "9.4.3",
|
||||||
|
"targets": [
|
||||||
|
{
|
||||||
|
"expr": "qbittorrent_dht_nodes",
|
||||||
|
"instant": true,
|
||||||
|
"interval": "",
|
||||||
|
"legendFormat": "DHT nodes",
|
||||||
|
"refId": "B"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"title": "DHT nodes",
|
||||||
|
"transformations": [],
|
||||||
|
"type": "stat"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"datasource": {
|
||||||
|
"type": "prometheus",
|
||||||
|
"uid": "${data_source}"
|
||||||
|
},
|
||||||
|
"fieldConfig": {
|
||||||
|
"defaults": {
|
||||||
|
"mappings": [],
|
||||||
|
"thresholds": {
|
||||||
|
"mode": "absolute",
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"color": "green",
|
||||||
|
"value": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"unit": "bytes"
|
||||||
|
},
|
||||||
|
"overrides": []
|
||||||
|
},
|
||||||
|
"gridPos": {
|
||||||
|
"h": 4,
|
||||||
|
"w": 3,
|
||||||
|
"x": 9,
|
||||||
|
"y": 0
|
||||||
|
},
|
||||||
|
"id": 5,
|
||||||
|
"options": {
|
||||||
|
"colorMode": "value",
|
||||||
|
"graphMode": "none",
|
||||||
|
"justifyMode": "auto",
|
||||||
|
"orientation": "auto",
|
||||||
|
"reduceOptions": {
|
||||||
|
"calcs": [
|
||||||
|
"last"
|
||||||
|
],
|
||||||
|
"fields": "",
|
||||||
|
"values": false
|
||||||
|
},
|
||||||
|
"textMode": "auto"
|
||||||
|
},
|
||||||
|
"pluginVersion": "9.4.3",
|
||||||
|
"targets": [
|
||||||
|
{
|
||||||
|
"datasource": {
|
||||||
|
"type": "prometheus",
|
||||||
|
"uid": "${data_source}"
|
||||||
|
},
|
||||||
|
"editorMode": "code",
|
||||||
|
"expr": "sum by (app) (qbittorrent_dl_info_data_total)",
|
||||||
|
"instant": false,
|
||||||
|
"interval": "",
|
||||||
|
"legendFormat": " ",
|
||||||
|
"refId": "A"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"title": "Data downloaded",
|
||||||
|
"type": "stat"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"datasource": {
|
||||||
|
"type": "prometheus",
|
||||||
|
"uid": "${data_source}"
|
||||||
|
},
|
||||||
|
"fieldConfig": {
|
||||||
|
"defaults": {
|
||||||
|
"mappings": [],
|
||||||
|
"thresholds": {
|
||||||
|
"mode": "absolute",
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"color": "green",
|
||||||
|
"value": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"unit": "bytes"
|
||||||
|
},
|
||||||
|
"overrides": []
|
||||||
|
},
|
||||||
|
"gridPos": {
|
||||||
|
"h": 4,
|
||||||
|
"w": 3,
|
||||||
|
"x": 12,
|
||||||
|
"y": 0
|
||||||
|
},
|
||||||
|
"id": 6,
|
||||||
|
"options": {
|
||||||
|
"colorMode": "value",
|
||||||
|
"graphMode": "none",
|
||||||
|
"justifyMode": "auto",
|
||||||
|
"orientation": "auto",
|
||||||
|
"reduceOptions": {
|
||||||
|
"calcs": [
|
||||||
|
"last"
|
||||||
|
],
|
||||||
|
"fields": "",
|
||||||
|
"values": false
|
||||||
|
},
|
||||||
|
"textMode": "auto"
|
||||||
|
},
|
||||||
|
"pluginVersion": "9.4.3",
|
||||||
|
"targets": [
|
||||||
|
{
|
||||||
|
"datasource": {
|
||||||
|
"type": "prometheus",
|
||||||
|
"uid": "${data_source}"
|
||||||
|
},
|
||||||
|
"editorMode": "code",
|
||||||
|
"expr": "sum by (app) (qbittorrent_up_info_data_total)",
|
||||||
|
"instant": false,
|
||||||
|
"interval": "",
|
||||||
|
"legendFormat": " ",
|
||||||
|
"refId": "A"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"title": "Data uploaded",
|
||||||
|
"type": "stat"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"datasource": {
|
||||||
|
"type": "prometheus",
|
||||||
|
"uid": "${data_source}"
|
||||||
|
},
|
||||||
|
"fieldConfig": {
|
||||||
|
"defaults": {
|
||||||
|
"mappings": [],
|
||||||
|
"thresholds": {
|
||||||
|
"mode": "absolute",
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"color": "green",
|
||||||
|
"value": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"unit": "none"
|
||||||
|
},
|
||||||
|
"overrides": []
|
||||||
|
},
|
||||||
|
"gridPos": {
|
||||||
|
"h": 4,
|
||||||
|
"w": 3,
|
||||||
|
"x": 15,
|
||||||
|
"y": 0
|
||||||
|
},
|
||||||
|
"id": 7,
|
||||||
|
"options": {
|
||||||
|
"colorMode": "value",
|
||||||
|
"graphMode": "area",
|
||||||
|
"justifyMode": "auto",
|
||||||
|
"orientation": "auto",
|
||||||
|
"reduceOptions": {
|
||||||
|
"calcs": [
|
||||||
|
"last"
|
||||||
|
],
|
||||||
|
"fields": "",
|
||||||
|
"values": false
|
||||||
|
},
|
||||||
|
"textMode": "auto"
|
||||||
|
},
|
||||||
|
"pluginVersion": "9.4.3",
|
||||||
|
"targets": [
|
||||||
|
{
|
||||||
|
"datasource": {
|
||||||
|
"type": "prometheus",
|
||||||
|
"uid": "${data_source}"
|
||||||
|
},
|
||||||
|
"editorMode": "code",
|
||||||
|
"expr": "(sum by (app) (qbittorrent_up_info_data_total)) / (sum by (app) (qbittorrent_dl_info_data_total))",
|
||||||
|
"instant": false,
|
||||||
|
"interval": "",
|
||||||
|
"legendFormat": "{{label_name}}",
|
||||||
|
"refId": "A"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"title": "Accumulated ratio",
|
||||||
|
"type": "stat"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"datasource": {
|
||||||
|
"type": "prometheus",
|
||||||
|
"uid": "${data_source}"
|
||||||
|
},
|
||||||
|
"fieldConfig": {
|
||||||
|
"defaults": {
|
||||||
|
"decimals": 1,
|
||||||
|
"mappings": [],
|
||||||
|
"max": 48000000,
|
||||||
|
"min": 0,
|
||||||
|
"thresholds": {
|
||||||
|
"mode": "absolute",
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"color": "dark-red",
|
||||||
|
"value": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"color": "dark-green",
|
||||||
|
"value": 8000000
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"unit": "binBps"
|
||||||
|
},
|
||||||
|
"overrides": []
|
||||||
|
},
|
||||||
|
"gridPos": {
|
||||||
|
"h": 4,
|
||||||
|
"w": 3,
|
||||||
|
"x": 18,
|
||||||
|
"y": 0
|
||||||
|
},
|
||||||
|
"id": 16,
|
||||||
|
"options": {
|
||||||
|
"orientation": "auto",
|
||||||
|
"reduceOptions": {
|
||||||
|
"calcs": [
|
||||||
|
"last"
|
||||||
|
],
|
||||||
|
"fields": "",
|
||||||
|
"values": false
|
||||||
|
},
|
||||||
|
"showThresholdLabels": false,
|
||||||
|
"showThresholdMarkers": true
|
||||||
|
},
|
||||||
|
"pluginVersion": "9.4.3",
|
||||||
|
"targets": [
|
||||||
|
{
|
||||||
|
"expr": "rate(qbittorrent_dl_info_data_total[2m])",
|
||||||
|
"instant": false,
|
||||||
|
"interval": "",
|
||||||
|
"legendFormat": "",
|
||||||
|
"refId": "A"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"title": "Download speed",
|
||||||
|
"type": "gauge"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"datasource": {
|
||||||
|
"type": "prometheus",
|
||||||
|
"uid": "${data_source}"
|
||||||
|
},
|
||||||
|
"fieldConfig": {
|
||||||
|
"defaults": {
|
||||||
|
"decimals": 1,
|
||||||
|
"mappings": [],
|
||||||
|
"max": 18000000,
|
||||||
|
"min": 0,
|
||||||
|
"thresholds": {
|
||||||
|
"mode": "absolute",
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"color": "dark-red",
|
||||||
|
"value": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"color": "dark-green",
|
||||||
|
"value": 4000000
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"unit": "binBps"
|
||||||
|
},
|
||||||
|
"overrides": []
|
||||||
|
},
|
||||||
|
"gridPos": {
|
||||||
|
"h": 4,
|
||||||
|
"w": 3,
|
||||||
|
"x": 21,
|
||||||
|
"y": 0
|
||||||
|
},
|
||||||
|
"id": 17,
|
||||||
|
"options": {
|
||||||
|
"orientation": "auto",
|
||||||
|
"reduceOptions": {
|
||||||
|
"calcs": [
|
||||||
|
"last"
|
||||||
|
],
|
||||||
|
"fields": "",
|
||||||
|
"values": false
|
||||||
|
},
|
||||||
|
"showThresholdLabels": false,
|
||||||
|
"showThresholdMarkers": true
|
||||||
|
},
|
||||||
|
"pluginVersion": "9.4.3",
|
||||||
|
"targets": [
|
||||||
|
{
|
||||||
|
"expr": "rate(qbittorrent_up_info_data_total[2m])",
|
||||||
|
"hide": false,
|
||||||
|
"instant": false,
|
||||||
|
"interval": "",
|
||||||
|
"legendFormat": "",
|
||||||
|
"refId": "A"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"title": "Upload speed",
|
||||||
|
"type": "gauge"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"aliasColors": {},
|
||||||
|
"bars": false,
|
||||||
|
"dashLength": 10,
|
||||||
|
"dashes": false,
|
||||||
|
"datasource": {
|
||||||
|
"type": "prometheus",
|
||||||
|
"uid": "${data_source}"
|
||||||
|
},
|
||||||
|
"fill": 1,
|
||||||
|
"fillGradient": 0,
|
||||||
|
"gridPos": {
|
||||||
|
"h": 10,
|
||||||
|
"w": 24,
|
||||||
|
"x": 0,
|
||||||
|
"y": 4
|
||||||
|
},
|
||||||
|
"hiddenSeries": false,
|
||||||
|
"id": 15,
|
||||||
|
"legend": {
|
||||||
|
"avg": false,
|
||||||
|
"current": false,
|
||||||
|
"max": false,
|
||||||
|
"min": false,
|
||||||
|
"show": true,
|
||||||
|
"total": false,
|
||||||
|
"values": false
|
||||||
|
},
|
||||||
|
"lines": true,
|
||||||
|
"linewidth": 1,
|
||||||
|
"nullPointMode": "null",
|
||||||
|
"options": {
|
||||||
|
"alertThreshold": true
|
||||||
|
},
|
||||||
|
"percentage": false,
|
||||||
|
"pluginVersion": "9.4.3",
|
||||||
|
"pointradius": 2,
|
||||||
|
"points": false,
|
||||||
|
"renderer": "flot",
|
||||||
|
"seriesOverrides": [],
|
||||||
|
"spaceLength": 10,
|
||||||
|
"stack": false,
|
||||||
|
"steppedLine": false,
|
||||||
|
"targets": [
|
||||||
|
{
|
||||||
|
"expr": "rate(qbittorrent_dl_info_data_total[2m])",
|
||||||
|
"interval": "",
|
||||||
|
"legendFormat": "Download",
|
||||||
|
"refId": "A"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"expr": "rate(qbittorrent_up_info_data_total[2m])",
|
||||||
|
"interval": "",
|
||||||
|
"legendFormat": "Upload",
|
||||||
|
"refId": "B"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"thresholds": [],
|
||||||
|
"timeRegions": [],
|
||||||
|
"title": "Transfer Rates",
|
||||||
|
"tooltip": {
|
||||||
|
"shared": true,
|
||||||
|
"sort": 0,
|
||||||
|
"value_type": "individual"
|
||||||
|
},
|
||||||
|
"type": "graph",
|
||||||
|
"xaxis": {
|
||||||
|
"mode": "time",
|
||||||
|
"show": true,
|
||||||
|
"values": []
|
||||||
|
},
|
||||||
|
"yaxes": [
|
||||||
|
{
|
||||||
|
"format": "binBps",
|
||||||
|
"logBase": 1,
|
||||||
|
"show": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"format": "binBps",
|
||||||
|
"logBase": 1,
|
||||||
|
"show": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"yaxis": {
|
||||||
|
"align": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"aliasColors": {},
|
||||||
|
"bars": true,
|
||||||
|
"dashLength": 10,
|
||||||
|
"dashes": false,
|
||||||
|
"datasource": {
|
||||||
|
"type": "prometheus",
|
||||||
|
"uid": "${data_source}"
|
||||||
|
},
|
||||||
|
"fill": 1,
|
||||||
|
"fillGradient": 0,
|
||||||
|
"gridPos": {
|
||||||
|
"h": 10,
|
||||||
|
"w": 14,
|
||||||
|
"x": 0,
|
||||||
|
"y": 14
|
||||||
|
},
|
||||||
|
"hiddenSeries": false,
|
||||||
|
"id": 11,
|
||||||
|
"legend": {
|
||||||
|
"alignAsTable": true,
|
||||||
|
"avg": false,
|
||||||
|
"current": false,
|
||||||
|
"max": false,
|
||||||
|
"min": false,
|
||||||
|
"rightSide": true,
|
||||||
|
"show": true,
|
||||||
|
"total": false,
|
||||||
|
"values": false
|
||||||
|
},
|
||||||
|
"lines": false,
|
||||||
|
"linewidth": 0,
|
||||||
|
"links": [],
|
||||||
|
"nullPointMode": "null as zero",
|
||||||
|
"options": {
|
||||||
|
"alertThreshold": true
|
||||||
|
},
|
||||||
|
"percentage": false,
|
||||||
|
"pluginVersion": "9.4.3",
|
||||||
|
"pointradius": 2,
|
||||||
|
"points": false,
|
||||||
|
"renderer": "flot",
|
||||||
|
"seriesOverrides": [],
|
||||||
|
"spaceLength": 10,
|
||||||
|
"stack": true,
|
||||||
|
"steppedLine": true,
|
||||||
|
"targets": [
|
||||||
|
{
|
||||||
|
"expr": "sum(qbittorrent_torrents_count{category=~\"${categories}\", status!=\"complete\"}) by (status)",
|
||||||
|
"interval": "",
|
||||||
|
"legendFormat": "{{status}}",
|
||||||
|
"refId": "A"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"thresholds": [],
|
||||||
|
"timeRegions": [],
|
||||||
|
"title": "Torrents by status",
|
||||||
|
"tooltip": {
|
||||||
|
"shared": true,
|
||||||
|
"sort": 0,
|
||||||
|
"value_type": "individual"
|
||||||
|
},
|
||||||
|
"type": "graph",
|
||||||
|
"xaxis": {
|
||||||
|
"mode": "time",
|
||||||
|
"show": true,
|
||||||
|
"values": []
|
||||||
|
},
|
||||||
|
"yaxes": [
|
||||||
|
{
|
||||||
|
"format": "short",
|
||||||
|
"logBase": 1,
|
||||||
|
"show": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"format": "short",
|
||||||
|
"logBase": 1,
|
||||||
|
"show": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"yaxis": {
|
||||||
|
"align": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"datasource": {
|
||||||
|
"type": "prometheus",
|
||||||
|
"uid": "${data_source}"
|
||||||
|
},
|
||||||
|
"fieldConfig": {
|
||||||
|
"defaults": {
|
||||||
|
"color": {
|
||||||
|
"mode": "palette-classic"
|
||||||
|
},
|
||||||
|
"custom": {
|
||||||
|
"hideFrom": {
|
||||||
|
"legend": false,
|
||||||
|
"tooltip": false,
|
||||||
|
"viz": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"mappings": []
|
||||||
|
},
|
||||||
|
"overrides": []
|
||||||
|
},
|
||||||
|
"gridPos": {
|
||||||
|
"h": 10,
|
||||||
|
"w": 10,
|
||||||
|
"x": 14,
|
||||||
|
"y": 14
|
||||||
|
},
|
||||||
|
"id": 12,
|
||||||
|
"links": [],
|
||||||
|
"options": {
|
||||||
|
"legend": {
|
||||||
|
"displayMode": "list",
|
||||||
|
"placement": "bottom",
|
||||||
|
"showLegend": true
|
||||||
|
},
|
||||||
|
"pieType": "pie",
|
||||||
|
"reduceOptions": {
|
||||||
|
"calcs": [
|
||||||
|
"lastNotNull"
|
||||||
|
],
|
||||||
|
"fields": "",
|
||||||
|
"values": false
|
||||||
|
},
|
||||||
|
"tooltip": {
|
||||||
|
"mode": "single",
|
||||||
|
"sort": "none"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"pluginVersion": "7.2.0",
|
||||||
|
"targets": [
|
||||||
|
{
|
||||||
|
"expr": "sum(qbittorrent_torrents_count{category=~\"${categories}\",status!=\"complete\"}) by (category)",
|
||||||
|
"interval": "",
|
||||||
|
"legendFormat": "{{category}}",
|
||||||
|
"refId": "A"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"title": "Torrents by categories",
|
||||||
|
"type": "piechart"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"refresh": "10s",
|
||||||
|
"revision": 1,
|
||||||
|
"schemaVersion": 38,
|
||||||
|
"style": "dark",
|
||||||
|
"tags": [],
|
||||||
|
"templating": {
|
||||||
|
"list": [
|
||||||
|
{
|
||||||
|
"allValue": ".*",
|
||||||
|
"current": {
|
||||||
|
"selected": false,
|
||||||
|
"text": "All",
|
||||||
|
"value": "$__all"
|
||||||
|
},
|
||||||
|
"datasource": {
|
||||||
|
"type": "prometheus",
|
||||||
|
"uid": "${data_source}"
|
||||||
|
},
|
||||||
|
"definition": "label_values(qbittorrent_torrents_count, category)",
|
||||||
|
"hide": 0,
|
||||||
|
"includeAll": true,
|
||||||
|
"label": "Categories",
|
||||||
|
"multi": true,
|
||||||
|
"name": "categories",
|
||||||
|
"options": [],
|
||||||
|
"query": {
|
||||||
|
"query": "label_values(qbittorrent_torrents_count, category)",
|
||||||
|
"refId": "Prometheus-categories-Variable-Query"
|
||||||
|
},
|
||||||
|
"refresh": 1,
|
||||||
|
"regex": "",
|
||||||
|
"skipUrlSync": false,
|
||||||
|
"sort": 0,
|
||||||
|
"tagValuesQuery": "",
|
||||||
|
"tagsQuery": "",
|
||||||
|
"type": "query",
|
||||||
|
"useTags": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"current": {
|
||||||
|
"selected": true,
|
||||||
|
"text": "Prometheus",
|
||||||
|
"value": "Prometheus"
|
||||||
|
},
|
||||||
|
"hide": 0,
|
||||||
|
"includeAll": false,
|
||||||
|
"label": "Data Source",
|
||||||
|
"multi": false,
|
||||||
|
"name": "data_source",
|
||||||
|
"options": [],
|
||||||
|
"query": "prometheus",
|
||||||
|
"queryValue": "",
|
||||||
|
"refresh": 1,
|
||||||
|
"regex": "",
|
||||||
|
"skipUrlSync": false,
|
||||||
|
"type": "datasource"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"time": {
|
||||||
|
"from": "now-1h",
|
||||||
|
"to": "now"
|
||||||
|
},
|
||||||
|
"timepicker": {},
|
||||||
|
"timezone": "",
|
||||||
|
"title": "Qbittorrent",
|
||||||
|
"uid": "eKyTETFMk",
|
||||||
|
"version": 1,
|
||||||
|
"weekStart": ""
|
||||||
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 209 KiB |
Generated
-624
@@ -1,624 +0,0 @@
|
|||||||
// Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
// For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt
|
|
||||||
|
|
||||||
// Coverage.py HTML report browser code.
|
|
||||||
/*jslint browser: true, sloppy: true, vars: true, plusplus: true, maxerr: 50, indent: 4 */
|
|
||||||
/*global coverage: true, document, window, $ */
|
|
||||||
|
|
||||||
coverage = {};
|
|
||||||
|
|
||||||
// General helpers
|
|
||||||
function debounce(callback, wait) {
|
|
||||||
let timeoutId = null;
|
|
||||||
return function(...args) {
|
|
||||||
clearTimeout(timeoutId);
|
|
||||||
timeoutId = setTimeout(() => {
|
|
||||||
callback.apply(this, args);
|
|
||||||
}, wait);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
function checkVisible(element) {
|
|
||||||
const rect = element.getBoundingClientRect();
|
|
||||||
const viewBottom = Math.max(document.documentElement.clientHeight, window.innerHeight);
|
|
||||||
const viewTop = 30;
|
|
||||||
return !(rect.bottom < viewTop || rect.top >= viewBottom);
|
|
||||||
}
|
|
||||||
|
|
||||||
function on_click(sel, fn) {
|
|
||||||
const elt = document.querySelector(sel);
|
|
||||||
if (elt) {
|
|
||||||
elt.addEventListener("click", fn);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Helpers for table sorting
|
|
||||||
function getCellValue(row, column = 0) {
|
|
||||||
const cell = row.cells[column] // nosemgrep: eslint.detect-object-injection
|
|
||||||
if (cell.childElementCount == 1) {
|
|
||||||
const child = cell.firstElementChild
|
|
||||||
if (child instanceof HTMLTimeElement && child.dateTime) {
|
|
||||||
return child.dateTime
|
|
||||||
} else if (child instanceof HTMLDataElement && child.value) {
|
|
||||||
return child.value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return cell.innerText || cell.textContent;
|
|
||||||
}
|
|
||||||
|
|
||||||
function rowComparator(rowA, rowB, column = 0) {
|
|
||||||
let valueA = getCellValue(rowA, column);
|
|
||||||
let valueB = getCellValue(rowB, column);
|
|
||||||
if (!isNaN(valueA) && !isNaN(valueB)) {
|
|
||||||
return valueA - valueB
|
|
||||||
}
|
|
||||||
return valueA.localeCompare(valueB, undefined, {numeric: true});
|
|
||||||
}
|
|
||||||
|
|
||||||
function sortColumn(th) {
|
|
||||||
// Get the current sorting direction of the selected header,
|
|
||||||
// clear state on other headers and then set the new sorting direction
|
|
||||||
const currentSortOrder = th.getAttribute("aria-sort");
|
|
||||||
[...th.parentElement.cells].forEach(header => header.setAttribute("aria-sort", "none"));
|
|
||||||
if (currentSortOrder === "none") {
|
|
||||||
th.setAttribute("aria-sort", th.dataset.defaultSortOrder || "ascending");
|
|
||||||
} else {
|
|
||||||
th.setAttribute("aria-sort", currentSortOrder === "ascending" ? "descending" : "ascending");
|
|
||||||
}
|
|
||||||
|
|
||||||
const column = [...th.parentElement.cells].indexOf(th)
|
|
||||||
|
|
||||||
// Sort all rows and afterwards append them in order to move them in the DOM
|
|
||||||
Array.from(th.closest("table").querySelectorAll("tbody tr"))
|
|
||||||
.sort((rowA, rowB) => rowComparator(rowA, rowB, column) * (th.getAttribute("aria-sort") === "ascending" ? 1 : -1))
|
|
||||||
.forEach(tr => tr.parentElement.appendChild(tr) );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find all the elements with data-shortcut attribute, and use them to assign a shortcut key.
|
|
||||||
coverage.assign_shortkeys = function () {
|
|
||||||
document.querySelectorAll("[data-shortcut]").forEach(element => {
|
|
||||||
document.addEventListener("keypress", event => {
|
|
||||||
if (event.target.tagName.toLowerCase() === "input") {
|
|
||||||
return; // ignore keypress from search filter
|
|
||||||
}
|
|
||||||
if (event.key === element.dataset.shortcut) {
|
|
||||||
element.click();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// Create the events for the filter box.
|
|
||||||
coverage.wire_up_filter = function () {
|
|
||||||
// Cache elements.
|
|
||||||
const table = document.querySelector("table.index");
|
|
||||||
const table_body_rows = table.querySelectorAll("tbody tr");
|
|
||||||
const no_rows = document.getElementById("no_rows");
|
|
||||||
|
|
||||||
// Observe filter keyevents.
|
|
||||||
document.getElementById("filter").addEventListener("input", debounce(event => {
|
|
||||||
// Keep running total of each metric, first index contains number of shown rows
|
|
||||||
const totals = new Array(table.rows[0].cells.length).fill(0);
|
|
||||||
// Accumulate the percentage as fraction
|
|
||||||
totals[totals.length - 1] = { "numer": 0, "denom": 0 }; // nosemgrep: eslint.detect-object-injection
|
|
||||||
|
|
||||||
// Hide / show elements.
|
|
||||||
table_body_rows.forEach(row => {
|
|
||||||
if (!row.cells[0].textContent.includes(event.target.value)) {
|
|
||||||
// hide
|
|
||||||
row.classList.add("hidden");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// show
|
|
||||||
row.classList.remove("hidden");
|
|
||||||
totals[0]++;
|
|
||||||
|
|
||||||
for (let column = 1; column < totals.length; column++) {
|
|
||||||
// Accumulate dynamic totals
|
|
||||||
cell = row.cells[column] // nosemgrep: eslint.detect-object-injection
|
|
||||||
if (column === totals.length - 1) {
|
|
||||||
// Last column contains percentage
|
|
||||||
const [numer, denom] = cell.dataset.ratio.split(" ");
|
|
||||||
totals[column]["numer"] += parseInt(numer, 10); // nosemgrep: eslint.detect-object-injection
|
|
||||||
totals[column]["denom"] += parseInt(denom, 10); // nosemgrep: eslint.detect-object-injection
|
|
||||||
} else {
|
|
||||||
totals[column] += parseInt(cell.textContent, 10); // nosemgrep: eslint.detect-object-injection
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Show placeholder if no rows will be displayed.
|
|
||||||
if (!totals[0]) {
|
|
||||||
// Show placeholder, hide table.
|
|
||||||
no_rows.style.display = "block";
|
|
||||||
table.style.display = "none";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Hide placeholder, show table.
|
|
||||||
no_rows.style.display = null;
|
|
||||||
table.style.display = null;
|
|
||||||
|
|
||||||
const footer = table.tFoot.rows[0];
|
|
||||||
// Calculate new dynamic sum values based on visible rows.
|
|
||||||
for (let column = 1; column < totals.length; column++) {
|
|
||||||
// Get footer cell element.
|
|
||||||
const cell = footer.cells[column]; // nosemgrep: eslint.detect-object-injection
|
|
||||||
|
|
||||||
// Set value into dynamic footer cell element.
|
|
||||||
if (column === totals.length - 1) {
|
|
||||||
// Percentage column uses the numerator and denominator,
|
|
||||||
// and adapts to the number of decimal places.
|
|
||||||
const match = /\.([0-9]+)/.exec(cell.textContent);
|
|
||||||
const places = match ? match[1].length : 0;
|
|
||||||
const { numer, denom } = totals[column]; // nosemgrep: eslint.detect-object-injection
|
|
||||||
cell.dataset.ratio = `${numer} ${denom}`;
|
|
||||||
// Check denom to prevent NaN if filtered files contain no statements
|
|
||||||
cell.textContent = denom
|
|
||||||
? `${(numer * 100 / denom).toFixed(places)}%`
|
|
||||||
: `${(100).toFixed(places)}%`;
|
|
||||||
} else {
|
|
||||||
cell.textContent = totals[column]; // nosemgrep: eslint.detect-object-injection
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
// Trigger change event on setup, to force filter on page refresh
|
|
||||||
// (filter value may still be present).
|
|
||||||
document.getElementById("filter").dispatchEvent(new Event("input"));
|
|
||||||
};
|
|
||||||
|
|
||||||
coverage.INDEX_SORT_STORAGE = "COVERAGE_INDEX_SORT_2";
|
|
||||||
|
|
||||||
// Loaded on index.html
|
|
||||||
coverage.index_ready = function () {
|
|
||||||
coverage.assign_shortkeys();
|
|
||||||
coverage.wire_up_filter();
|
|
||||||
document.querySelectorAll("[data-sortable] th[aria-sort]").forEach(
|
|
||||||
th => th.addEventListener("click", e => sortColumn(e.target))
|
|
||||||
);
|
|
||||||
|
|
||||||
// Look for a localStorage item containing previous sort settings:
|
|
||||||
const stored_list = localStorage.getItem(coverage.INDEX_SORT_STORAGE);
|
|
||||||
|
|
||||||
if (stored_list) {
|
|
||||||
const {column, direction} = JSON.parse(stored_list);
|
|
||||||
const th = document.querySelector("[data-sortable]").tHead.rows[0].cells[column]; // nosemgrep: eslint.detect-object-injection
|
|
||||||
th.setAttribute("aria-sort", direction === "ascending" ? "descending" : "ascending");
|
|
||||||
th.click()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Watch for page unload events so we can save the final sort settings:
|
|
||||||
window.addEventListener("unload", function () {
|
|
||||||
const th = document.querySelector('[data-sortable] th[aria-sort="ascending"], [data-sortable] [aria-sort="descending"]');
|
|
||||||
if (!th) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
localStorage.setItem(coverage.INDEX_SORT_STORAGE, JSON.stringify({
|
|
||||||
column: [...th.parentElement.cells].indexOf(th),
|
|
||||||
direction: th.getAttribute("aria-sort"),
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
|
|
||||||
on_click(".button_prev_file", coverage.to_prev_file);
|
|
||||||
on_click(".button_next_file", coverage.to_next_file);
|
|
||||||
|
|
||||||
on_click(".button_show_hide_help", coverage.show_hide_help);
|
|
||||||
};
|
|
||||||
|
|
||||||
// -- pyfile stuff --
|
|
||||||
|
|
||||||
coverage.LINE_FILTERS_STORAGE = "COVERAGE_LINE_FILTERS";
|
|
||||||
|
|
||||||
coverage.pyfile_ready = function () {
|
|
||||||
// If we're directed to a particular line number, highlight the line.
|
|
||||||
var frag = location.hash;
|
|
||||||
if (frag.length > 2 && frag[1] === "t") {
|
|
||||||
document.querySelector(frag).closest(".n").classList.add("highlight");
|
|
||||||
coverage.set_sel(parseInt(frag.substr(2), 10));
|
|
||||||
} else {
|
|
||||||
coverage.set_sel(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
on_click(".button_toggle_run", coverage.toggle_lines);
|
|
||||||
on_click(".button_toggle_mis", coverage.toggle_lines);
|
|
||||||
on_click(".button_toggle_exc", coverage.toggle_lines);
|
|
||||||
on_click(".button_toggle_par", coverage.toggle_lines);
|
|
||||||
|
|
||||||
on_click(".button_next_chunk", coverage.to_next_chunk_nicely);
|
|
||||||
on_click(".button_prev_chunk", coverage.to_prev_chunk_nicely);
|
|
||||||
on_click(".button_top_of_page", coverage.to_top);
|
|
||||||
on_click(".button_first_chunk", coverage.to_first_chunk);
|
|
||||||
|
|
||||||
on_click(".button_prev_file", coverage.to_prev_file);
|
|
||||||
on_click(".button_next_file", coverage.to_next_file);
|
|
||||||
on_click(".button_to_index", coverage.to_index);
|
|
||||||
|
|
||||||
on_click(".button_show_hide_help", coverage.show_hide_help);
|
|
||||||
|
|
||||||
coverage.filters = undefined;
|
|
||||||
try {
|
|
||||||
coverage.filters = localStorage.getItem(coverage.LINE_FILTERS_STORAGE);
|
|
||||||
} catch(err) {}
|
|
||||||
|
|
||||||
if (coverage.filters) {
|
|
||||||
coverage.filters = JSON.parse(coverage.filters);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
coverage.filters = {run: false, exc: true, mis: true, par: true};
|
|
||||||
}
|
|
||||||
|
|
||||||
for (cls in coverage.filters) {
|
|
||||||
coverage.set_line_visibilty(cls, coverage.filters[cls]); // nosemgrep: eslint.detect-object-injection
|
|
||||||
}
|
|
||||||
|
|
||||||
coverage.assign_shortkeys();
|
|
||||||
coverage.init_scroll_markers();
|
|
||||||
coverage.wire_up_sticky_header();
|
|
||||||
|
|
||||||
document.querySelectorAll("[id^=ctxs]").forEach(
|
|
||||||
cbox => cbox.addEventListener("click", coverage.expand_contexts)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Rebuild scroll markers when the window height changes.
|
|
||||||
window.addEventListener("resize", coverage.build_scroll_markers);
|
|
||||||
};
|
|
||||||
|
|
||||||
coverage.toggle_lines = function (event) {
|
|
||||||
const btn = event.target.closest("button");
|
|
||||||
const category = btn.value
|
|
||||||
const show = !btn.classList.contains("show_" + category);
|
|
||||||
coverage.set_line_visibilty(category, show);
|
|
||||||
coverage.build_scroll_markers();
|
|
||||||
coverage.filters[category] = show;
|
|
||||||
try {
|
|
||||||
localStorage.setItem(coverage.LINE_FILTERS_STORAGE, JSON.stringify(coverage.filters));
|
|
||||||
} catch(err) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
coverage.set_line_visibilty = function (category, should_show) {
|
|
||||||
const cls = "show_" + category;
|
|
||||||
const btn = document.querySelector(".button_toggle_" + category);
|
|
||||||
if (btn) {
|
|
||||||
if (should_show) {
|
|
||||||
document.querySelectorAll("#source ." + category).forEach(e => e.classList.add(cls));
|
|
||||||
btn.classList.add(cls);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
document.querySelectorAll("#source ." + category).forEach(e => e.classList.remove(cls));
|
|
||||||
btn.classList.remove(cls);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Return the nth line div.
|
|
||||||
coverage.line_elt = function (n) {
|
|
||||||
return document.getElementById("t" + n)?.closest("p");
|
|
||||||
};
|
|
||||||
|
|
||||||
// Set the selection. b and e are line numbers.
|
|
||||||
coverage.set_sel = function (b, e) {
|
|
||||||
// The first line selected.
|
|
||||||
coverage.sel_begin = b;
|
|
||||||
// The next line not selected.
|
|
||||||
coverage.sel_end = (e === undefined) ? b+1 : e;
|
|
||||||
};
|
|
||||||
|
|
||||||
coverage.to_top = function () {
|
|
||||||
coverage.set_sel(0, 1);
|
|
||||||
coverage.scroll_window(0);
|
|
||||||
};
|
|
||||||
|
|
||||||
coverage.to_first_chunk = function () {
|
|
||||||
coverage.set_sel(0, 1);
|
|
||||||
coverage.to_next_chunk();
|
|
||||||
};
|
|
||||||
|
|
||||||
coverage.to_prev_file = function () {
|
|
||||||
window.location = document.getElementById("prevFileLink").href;
|
|
||||||
}
|
|
||||||
|
|
||||||
coverage.to_next_file = function () {
|
|
||||||
window.location = document.getElementById("nextFileLink").href;
|
|
||||||
}
|
|
||||||
|
|
||||||
coverage.to_index = function () {
|
|
||||||
location.href = document.getElementById("indexLink").href;
|
|
||||||
}
|
|
||||||
|
|
||||||
coverage.show_hide_help = function () {
|
|
||||||
const helpCheck = document.getElementById("help_panel_state")
|
|
||||||
helpCheck.checked = !helpCheck.checked;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return a string indicating what kind of chunk this line belongs to,
|
|
||||||
// or null if not a chunk.
|
|
||||||
coverage.chunk_indicator = function (line_elt) {
|
|
||||||
const classes = line_elt?.className;
|
|
||||||
if (!classes) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
const match = classes.match(/\bshow_\w+\b/);
|
|
||||||
if (!match) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return match[0];
|
|
||||||
};
|
|
||||||
|
|
||||||
coverage.to_next_chunk = function () {
|
|
||||||
const c = coverage;
|
|
||||||
|
|
||||||
// Find the start of the next colored chunk.
|
|
||||||
var probe = c.sel_end;
|
|
||||||
var chunk_indicator, probe_line;
|
|
||||||
while (true) {
|
|
||||||
probe_line = c.line_elt(probe);
|
|
||||||
if (!probe_line) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
chunk_indicator = c.chunk_indicator(probe_line);
|
|
||||||
if (chunk_indicator) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
probe++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// There's a next chunk, `probe` points to it.
|
|
||||||
var begin = probe;
|
|
||||||
|
|
||||||
// Find the end of this chunk.
|
|
||||||
var next_indicator = chunk_indicator;
|
|
||||||
while (next_indicator === chunk_indicator) {
|
|
||||||
probe++;
|
|
||||||
probe_line = c.line_elt(probe);
|
|
||||||
next_indicator = c.chunk_indicator(probe_line);
|
|
||||||
}
|
|
||||||
c.set_sel(begin, probe);
|
|
||||||
c.show_selection();
|
|
||||||
};
|
|
||||||
|
|
||||||
coverage.to_prev_chunk = function () {
|
|
||||||
const c = coverage;
|
|
||||||
|
|
||||||
// Find the end of the prev colored chunk.
|
|
||||||
var probe = c.sel_begin-1;
|
|
||||||
var probe_line = c.line_elt(probe);
|
|
||||||
if (!probe_line) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var chunk_indicator = c.chunk_indicator(probe_line);
|
|
||||||
while (probe > 1 && !chunk_indicator) {
|
|
||||||
probe--;
|
|
||||||
probe_line = c.line_elt(probe);
|
|
||||||
if (!probe_line) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
chunk_indicator = c.chunk_indicator(probe_line);
|
|
||||||
}
|
|
||||||
|
|
||||||
// There's a prev chunk, `probe` points to its last line.
|
|
||||||
var end = probe+1;
|
|
||||||
|
|
||||||
// Find the beginning of this chunk.
|
|
||||||
var prev_indicator = chunk_indicator;
|
|
||||||
while (prev_indicator === chunk_indicator) {
|
|
||||||
probe--;
|
|
||||||
if (probe <= 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
probe_line = c.line_elt(probe);
|
|
||||||
prev_indicator = c.chunk_indicator(probe_line);
|
|
||||||
}
|
|
||||||
c.set_sel(probe+1, end);
|
|
||||||
c.show_selection();
|
|
||||||
};
|
|
||||||
|
|
||||||
// Returns 0, 1, or 2: how many of the two ends of the selection are on
|
|
||||||
// the screen right now?
|
|
||||||
coverage.selection_ends_on_screen = function () {
|
|
||||||
if (coverage.sel_begin === 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
const begin = coverage.line_elt(coverage.sel_begin);
|
|
||||||
const end = coverage.line_elt(coverage.sel_end-1);
|
|
||||||
|
|
||||||
return (
|
|
||||||
(checkVisible(begin) ? 1 : 0)
|
|
||||||
+ (checkVisible(end) ? 1 : 0)
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
coverage.to_next_chunk_nicely = function () {
|
|
||||||
if (coverage.selection_ends_on_screen() === 0) {
|
|
||||||
// The selection is entirely off the screen:
|
|
||||||
// Set the top line on the screen as selection.
|
|
||||||
|
|
||||||
// This will select the top-left of the viewport
|
|
||||||
// As this is most likely the span with the line number we take the parent
|
|
||||||
const line = document.elementFromPoint(0, 0).parentElement;
|
|
||||||
if (line.parentElement !== document.getElementById("source")) {
|
|
||||||
// The element is not a source line but the header or similar
|
|
||||||
coverage.select_line_or_chunk(1);
|
|
||||||
} else {
|
|
||||||
// We extract the line number from the id
|
|
||||||
coverage.select_line_or_chunk(parseInt(line.id.substring(1), 10));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
coverage.to_next_chunk();
|
|
||||||
};
|
|
||||||
|
|
||||||
coverage.to_prev_chunk_nicely = function () {
|
|
||||||
if (coverage.selection_ends_on_screen() === 0) {
|
|
||||||
// The selection is entirely off the screen:
|
|
||||||
// Set the lowest line on the screen as selection.
|
|
||||||
|
|
||||||
// This will select the bottom-left of the viewport
|
|
||||||
// As this is most likely the span with the line number we take the parent
|
|
||||||
const line = document.elementFromPoint(document.documentElement.clientHeight-1, 0).parentElement;
|
|
||||||
if (line.parentElement !== document.getElementById("source")) {
|
|
||||||
// The element is not a source line but the header or similar
|
|
||||||
coverage.select_line_or_chunk(coverage.lines_len);
|
|
||||||
} else {
|
|
||||||
// We extract the line number from the id
|
|
||||||
coverage.select_line_or_chunk(parseInt(line.id.substring(1), 10));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
coverage.to_prev_chunk();
|
|
||||||
};
|
|
||||||
|
|
||||||
// Select line number lineno, or if it is in a colored chunk, select the
|
|
||||||
// entire chunk
|
|
||||||
coverage.select_line_or_chunk = function (lineno) {
|
|
||||||
var c = coverage;
|
|
||||||
var probe_line = c.line_elt(lineno);
|
|
||||||
if (!probe_line) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var the_indicator = c.chunk_indicator(probe_line);
|
|
||||||
if (the_indicator) {
|
|
||||||
// The line is in a highlighted chunk.
|
|
||||||
// Search backward for the first line.
|
|
||||||
var probe = lineno;
|
|
||||||
var indicator = the_indicator;
|
|
||||||
while (probe > 0 && indicator === the_indicator) {
|
|
||||||
probe--;
|
|
||||||
probe_line = c.line_elt(probe);
|
|
||||||
if (!probe_line) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
indicator = c.chunk_indicator(probe_line);
|
|
||||||
}
|
|
||||||
var begin = probe + 1;
|
|
||||||
|
|
||||||
// Search forward for the last line.
|
|
||||||
probe = lineno;
|
|
||||||
indicator = the_indicator;
|
|
||||||
while (indicator === the_indicator) {
|
|
||||||
probe++;
|
|
||||||
probe_line = c.line_elt(probe);
|
|
||||||
indicator = c.chunk_indicator(probe_line);
|
|
||||||
}
|
|
||||||
|
|
||||||
coverage.set_sel(begin, probe);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
coverage.set_sel(lineno);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
coverage.show_selection = function () {
|
|
||||||
// Highlight the lines in the chunk
|
|
||||||
document.querySelectorAll("#source .highlight").forEach(e => e.classList.remove("highlight"));
|
|
||||||
for (let probe = coverage.sel_begin; probe < coverage.sel_end; probe++) {
|
|
||||||
coverage.line_elt(probe).querySelector(".n").classList.add("highlight");
|
|
||||||
}
|
|
||||||
|
|
||||||
coverage.scroll_to_selection();
|
|
||||||
};
|
|
||||||
|
|
||||||
coverage.scroll_to_selection = function () {
|
|
||||||
// Scroll the page if the chunk isn't fully visible.
|
|
||||||
if (coverage.selection_ends_on_screen() < 2) {
|
|
||||||
const element = coverage.line_elt(coverage.sel_begin);
|
|
||||||
coverage.scroll_window(element.offsetTop - 60);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
coverage.scroll_window = function (to_pos) {
|
|
||||||
window.scroll({top: to_pos, behavior: "smooth"});
|
|
||||||
};
|
|
||||||
|
|
||||||
coverage.init_scroll_markers = function () {
|
|
||||||
// Init some variables
|
|
||||||
coverage.lines_len = document.querySelectorAll("#source > p").length;
|
|
||||||
|
|
||||||
// Build html
|
|
||||||
coverage.build_scroll_markers();
|
|
||||||
};
|
|
||||||
|
|
||||||
coverage.build_scroll_markers = function () {
|
|
||||||
const temp_scroll_marker = document.getElementById("scroll_marker")
|
|
||||||
if (temp_scroll_marker) temp_scroll_marker.remove();
|
|
||||||
// Don't build markers if the window has no scroll bar.
|
|
||||||
if (document.body.scrollHeight <= window.innerHeight) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const marker_scale = window.innerHeight / document.body.scrollHeight;
|
|
||||||
const line_height = Math.min(Math.max(3, window.innerHeight / coverage.lines_len), 10);
|
|
||||||
|
|
||||||
let previous_line = -99, last_mark, last_top;
|
|
||||||
|
|
||||||
const scroll_marker = document.createElement("div");
|
|
||||||
scroll_marker.id = "scroll_marker";
|
|
||||||
document.getElementById("source").querySelectorAll(
|
|
||||||
"p.show_run, p.show_mis, p.show_exc, p.show_exc, p.show_par"
|
|
||||||
).forEach(element => {
|
|
||||||
const line_top = Math.floor(element.offsetTop * marker_scale);
|
|
||||||
const line_number = parseInt(element.querySelector(".n a").id.substr(1));
|
|
||||||
|
|
||||||
if (line_number === previous_line + 1) {
|
|
||||||
// If this solid missed block just make previous mark higher.
|
|
||||||
last_mark.style.height = `${line_top + line_height - last_top}px`;
|
|
||||||
} else {
|
|
||||||
// Add colored line in scroll_marker block.
|
|
||||||
last_mark = document.createElement("div");
|
|
||||||
last_mark.id = `m${line_number}`;
|
|
||||||
last_mark.classList.add("marker");
|
|
||||||
last_mark.style.height = `${line_height}px`;
|
|
||||||
last_mark.style.top = `${line_top}px`;
|
|
||||||
scroll_marker.append(last_mark);
|
|
||||||
last_top = line_top;
|
|
||||||
}
|
|
||||||
|
|
||||||
previous_line = line_number;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Append last to prevent layout calculation
|
|
||||||
document.body.append(scroll_marker);
|
|
||||||
};
|
|
||||||
|
|
||||||
coverage.wire_up_sticky_header = function () {
|
|
||||||
const header = document.querySelector("header");
|
|
||||||
const header_bottom = (
|
|
||||||
header.querySelector(".content h2").getBoundingClientRect().top -
|
|
||||||
header.getBoundingClientRect().top
|
|
||||||
);
|
|
||||||
|
|
||||||
function updateHeader() {
|
|
||||||
if (window.scrollY > header_bottom) {
|
|
||||||
header.classList.add("sticky");
|
|
||||||
} else {
|
|
||||||
header.classList.remove("sticky");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
window.addEventListener("scroll", updateHeader);
|
|
||||||
updateHeader();
|
|
||||||
};
|
|
||||||
|
|
||||||
coverage.expand_contexts = function (e) {
|
|
||||||
var ctxs = e.target.parentNode.querySelector(".ctxs");
|
|
||||||
|
|
||||||
if (!ctxs.classList.contains("expanded")) {
|
|
||||||
var ctxs_text = ctxs.textContent;
|
|
||||||
var width = Number(ctxs_text[0]);
|
|
||||||
ctxs.textContent = "";
|
|
||||||
for (var i = 1; i < ctxs_text.length; i += width) {
|
|
||||||
key = ctxs_text.substring(i, i + width).trim();
|
|
||||||
ctxs.appendChild(document.createTextNode(contexts[key]));
|
|
||||||
ctxs.appendChild(document.createElement("br"));
|
|
||||||
}
|
|
||||||
ctxs.classList.add("expanded");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
document.addEventListener("DOMContentLoaded", () => {
|
|
||||||
if (document.body.classList.contains("indexfile")) {
|
|
||||||
coverage.index_ready();
|
|
||||||
} else {
|
|
||||||
coverage.pyfile_ready();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
-406
@@ -1,406 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
||||||
<title>Coverage for qbittorrent_exporter/exporter.py: 68%</title>
|
|
||||||
<link rel="icon" sizes="32x32" href="favicon_32.png">
|
|
||||||
<link rel="stylesheet" href="style.css" type="text/css">
|
|
||||||
<script type="text/javascript" src="coverage_html.js" defer></script>
|
|
||||||
</head>
|
|
||||||
<body class="pyfile">
|
|
||||||
<header>
|
|
||||||
<div class="content">
|
|
||||||
<h1>
|
|
||||||
<span class="text">Coverage for </span><b>qbittorrent_exporter/exporter.py</b>:
|
|
||||||
<span class="pc_cov">68%</span>
|
|
||||||
</h1>
|
|
||||||
<aside id="help_panel_wrapper">
|
|
||||||
<input id="help_panel_state" type="checkbox">
|
|
||||||
<label for="help_panel_state">
|
|
||||||
<img id="keyboard_icon" src="keybd_closed.png" alt="Show/hide keyboard shortcuts" />
|
|
||||||
</label>
|
|
||||||
<div id="help_panel">
|
|
||||||
<p class="legend">Shortcuts on this page</p>
|
|
||||||
<div class="keyhelp">
|
|
||||||
<p>
|
|
||||||
<kbd>r</kbd>
|
|
||||||
<kbd>m</kbd>
|
|
||||||
<kbd>x</kbd>
|
|
||||||
toggle line displays
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<kbd>j</kbd>
|
|
||||||
<kbd>k</kbd>
|
|
||||||
next/prev highlighted chunk
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<kbd>0</kbd> (zero) top of page
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<kbd>1</kbd> (one) first highlighted chunk
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<kbd>[</kbd>
|
|
||||||
<kbd>]</kbd>
|
|
||||||
prev/next file
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<kbd>u</kbd> up to the index
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<kbd>?</kbd> show/hide this help
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</aside>
|
|
||||||
<h2>
|
|
||||||
<span class="text">132 statements </span>
|
|
||||||
<button type="button" class="run button_toggle_run" value="run" data-shortcut="r" title="Toggle lines run">90<span class="text"> run</span></button>
|
|
||||||
<button type="button" class="mis show_mis button_toggle_mis" value="mis" data-shortcut="m" title="Toggle lines missing">42<span class="text"> missing</span></button>
|
|
||||||
<button type="button" class="exc show_exc button_toggle_exc" value="exc" data-shortcut="x" title="Toggle lines excluded">0<span class="text"> excluded</span></button>
|
|
||||||
</h2>
|
|
||||||
<p class="text">
|
|
||||||
<a id="prevFileLink" class="nav" href="index.html">« prev</a>
|
|
||||||
<a id="indexLink" class="nav" href="index.html">^ index</a>
|
|
||||||
<a id="nextFileLink" class="nav" href="index.html">» next</a>
|
|
||||||
|
|
||||||
<a class="nav" href="https://coverage.readthedocs.io/en/7.3.2">coverage.py v7.3.2</a>,
|
|
||||||
created at 2023-12-10 09:17 +0000
|
|
||||||
</p>
|
|
||||||
<aside class="hidden">
|
|
||||||
<button type="button" class="button_next_chunk" data-shortcut="j"/>
|
|
||||||
<button type="button" class="button_prev_chunk" data-shortcut="k"/>
|
|
||||||
<button type="button" class="button_top_of_page" data-shortcut="0"/>
|
|
||||||
<button type="button" class="button_first_chunk" data-shortcut="1"/>
|
|
||||||
<button type="button" class="button_prev_file" data-shortcut="["/>
|
|
||||||
<button type="button" class="button_next_file" data-shortcut="]"/>
|
|
||||||
<button type="button" class="button_to_index" data-shortcut="u"/>
|
|
||||||
<button type="button" class="button_show_hide_help" data-shortcut="?"/>
|
|
||||||
</aside>
|
|
||||||
</div>
|
|
||||||
</header>
|
|
||||||
<main id="source">
|
|
||||||
<p class="run"><span class="n"><a id="t1" href="#t1">1</a></span><span class="t"><span class="key">import</span> <span class="nam">faulthandler</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t2" href="#t2">2</a></span><span class="t"><span class="key">import</span> <span class="nam">logging</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t3" href="#t3">3</a></span><span class="t"><span class="key">import</span> <span class="nam">os</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t4" href="#t4">4</a></span><span class="t"><span class="key">import</span> <span class="nam">signal</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t5" href="#t5">5</a></span><span class="t"><span class="key">import</span> <span class="nam">sys</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t6" href="#t6">6</a></span><span class="t"><span class="key">import</span> <span class="nam">time</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t7" href="#t7">7</a></span><span class="t"><span class="key">from</span> <span class="nam">dataclasses</span> <span class="key">import</span> <span class="nam">dataclass</span><span class="op">,</span> <span class="nam">field</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t8" href="#t8">8</a></span><span class="t"><span class="key">from</span> <span class="nam">enum</span> <span class="key">import</span> <span class="nam">StrEnum</span><span class="op">,</span> <span class="nam">auto</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t9" href="#t9">9</a></span><span class="t"><span class="key">from</span> <span class="nam">typing</span> <span class="key">import</span> <span class="nam">Any</span><span class="op">,</span> <span class="nam">Iterable</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t10" href="#t10">10</a></span><span class="t"> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t11" href="#t11">11</a></span><span class="t"><span class="key">from</span> <span class="nam">prometheus_client</span> <span class="key">import</span> <span class="nam">start_http_server</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t12" href="#t12">12</a></span><span class="t"><span class="key">from</span> <span class="nam">prometheus_client</span><span class="op">.</span><span class="nam">core</span> <span class="key">import</span> <span class="nam">REGISTRY</span><span class="op">,</span> <span class="nam">CounterMetricFamily</span><span class="op">,</span> <span class="nam">GaugeMetricFamily</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t13" href="#t13">13</a></span><span class="t"><span class="key">from</span> <span class="nam">pythonjsonlogger</span> <span class="key">import</span> <span class="nam">jsonlogger</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t14" href="#t14">14</a></span><span class="t"><span class="key">from</span> <span class="nam">qbittorrentapi</span> <span class="key">import</span> <span class="nam">Client</span><span class="op">,</span> <span class="nam">TorrentStates</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t15" href="#t15">15</a></span><span class="t"> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t16" href="#t16">16</a></span><span class="t"><span class="com"># Enable dumps on stderr in case of segfault</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t17" href="#t17">17</a></span><span class="t"><span class="nam">faulthandler</span><span class="op">.</span><span class="nam">enable</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t18" href="#t18">18</a></span><span class="t"><span class="nam">logger</span> <span class="op">=</span> <span class="nam">logging</span><span class="op">.</span><span class="nam">getLogger</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t19" href="#t19">19</a></span><span class="t"> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t20" href="#t20">20</a></span><span class="t"> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t21" href="#t21">21</a></span><span class="t"><span class="key">class</span> <span class="nam">MetricType</span><span class="op">(</span><span class="nam">StrEnum</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t22" href="#t22">22</a></span><span class="t"> <span class="str">"""</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t23" href="#t23">23</a></span><span class="t"><span class="str"> Represents possible metric types (used in this project).</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t24" href="#t24">24</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t25" href="#t25">25</a></span><span class="t"> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t26" href="#t26">26</a></span><span class="t"> <span class="nam">GAUGE</span> <span class="op">=</span> <span class="nam">auto</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t27" href="#t27">27</a></span><span class="t"> <span class="nam">COUNTER</span> <span class="op">=</span> <span class="nam">auto</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t28" href="#t28">28</a></span><span class="t"> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t29" href="#t29">29</a></span><span class="t"> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t30" href="#t30">30</a></span><span class="t"><span class="op">@</span><span class="nam">dataclass</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t31" href="#t31">31</a></span><span class="t"><span class="key">class</span> <span class="nam">Metric</span><span class="op">:</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t32" href="#t32">32</a></span><span class="t"> <span class="str">"""</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t33" href="#t33">33</a></span><span class="t"><span class="str"> Contains data and metadata about a single counter or gauge.</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t34" href="#t34">34</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t35" href="#t35">35</a></span><span class="t"> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t36" href="#t36">36</a></span><span class="t"> <span class="nam">name</span><span class="op">:</span> <span class="nam">str</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t37" href="#t37">37</a></span><span class="t"> <span class="nam">value</span><span class="op">:</span> <span class="nam">Any</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t38" href="#t38">38</a></span><span class="t"> <span class="nam">labels</span><span class="op">:</span> <span class="nam">dict</span><span class="op">[</span><span class="nam">str</span><span class="op">,</span> <span class="nam">str</span><span class="op">]</span> <span class="op">=</span> <span class="nam">field</span><span class="op">(</span><span class="nam">default_factory</span><span class="op">=</span><span class="key">lambda</span><span class="op">:</span> <span class="op">{</span><span class="op">}</span><span class="op">)</span> <span class="com"># Default to empty dict</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t39" href="#t39">39</a></span><span class="t"> <span class="nam">help_text</span><span class="op">:</span> <span class="nam">str</span> <span class="op">=</span> <span class="str">""</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t40" href="#t40">40</a></span><span class="t"> <span class="nam">metric_type</span><span class="op">:</span> <span class="nam">MetricType</span> <span class="op">=</span> <span class="nam">MetricType</span><span class="op">.</span><span class="nam">GAUGE</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t41" href="#t41">41</a></span><span class="t"> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t42" href="#t42">42</a></span><span class="t"> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t43" href="#t43">43</a></span><span class="t"><span class="key">class</span> <span class="nam">QbittorrentMetricsCollector</span><span class="op">:</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t44" href="#t44">44</a></span><span class="t"> <span class="key">def</span> <span class="nam">__init__</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">config</span><span class="op">:</span> <span class="nam">dict</span><span class="op">)</span> <span class="op">-></span> <span class="key">None</span><span class="op">:</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t45" href="#t45">45</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">config</span> <span class="op">=</span> <span class="nam">config</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t46" href="#t46">46</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">client</span> <span class="op">=</span> <span class="nam">Client</span><span class="op">(</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t47" href="#t47">47</a></span><span class="t"> <span class="nam">host</span><span class="op">=</span><span class="nam">config</span><span class="op">[</span><span class="str">"host"</span><span class="op">]</span><span class="op">,</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t48" href="#t48">48</a></span><span class="t"> <span class="nam">port</span><span class="op">=</span><span class="nam">config</span><span class="op">[</span><span class="str">"port"</span><span class="op">]</span><span class="op">,</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t49" href="#t49">49</a></span><span class="t"> <span class="nam">username</span><span class="op">=</span><span class="nam">config</span><span class="op">[</span><span class="str">"username"</span><span class="op">]</span><span class="op">,</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t50" href="#t50">50</a></span><span class="t"> <span class="nam">password</span><span class="op">=</span><span class="nam">config</span><span class="op">[</span><span class="str">"password"</span><span class="op">]</span><span class="op">,</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t51" href="#t51">51</a></span><span class="t"> <span class="nam">VERIFY_WEBUI_CERTIFICATE</span><span class="op">=</span><span class="nam">config</span><span class="op">[</span><span class="str">"verify_webui_certificate"</span><span class="op">]</span><span class="op">,</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t52" href="#t52">52</a></span><span class="t"> <span class="op">)</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t53" href="#t53">53</a></span><span class="t"> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t54" href="#t54">54</a></span><span class="t"> <span class="key">def</span> <span class="nam">collect</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span> <span class="op">-></span> <span class="nam">Iterable</span><span class="op">[</span><span class="nam">GaugeMetricFamily</span> <span class="op">|</span> <span class="nam">CounterMetricFamily</span><span class="op">]</span><span class="op">:</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t55" href="#t55">55</a></span><span class="t"> <span class="str">"""</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t56" href="#t56">56</a></span><span class="t"><span class="str"> Yields Prometheus gauges and counters from metrics collected from qbittorrent.</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t57" href="#t57">57</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t58" href="#t58">58</a></span><span class="t"> <span class="nam">metrics</span><span class="op">:</span> <span class="nam">list</span><span class="op">[</span><span class="nam">Metric</span><span class="op">]</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">get_qbittorrent_metrics</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t59" href="#t59">59</a></span><span class="t"> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t60" href="#t60">60</a></span><span class="t"> <span class="key">for</span> <span class="nam">metric</span> <span class="key">in</span> <span class="nam">metrics</span><span class="op">:</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t61" href="#t61">61</a></span><span class="t"> <span class="key">if</span> <span class="nam">metric</span><span class="op">.</span><span class="nam">metric_type</span> <span class="op">==</span> <span class="nam">MetricType</span><span class="op">.</span><span class="nam">COUNTER</span><span class="op">:</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t62" href="#t62">62</a></span><span class="t"> <span class="nam">prom_metric</span> <span class="op">=</span> <span class="nam">CounterMetricFamily</span><span class="op">(</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t63" href="#t63">63</a></span><span class="t"> <span class="nam">metric</span><span class="op">.</span><span class="nam">name</span><span class="op">,</span> <span class="nam">metric</span><span class="op">.</span><span class="nam">help_text</span><span class="op">,</span> <span class="nam">labels</span><span class="op">=</span><span class="nam">list</span><span class="op">(</span><span class="nam">metric</span><span class="op">.</span><span class="nam">labels</span><span class="op">.</span><span class="nam">keys</span><span class="op">(</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t64" href="#t64">64</a></span><span class="t"> <span class="op">)</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t65" href="#t65">65</a></span><span class="t"> <span class="key">else</span><span class="op">:</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t66" href="#t66">66</a></span><span class="t"> <span class="nam">prom_metric</span> <span class="op">=</span> <span class="nam">GaugeMetricFamily</span><span class="op">(</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t67" href="#t67">67</a></span><span class="t"> <span class="nam">metric</span><span class="op">.</span><span class="nam">name</span><span class="op">,</span> <span class="nam">metric</span><span class="op">.</span><span class="nam">help_text</span><span class="op">,</span> <span class="nam">labels</span><span class="op">=</span><span class="nam">list</span><span class="op">(</span><span class="nam">metric</span><span class="op">.</span><span class="nam">labels</span><span class="op">.</span><span class="nam">keys</span><span class="op">(</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t68" href="#t68">68</a></span><span class="t"> <span class="op">)</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t69" href="#t69">69</a></span><span class="t"> <span class="nam">prom_metric</span><span class="op">.</span><span class="nam">add_metric</span><span class="op">(</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t70" href="#t70">70</a></span><span class="t"> <span class="nam">value</span><span class="op">=</span><span class="nam">metric</span><span class="op">.</span><span class="nam">value</span><span class="op">,</span> <span class="nam">labels</span><span class="op">=</span><span class="nam">list</span><span class="op">(</span><span class="nam">metric</span><span class="op">.</span><span class="nam">labels</span><span class="op">.</span><span class="nam">values</span><span class="op">(</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t71" href="#t71">71</a></span><span class="t"> <span class="op">)</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t72" href="#t72">72</a></span><span class="t"> <span class="key">yield</span> <span class="nam">prom_metric</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t73" href="#t73">73</a></span><span class="t"> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t74" href="#t74">74</a></span><span class="t"> <span class="key">def</span> <span class="nam">get_qbittorrent_metrics</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span> <span class="op">-></span> <span class="nam">list</span><span class="op">[</span><span class="nam">Metric</span><span class="op">]</span><span class="op">:</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t75" href="#t75">75</a></span><span class="t"> <span class="str">"""</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t76" href="#t76">76</a></span><span class="t"><span class="str"> Calls and combines qbittorrent state metrics with torrent metrics.</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t77" href="#t77">77</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t78" href="#t78">78</a></span><span class="t"> <span class="nam">metrics</span><span class="op">:</span> <span class="nam">list</span><span class="op">[</span><span class="nam">Metric</span><span class="op">]</span> <span class="op">=</span> <span class="op">[</span><span class="op">]</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t79" href="#t79">79</a></span><span class="t"> <span class="nam">metrics</span><span class="op">.</span><span class="nam">extend</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">_get_qbittorrent_status_metrics</span><span class="op">(</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t80" href="#t80">80</a></span><span class="t"> <span class="nam">metrics</span><span class="op">.</span><span class="nam">extend</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">_get_qbittorrent_torrent_tags_metrics</span><span class="op">(</span><span class="op">)</span><span class="op">)</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t81" href="#t81">81</a></span><span class="t"> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t82" href="#t82">82</a></span><span class="t"> <span class="key">return</span> <span class="nam">metrics</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t83" href="#t83">83</a></span><span class="t"> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t84" href="#t84">84</a></span><span class="t"> <span class="key">def</span> <span class="nam">_get_qbittorrent_status_metrics</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span> <span class="op">-></span> <span class="nam">list</span><span class="op">[</span><span class="nam">Metric</span><span class="op">]</span><span class="op">:</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t85" href="#t85">85</a></span><span class="t"> <span class="str">"""</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t86" href="#t86">86</a></span><span class="t"><span class="str"> Returns metrics about the state of the qbittorrent server.</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t87" href="#t87">87</a></span><span class="t"><span class="str"> """</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t88" href="#t88">88</a></span><span class="t"> <span class="nam">response</span><span class="op">:</span> <span class="nam">dict</span><span class="op">[</span><span class="nam">str</span><span class="op">,</span> <span class="nam">Any</span><span class="op">]</span> <span class="op">=</span> <span class="op">{</span><span class="op">}</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t89" href="#t89">89</a></span><span class="t"> <span class="nam">version</span><span class="op">:</span> <span class="nam">str</span> <span class="op">=</span> <span class="str">""</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t90" href="#t90">90</a></span><span class="t"> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t91" href="#t91">91</a></span><span class="t"> <span class="com"># Fetch data from API</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t92" href="#t92">92</a></span><span class="t"> <span class="key">try</span><span class="op">:</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t93" href="#t93">93</a></span><span class="t"> <span class="nam">response</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">client</span><span class="op">.</span><span class="nam">transfer</span><span class="op">.</span><span class="nam">info</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t94" href="#t94">94</a></span><span class="t"> <span class="nam">version</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">client</span><span class="op">.</span><span class="nam">app</span><span class="op">.</span><span class="nam">version</span> </span><span class="r"></span></p>
|
|
||||||
<p class="mis show_mis"><span class="n"><a id="t95" href="#t95">95</a></span><span class="t"> <span class="key">except</span> <span class="nam">Exception</span> <span class="key">as</span> <span class="nam">e</span><span class="op">:</span> </span><span class="r"></span></p>
|
|
||||||
<p class="mis show_mis"><span class="n"><a id="t96" href="#t96">96</a></span><span class="t"> <span class="nam">logger</span><span class="op">.</span><span class="nam">error</span><span class="op">(</span><span class="str">f"Couldn't get server info: {e}"</span><span class="op">)</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t97" href="#t97">97</a></span><span class="t"> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t98" href="#t98">98</a></span><span class="t"> <span class="key">return</span> <span class="op">[</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t99" href="#t99">99</a></span><span class="t"> <span class="nam">Metric</span><span class="op">(</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t100" href="#t100">100</a></span><span class="t"> <span class="nam">name</span><span class="op">=</span><span class="str">f"{self.config['metrics_prefix']}_up"</span><span class="op">,</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t101" href="#t101">101</a></span><span class="t"> <span class="nam">value</span><span class="op">=</span><span class="nam">bool</span><span class="op">(</span><span class="nam">response</span><span class="op">)</span><span class="op">,</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t102" href="#t102">102</a></span><span class="t"> <span class="nam">labels</span><span class="op">=</span><span class="op">{</span><span class="str">"version"</span><span class="op">:</span> <span class="nam">version</span><span class="op">}</span><span class="op">,</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t103" href="#t103">103</a></span><span class="t"> <span class="nam">help_text</span><span class="op">=</span><span class="op">(</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t104" href="#t104">104</a></span><span class="t"> <span class="str">"Whether the qBittorrent server is answering requests from this"</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t105" href="#t105">105</a></span><span class="t"> <span class="str">" exporter. A `version` label with the server version is added."</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t106" href="#t106">106</a></span><span class="t"> <span class="op">)</span><span class="op">,</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t107" href="#t107">107</a></span><span class="t"> <span class="op">)</span><span class="op">,</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t108" href="#t108">108</a></span><span class="t"> <span class="nam">Metric</span><span class="op">(</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t109" href="#t109">109</a></span><span class="t"> <span class="nam">name</span><span class="op">=</span><span class="str">f"{self.config['metrics_prefix']}_connected"</span><span class="op">,</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t110" href="#t110">110</a></span><span class="t"> <span class="nam">value</span><span class="op">=</span><span class="nam">response</span><span class="op">.</span><span class="nam">get</span><span class="op">(</span><span class="str">"connection_status"</span><span class="op">,</span> <span class="str">""</span><span class="op">)</span> <span class="op">==</span> <span class="str">"connected"</span><span class="op">,</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t111" href="#t111">111</a></span><span class="t"> <span class="nam">labels</span><span class="op">=</span><span class="op">{</span><span class="op">}</span><span class="op">,</span> <span class="com"># no labels in the example</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t112" href="#t112">112</a></span><span class="t"> <span class="nam">help_text</span><span class="op">=</span><span class="op">(</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t113" href="#t113">113</a></span><span class="t"> <span class="str">"Whether the qBittorrent server is connected to the Bittorrent"</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t114" href="#t114">114</a></span><span class="t"> <span class="str">" network."</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t115" href="#t115">115</a></span><span class="t"> <span class="op">)</span><span class="op">,</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t116" href="#t116">116</a></span><span class="t"> <span class="op">)</span><span class="op">,</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t117" href="#t117">117</a></span><span class="t"> <span class="nam">Metric</span><span class="op">(</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t118" href="#t118">118</a></span><span class="t"> <span class="nam">name</span><span class="op">=</span><span class="str">f"{self.config['metrics_prefix']}_firewalled"</span><span class="op">,</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t119" href="#t119">119</a></span><span class="t"> <span class="nam">value</span><span class="op">=</span><span class="nam">response</span><span class="op">.</span><span class="nam">get</span><span class="op">(</span><span class="str">"connection_status"</span><span class="op">,</span> <span class="str">""</span><span class="op">)</span> <span class="op">==</span> <span class="str">"firewalled"</span><span class="op">,</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t120" href="#t120">120</a></span><span class="t"> <span class="nam">labels</span><span class="op">=</span><span class="op">{</span><span class="op">}</span><span class="op">,</span> <span class="com"># no labels in the example</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t121" href="#t121">121</a></span><span class="t"> <span class="nam">help_text</span><span class="op">=</span><span class="op">(</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t122" href="#t122">122</a></span><span class="t"> <span class="str">"Whether the qBittorrent server is connected to the Bittorrent"</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t123" href="#t123">123</a></span><span class="t"> <span class="str">" network but is behind a firewall."</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t124" href="#t124">124</a></span><span class="t"> <span class="op">)</span><span class="op">,</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t125" href="#t125">125</a></span><span class="t"> <span class="op">)</span><span class="op">,</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t126" href="#t126">126</a></span><span class="t"> <span class="nam">Metric</span><span class="op">(</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t127" href="#t127">127</a></span><span class="t"> <span class="nam">name</span><span class="op">=</span><span class="str">f"{self.config['metrics_prefix']}_dht_nodes"</span><span class="op">,</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t128" href="#t128">128</a></span><span class="t"> <span class="nam">value</span><span class="op">=</span><span class="nam">response</span><span class="op">.</span><span class="nam">get</span><span class="op">(</span><span class="str">"dht_nodes"</span><span class="op">,</span> <span class="num">0</span><span class="op">)</span><span class="op">,</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t129" href="#t129">129</a></span><span class="t"> <span class="nam">labels</span><span class="op">=</span><span class="op">{</span><span class="op">}</span><span class="op">,</span> <span class="com"># no labels in the example</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t130" href="#t130">130</a></span><span class="t"> <span class="nam">help_text</span><span class="op">=</span><span class="str">"Number of DHT nodes connected to."</span><span class="op">,</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t131" href="#t131">131</a></span><span class="t"> <span class="op">)</span><span class="op">,</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t132" href="#t132">132</a></span><span class="t"> <span class="nam">Metric</span><span class="op">(</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t133" href="#t133">133</a></span><span class="t"> <span class="nam">name</span><span class="op">=</span><span class="str">f"{self.config['metrics_prefix']}_dl_info_data"</span><span class="op">,</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t134" href="#t134">134</a></span><span class="t"> <span class="nam">value</span><span class="op">=</span><span class="nam">response</span><span class="op">.</span><span class="nam">get</span><span class="op">(</span><span class="str">"dl_info_data"</span><span class="op">,</span> <span class="num">0</span><span class="op">)</span><span class="op">,</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t135" href="#t135">135</a></span><span class="t"> <span class="nam">labels</span><span class="op">=</span><span class="op">{</span><span class="op">}</span><span class="op">,</span> <span class="com"># no labels in the example</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t136" href="#t136">136</a></span><span class="t"> <span class="nam">help_text</span><span class="op">=</span><span class="str">"Data downloaded since the server started, in bytes."</span><span class="op">,</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t137" href="#t137">137</a></span><span class="t"> <span class="nam">metric_type</span><span class="op">=</span><span class="nam">MetricType</span><span class="op">.</span><span class="nam">COUNTER</span><span class="op">,</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t138" href="#t138">138</a></span><span class="t"> <span class="op">)</span><span class="op">,</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t139" href="#t139">139</a></span><span class="t"> <span class="nam">Metric</span><span class="op">(</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t140" href="#t140">140</a></span><span class="t"> <span class="nam">name</span><span class="op">=</span><span class="str">f"{self.config['metrics_prefix']}_up_info_data"</span><span class="op">,</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t141" href="#t141">141</a></span><span class="t"> <span class="nam">value</span><span class="op">=</span><span class="nam">response</span><span class="op">.</span><span class="nam">get</span><span class="op">(</span><span class="str">"up_info_data"</span><span class="op">,</span> <span class="num">0</span><span class="op">)</span><span class="op">,</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t142" href="#t142">142</a></span><span class="t"> <span class="nam">labels</span><span class="op">=</span><span class="op">{</span><span class="op">}</span><span class="op">,</span> <span class="com"># no labels in the example</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t143" href="#t143">143</a></span><span class="t"> <span class="nam">help_text</span><span class="op">=</span><span class="str">"Data uploaded since the server started, in bytes."</span><span class="op">,</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t144" href="#t144">144</a></span><span class="t"> <span class="nam">metric_type</span><span class="op">=</span><span class="nam">MetricType</span><span class="op">.</span><span class="nam">COUNTER</span><span class="op">,</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t145" href="#t145">145</a></span><span class="t"> <span class="op">)</span><span class="op">,</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t146" href="#t146">146</a></span><span class="t"> <span class="op">]</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t147" href="#t147">147</a></span><span class="t"> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t148" href="#t148">148</a></span><span class="t"> <span class="key">def</span> <span class="nam">_fetch_categories</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span> <span class="op">-></span> <span class="nam">dict</span><span class="op">:</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t149" href="#t149">149</a></span><span class="t"> <span class="str">"""Fetches all categories in use from qbittorrent."""</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t150" href="#t150">150</a></span><span class="t"> <span class="key">try</span><span class="op">:</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t151" href="#t151">151</a></span><span class="t"> <span class="nam">categories</span> <span class="op">=</span> <span class="nam">dict</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">client</span><span class="op">.</span><span class="nam">torrent_categories</span><span class="op">.</span><span class="nam">categories</span><span class="op">)</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t152" href="#t152">152</a></span><span class="t"> <span class="key">for</span> <span class="nam">key</span><span class="op">,</span> <span class="nam">value</span> <span class="key">in</span> <span class="nam">categories</span><span class="op">.</span><span class="nam">items</span><span class="op">(</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t153" href="#t153">153</a></span><span class="t"> <span class="nam">categories</span><span class="op">[</span><span class="nam">key</span><span class="op">]</span> <span class="op">=</span> <span class="nam">dict</span><span class="op">(</span><span class="nam">value</span><span class="op">)</span> <span class="com"># type: ignore</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t154" href="#t154">154</a></span><span class="t"> <span class="key">return</span> <span class="nam">categories</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t155" href="#t155">155</a></span><span class="t"> <span class="key">except</span> <span class="nam">Exception</span> <span class="key">as</span> <span class="nam">e</span><span class="op">:</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t156" href="#t156">156</a></span><span class="t"> <span class="nam">logger</span><span class="op">.</span><span class="nam">error</span><span class="op">(</span><span class="str">f"Couldn't fetch categories: {e}"</span><span class="op">)</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t157" href="#t157">157</a></span><span class="t"> <span class="key">return</span> <span class="op">{</span><span class="op">}</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t158" href="#t158">158</a></span><span class="t"> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t159" href="#t159">159</a></span><span class="t"> <span class="key">def</span> <span class="nam">_fetch_torrents</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span> <span class="op">-></span> <span class="nam">list</span><span class="op">[</span><span class="nam">dict</span><span class="op">]</span><span class="op">:</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t160" href="#t160">160</a></span><span class="t"> <span class="str">"""Fetches torrents from qbittorrent"""</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t161" href="#t161">161</a></span><span class="t"> <span class="key">try</span><span class="op">:</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t162" href="#t162">162</a></span><span class="t"> <span class="key">return</span> <span class="op">[</span><span class="nam">dict</span><span class="op">(</span><span class="nam">_attr_dict</span><span class="op">)</span> <span class="key">for</span> <span class="nam">_attr_dict</span> <span class="key">in</span> <span class="nam">self</span><span class="op">.</span><span class="nam">client</span><span class="op">.</span><span class="nam">torrents</span><span class="op">.</span><span class="nam">info</span><span class="op">(</span><span class="op">)</span><span class="op">]</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t163" href="#t163">163</a></span><span class="t"> <span class="key">except</span> <span class="nam">Exception</span> <span class="key">as</span> <span class="nam">e</span><span class="op">:</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t164" href="#t164">164</a></span><span class="t"> <span class="nam">logger</span><span class="op">.</span><span class="nam">error</span><span class="op">(</span><span class="str">f"Couldn't fetch torrents: {e}"</span><span class="op">)</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t165" href="#t165">165</a></span><span class="t"> <span class="key">return</span> <span class="op">[</span><span class="op">]</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t166" href="#t166">166</a></span><span class="t"> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t167" href="#t167">167</a></span><span class="t"> <span class="key">def</span> <span class="nam">_filter_torrents_by_category</span><span class="op">(</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t168" href="#t168">168</a></span><span class="t"> <span class="nam">self</span><span class="op">,</span> <span class="nam">category</span><span class="op">:</span> <span class="nam">str</span><span class="op">,</span> <span class="nam">torrents</span><span class="op">:</span> <span class="nam">list</span><span class="op">[</span><span class="nam">dict</span><span class="op">]</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t169" href="#t169">169</a></span><span class="t"> <span class="op">)</span> <span class="op">-></span> <span class="nam">list</span><span class="op">[</span><span class="nam">dict</span><span class="op">]</span><span class="op">:</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t170" href="#t170">170</a></span><span class="t"> <span class="str">"""Filters torrents by the given category."""</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t171" href="#t171">171</a></span><span class="t"> <span class="key">return</span> <span class="op">[</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t172" href="#t172">172</a></span><span class="t"> <span class="nam">torrent</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t173" href="#t173">173</a></span><span class="t"> <span class="key">for</span> <span class="nam">torrent</span> <span class="key">in</span> <span class="nam">torrents</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t174" href="#t174">174</a></span><span class="t"> <span class="key">if</span> <span class="nam">torrent</span><span class="op">[</span><span class="str">"category"</span><span class="op">]</span> <span class="op">==</span> <span class="nam">category</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t175" href="#t175">175</a></span><span class="t"> <span class="key">or</span> <span class="op">(</span><span class="nam">category</span> <span class="op">==</span> <span class="str">"Uncategorized"</span> <span class="key">and</span> <span class="nam">torrent</span><span class="op">[</span><span class="str">"category"</span><span class="op">]</span> <span class="op">==</span> <span class="str">""</span><span class="op">)</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t176" href="#t176">176</a></span><span class="t"> <span class="op">]</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t177" href="#t177">177</a></span><span class="t"> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t178" href="#t178">178</a></span><span class="t"> <span class="key">def</span> <span class="nam">_filter_torrents_by_state</span><span class="op">(</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t179" href="#t179">179</a></span><span class="t"> <span class="nam">self</span><span class="op">,</span> <span class="nam">state</span><span class="op">:</span> <span class="nam">TorrentStates</span><span class="op">,</span> <span class="nam">torrents</span><span class="op">:</span> <span class="nam">list</span><span class="op">[</span><span class="nam">dict</span><span class="op">]</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t180" href="#t180">180</a></span><span class="t"> <span class="op">)</span> <span class="op">-></span> <span class="nam">list</span><span class="op">[</span><span class="nam">dict</span><span class="op">]</span><span class="op">:</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t181" href="#t181">181</a></span><span class="t"> <span class="str">"""Filters torrents by the given state."""</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t182" href="#t182">182</a></span><span class="t"> <span class="key">return</span> <span class="op">[</span><span class="nam">torrent</span> <span class="key">for</span> <span class="nam">torrent</span> <span class="key">in</span> <span class="nam">torrents</span> <span class="key">if</span> <span class="nam">torrent</span><span class="op">[</span><span class="str">"state"</span><span class="op">]</span> <span class="op">==</span> <span class="nam">state</span><span class="op">.</span><span class="nam">value</span><span class="op">]</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t183" href="#t183">183</a></span><span class="t"> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t184" href="#t184">184</a></span><span class="t"> <span class="key">def</span> <span class="nam">_construct_metric</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">state</span><span class="op">:</span> <span class="nam">str</span><span class="op">,</span> <span class="nam">category</span><span class="op">:</span> <span class="nam">str</span><span class="op">,</span> <span class="nam">count</span><span class="op">:</span> <span class="nam">int</span><span class="op">)</span> <span class="op">-></span> <span class="nam">Metric</span><span class="op">:</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t185" href="#t185">185</a></span><span class="t"> <span class="str">"""Constructs and returns a metric object with a torrent count and appropriate</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t186" href="#t186">186</a></span><span class="t"><span class="str"> labels."""</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t187" href="#t187">187</a></span><span class="t"> <span class="key">return</span> <span class="nam">Metric</span><span class="op">(</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t188" href="#t188">188</a></span><span class="t"> <span class="nam">name</span><span class="op">=</span><span class="str">f"{self.config['metrics_prefix']}_torrents_count"</span><span class="op">,</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t189" href="#t189">189</a></span><span class="t"> <span class="nam">value</span><span class="op">=</span><span class="nam">count</span><span class="op">,</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t190" href="#t190">190</a></span><span class="t"> <span class="nam">labels</span><span class="op">=</span><span class="op">{</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t191" href="#t191">191</a></span><span class="t"> <span class="str">"status"</span><span class="op">:</span> <span class="nam">state</span><span class="op">,</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t192" href="#t192">192</a></span><span class="t"> <span class="str">"category"</span><span class="op">:</span> <span class="nam">category</span><span class="op">,</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t193" href="#t193">193</a></span><span class="t"> <span class="op">}</span><span class="op">,</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t194" href="#t194">194</a></span><span class="t"> <span class="nam">help_text</span><span class="op">=</span><span class="str">f"Number of torrents in status {state} under category {category}"</span><span class="op">,</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t195" href="#t195">195</a></span><span class="t"> <span class="op">)</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t196" href="#t196">196</a></span><span class="t"> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t197" href="#t197">197</a></span><span class="t"> <span class="key">def</span> <span class="nam">_get_qbittorrent_torrent_tags_metrics</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span> <span class="op">-></span> <span class="nam">list</span><span class="op">[</span><span class="nam">Metric</span><span class="op">]</span><span class="op">:</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t198" href="#t198">198</a></span><span class="t"> <span class="nam">categories</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">_fetch_categories</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t199" href="#t199">199</a></span><span class="t"> <span class="nam">torrents</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">_fetch_torrents</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t200" href="#t200">200</a></span><span class="t"> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t201" href="#t201">201</a></span><span class="t"> <span class="nam">metrics</span><span class="op">:</span> <span class="nam">list</span><span class="op">[</span><span class="nam">Metric</span><span class="op">]</span> <span class="op">=</span> <span class="op">[</span><span class="op">]</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t202" href="#t202">202</a></span><span class="t"> <span class="nam">categories</span><span class="op">[</span><span class="str">"Uncategorized"</span><span class="op">]</span> <span class="op">=</span> <span class="op">{</span><span class="str">"name"</span><span class="op">:</span> <span class="str">"Uncategorized"</span><span class="op">,</span> <span class="str">"savePath"</span><span class="op">:</span> <span class="str">""</span><span class="op">}</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t203" href="#t203">203</a></span><span class="t"> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t204" href="#t204">204</a></span><span class="t"> <span class="key">for</span> <span class="nam">category</span> <span class="key">in</span> <span class="nam">categories</span><span class="op">:</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t205" href="#t205">205</a></span><span class="t"> <span class="nam">category_torrents</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">_filter_torrents_by_category</span><span class="op">(</span><span class="nam">category</span><span class="op">,</span> <span class="nam">torrents</span><span class="op">)</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t206" href="#t206">206</a></span><span class="t"> <span class="key">for</span> <span class="nam">state</span> <span class="key">in</span> <span class="nam">TorrentStates</span><span class="op">:</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t207" href="#t207">207</a></span><span class="t"> <span class="nam">state_torrents</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">_filter_torrents_by_state</span><span class="op">(</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t208" href="#t208">208</a></span><span class="t"> <span class="nam">state</span><span class="op">,</span> <span class="nam">category_torrents</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t209" href="#t209">209</a></span><span class="t"> <span class="op">)</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t210" href="#t210">210</a></span><span class="t"> <span class="nam">metric</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">_construct_metric</span><span class="op">(</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t211" href="#t211">211</a></span><span class="t"> <span class="nam">state</span><span class="op">.</span><span class="nam">value</span><span class="op">,</span> <span class="nam">category</span><span class="op">,</span> <span class="nam">len</span><span class="op">(</span><span class="nam">state_torrents</span><span class="op">)</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t212" href="#t212">212</a></span><span class="t"> <span class="op">)</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t213" href="#t213">213</a></span><span class="t"> <span class="nam">metrics</span><span class="op">.</span><span class="nam">append</span><span class="op">(</span><span class="nam">metric</span><span class="op">)</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t214" href="#t214">214</a></span><span class="t"> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t215" href="#t215">215</a></span><span class="t"> <span class="key">return</span> <span class="nam">metrics</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t216" href="#t216">216</a></span><span class="t"> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t217" href="#t217">217</a></span><span class="t"> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t218" href="#t218">218</a></span><span class="t"><span class="key">class</span> <span class="nam">ShutdownSignalHandler</span><span class="op">:</span> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t219" href="#t219">219</a></span><span class="t"> <span class="key">def</span> <span class="nam">__init__</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p>
|
|
||||||
<p class="mis show_mis"><span class="n"><a id="t220" href="#t220">220</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">shutdown_count</span><span class="op">:</span> <span class="nam">int</span> <span class="op">=</span> <span class="num">0</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t221" href="#t221">221</a></span><span class="t"> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t222" href="#t222">222</a></span><span class="t"> <span class="com"># Register signal handler</span> </span><span class="r"></span></p>
|
|
||||||
<p class="mis show_mis"><span class="n"><a id="t223" href="#t223">223</a></span><span class="t"> <span class="nam">signal</span><span class="op">.</span><span class="nam">signal</span><span class="op">(</span><span class="nam">signal</span><span class="op">.</span><span class="nam">SIGINT</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">_on_signal_received</span><span class="op">)</span> </span><span class="r"></span></p>
|
|
||||||
<p class="mis show_mis"><span class="n"><a id="t224" href="#t224">224</a></span><span class="t"> <span class="nam">signal</span><span class="op">.</span><span class="nam">signal</span><span class="op">(</span><span class="nam">signal</span><span class="op">.</span><span class="nam">SIGTERM</span><span class="op">,</span> <span class="nam">self</span><span class="op">.</span><span class="nam">_on_signal_received</span><span class="op">)</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t225" href="#t225">225</a></span><span class="t"> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t226" href="#t226">226</a></span><span class="t"> <span class="key">def</span> <span class="nam">is_shutting_down</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p>
|
|
||||||
<p class="mis show_mis"><span class="n"><a id="t227" href="#t227">227</a></span><span class="t"> <span class="key">return</span> <span class="nam">self</span><span class="op">.</span><span class="nam">shutdown_count</span> <span class="op">></span> <span class="num">0</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t228" href="#t228">228</a></span><span class="t"> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t229" href="#t229">229</a></span><span class="t"> <span class="key">def</span> <span class="nam">_on_signal_received</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">signal</span><span class="op">,</span> <span class="nam">frame</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p>
|
|
||||||
<p class="mis show_mis"><span class="n"><a id="t230" href="#t230">230</a></span><span class="t"> <span class="key">if</span> <span class="nam">self</span><span class="op">.</span><span class="nam">shutdown_count</span> <span class="op">></span> <span class="num">1</span><span class="op">:</span> </span><span class="r"></span></p>
|
|
||||||
<p class="mis show_mis"><span class="n"><a id="t231" href="#t231">231</a></span><span class="t"> <span class="nam">logger</span><span class="op">.</span><span class="nam">warn</span><span class="op">(</span><span class="str">"Forcibly killing exporter"</span><span class="op">)</span> </span><span class="r"></span></p>
|
|
||||||
<p class="mis show_mis"><span class="n"><a id="t232" href="#t232">232</a></span><span class="t"> <span class="nam">sys</span><span class="op">.</span><span class="nam">exit</span><span class="op">(</span><span class="num">1</span><span class="op">)</span> </span><span class="r"></span></p>
|
|
||||||
<p class="mis show_mis"><span class="n"><a id="t233" href="#t233">233</a></span><span class="t"> <span class="nam">logger</span><span class="op">.</span><span class="nam">info</span><span class="op">(</span><span class="str">"Exporter is shutting down"</span><span class="op">)</span> </span><span class="r"></span></p>
|
|
||||||
<p class="mis show_mis"><span class="n"><a id="t234" href="#t234">234</a></span><span class="t"> <span class="nam">self</span><span class="op">.</span><span class="nam">shutdown_count</span> <span class="op">+=</span> <span class="num">1</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t235" href="#t235">235</a></span><span class="t"> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t236" href="#t236">236</a></span><span class="t"> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t237" href="#t237">237</a></span><span class="t"><span class="key">def</span> <span class="nam">_get_config_value</span><span class="op">(</span><span class="nam">key</span><span class="op">:</span> <span class="nam">str</span><span class="op">,</span> <span class="nam">default</span><span class="op">:</span> <span class="nam">str</span> <span class="op">=</span> <span class="str">""</span><span class="op">)</span> <span class="op">-></span> <span class="nam">str</span><span class="op">:</span> </span><span class="r"></span></p>
|
|
||||||
<p class="mis show_mis"><span class="n"><a id="t238" href="#t238">238</a></span><span class="t"> <span class="nam">input_path</span> <span class="op">=</span> <span class="nam">os</span><span class="op">.</span><span class="nam">environ</span><span class="op">.</span><span class="nam">get</span><span class="op">(</span><span class="str">"FILE__"</span> <span class="op">+</span> <span class="nam">key</span><span class="op">,</span> <span class="key">None</span><span class="op">)</span> </span><span class="r"></span></p>
|
|
||||||
<p class="mis show_mis"><span class="n"><a id="t239" href="#t239">239</a></span><span class="t"> <span class="key">if</span> <span class="nam">input_path</span> <span class="key">is</span> <span class="key">not</span> <span class="key">None</span><span class="op">:</span> </span><span class="r"></span></p>
|
|
||||||
<p class="mis show_mis"><span class="n"><a id="t240" href="#t240">240</a></span><span class="t"> <span class="key">try</span><span class="op">:</span> </span><span class="r"></span></p>
|
|
||||||
<p class="mis show_mis"><span class="n"><a id="t241" href="#t241">241</a></span><span class="t"> <span class="key">with</span> <span class="nam">open</span><span class="op">(</span><span class="nam">input_path</span><span class="op">,</span> <span class="str">"r"</span><span class="op">)</span> <span class="key">as</span> <span class="nam">input_file</span><span class="op">:</span> </span><span class="r"></span></p>
|
|
||||||
<p class="mis show_mis"><span class="n"><a id="t242" href="#t242">242</a></span><span class="t"> <span class="key">return</span> <span class="nam">input_file</span><span class="op">.</span><span class="nam">read</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">strip</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p>
|
|
||||||
<p class="mis show_mis"><span class="n"><a id="t243" href="#t243">243</a></span><span class="t"> <span class="key">except</span> <span class="nam">IOError</span> <span class="key">as</span> <span class="nam">e</span><span class="op">:</span> </span><span class="r"></span></p>
|
|
||||||
<p class="mis show_mis"><span class="n"><a id="t244" href="#t244">244</a></span><span class="t"> <span class="nam">logger</span><span class="op">.</span><span class="nam">error</span><span class="op">(</span><span class="str">f"Unable to read value for {key} from {input_path}: {str(e)}"</span><span class="op">)</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t245" href="#t245">245</a></span><span class="t"> </span><span class="r"></span></p>
|
|
||||||
<p class="mis show_mis"><span class="n"><a id="t246" href="#t246">246</a></span><span class="t"> <span class="key">return</span> <span class="nam">os</span><span class="op">.</span><span class="nam">environ</span><span class="op">.</span><span class="nam">get</span><span class="op">(</span><span class="nam">key</span><span class="op">,</span> <span class="nam">default</span><span class="op">)</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t247" href="#t247">247</a></span><span class="t"> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t248" href="#t248">248</a></span><span class="t"> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t249" href="#t249">249</a></span><span class="t"><span class="key">def</span> <span class="nam">get_config</span><span class="op">(</span><span class="op">)</span> <span class="op">-></span> <span class="nam">dict</span><span class="op">:</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t250" href="#t250">250</a></span><span class="t"> <span class="str">"""Loads all config values."""</span> </span><span class="r"></span></p>
|
|
||||||
<p class="mis show_mis"><span class="n"><a id="t251" href="#t251">251</a></span><span class="t"> <span class="key">return</span> <span class="op">{</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t252" href="#t252">252</a></span><span class="t"> <span class="str">"host"</span><span class="op">:</span> <span class="nam">_get_config_value</span><span class="op">(</span><span class="str">"QBITTORRENT_HOST"</span><span class="op">,</span> <span class="str">""</span><span class="op">)</span><span class="op">,</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t253" href="#t253">253</a></span><span class="t"> <span class="str">"port"</span><span class="op">:</span> <span class="nam">_get_config_value</span><span class="op">(</span><span class="str">"QBITTORRENT_PORT"</span><span class="op">,</span> <span class="str">""</span><span class="op">)</span><span class="op">,</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t254" href="#t254">254</a></span><span class="t"> <span class="str">"username"</span><span class="op">:</span> <span class="nam">_get_config_value</span><span class="op">(</span><span class="str">"QBITTORRENT_USER"</span><span class="op">,</span> <span class="str">""</span><span class="op">)</span><span class="op">,</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t255" href="#t255">255</a></span><span class="t"> <span class="str">"password"</span><span class="op">:</span> <span class="nam">_get_config_value</span><span class="op">(</span><span class="str">"QBITTORRENT_PASS"</span><span class="op">,</span> <span class="str">""</span><span class="op">)</span><span class="op">,</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t256" href="#t256">256</a></span><span class="t"> <span class="str">"exporter_port"</span><span class="op">:</span> <span class="nam">int</span><span class="op">(</span><span class="nam">_get_config_value</span><span class="op">(</span><span class="str">"EXPORTER_PORT"</span><span class="op">,</span> <span class="str">"8000"</span><span class="op">)</span><span class="op">)</span><span class="op">,</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t257" href="#t257">257</a></span><span class="t"> <span class="str">"log_level"</span><span class="op">:</span> <span class="nam">_get_config_value</span><span class="op">(</span><span class="str">"EXPORTER_LOG_LEVEL"</span><span class="op">,</span> <span class="str">"INFO"</span><span class="op">)</span><span class="op">,</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t258" href="#t258">258</a></span><span class="t"> <span class="str">"metrics_prefix"</span><span class="op">:</span> <span class="nam">_get_config_value</span><span class="op">(</span><span class="str">"METRICS_PREFIX"</span><span class="op">,</span> <span class="str">"qbittorrent"</span><span class="op">)</span><span class="op">,</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t259" href="#t259">259</a></span><span class="t"> <span class="str">"verify_webui_certificate"</span><span class="op">:</span> <span class="op">(</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t260" href="#t260">260</a></span><span class="t"> <span class="nam">_get_config_value</span><span class="op">(</span><span class="str">"VERIFY_WEBUI_CERTIFICATE"</span><span class="op">,</span> <span class="str">"True"</span><span class="op">)</span> <span class="op">==</span> <span class="str">"True"</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t261" href="#t261">261</a></span><span class="t"> <span class="op">)</span><span class="op">,</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t262" href="#t262">262</a></span><span class="t"> <span class="op">}</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t263" href="#t263">263</a></span><span class="t"> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t264" href="#t264">264</a></span><span class="t"> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t265" href="#t265">265</a></span><span class="t"><span class="key">def</span> <span class="nam">main</span><span class="op">(</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t266" href="#t266">266</a></span><span class="t"> <span class="com"># Init logger so it can be used</span> </span><span class="r"></span></p>
|
|
||||||
<p class="mis show_mis"><span class="n"><a id="t267" href="#t267">267</a></span><span class="t"> <span class="nam">logHandler</span> <span class="op">=</span> <span class="nam">logging</span><span class="op">.</span><span class="nam">StreamHandler</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p>
|
|
||||||
<p class="mis show_mis"><span class="n"><a id="t268" href="#t268">268</a></span><span class="t"> <span class="nam">formatter</span> <span class="op">=</span> <span class="nam">jsonlogger</span><span class="op">.</span><span class="nam">JsonFormatter</span><span class="op">(</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t269" href="#t269">269</a></span><span class="t"> <span class="str">"%(asctime) %(levelname) %(message)"</span><span class="op">,</span> <span class="nam">datefmt</span><span class="op">=</span><span class="str">"%Y-%m-%d %H:%M:%S"</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t270" href="#t270">270</a></span><span class="t"> <span class="op">)</span> </span><span class="r"></span></p>
|
|
||||||
<p class="mis show_mis"><span class="n"><a id="t271" href="#t271">271</a></span><span class="t"> <span class="nam">logHandler</span><span class="op">.</span><span class="nam">setFormatter</span><span class="op">(</span><span class="nam">formatter</span><span class="op">)</span> </span><span class="r"></span></p>
|
|
||||||
<p class="mis show_mis"><span class="n"><a id="t272" href="#t272">272</a></span><span class="t"> <span class="nam">logger</span><span class="op">.</span><span class="nam">addHandler</span><span class="op">(</span><span class="nam">logHandler</span><span class="op">)</span> </span><span class="r"></span></p>
|
|
||||||
<p class="mis show_mis"><span class="n"><a id="t273" href="#t273">273</a></span><span class="t"> <span class="nam">logger</span><span class="op">.</span><span class="nam">setLevel</span><span class="op">(</span><span class="str">"INFO"</span><span class="op">)</span> <span class="com"># default until config is loaded</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t274" href="#t274">274</a></span><span class="t"> </span><span class="r"></span></p>
|
|
||||||
<p class="mis show_mis"><span class="n"><a id="t275" href="#t275">275</a></span><span class="t"> <span class="nam">config</span> <span class="op">=</span> <span class="nam">get_config</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t276" href="#t276">276</a></span><span class="t"> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t277" href="#t277">277</a></span><span class="t"> <span class="com"># set level once config has been loaded</span> </span><span class="r"></span></p>
|
|
||||||
<p class="mis show_mis"><span class="n"><a id="t278" href="#t278">278</a></span><span class="t"> <span class="nam">logger</span><span class="op">.</span><span class="nam">setLevel</span><span class="op">(</span><span class="nam">config</span><span class="op">[</span><span class="str">"log_level"</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t279" href="#t279">279</a></span><span class="t"> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t280" href="#t280">280</a></span><span class="t"> <span class="com"># Register signal handler</span> </span><span class="r"></span></p>
|
|
||||||
<p class="mis show_mis"><span class="n"><a id="t281" href="#t281">281</a></span><span class="t"> <span class="nam">signal_handler</span> <span class="op">=</span> <span class="nam">ShutdownSignalHandler</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t282" href="#t282">282</a></span><span class="t"> </span><span class="r"></span></p>
|
|
||||||
<p class="mis show_mis"><span class="n"><a id="t283" href="#t283">283</a></span><span class="t"> <span class="key">if</span> <span class="key">not</span> <span class="nam">config</span><span class="op">[</span><span class="str">"host"</span><span class="op">]</span><span class="op">:</span> </span><span class="r"></span></p>
|
|
||||||
<p class="mis show_mis"><span class="n"><a id="t284" href="#t284">284</a></span><span class="t"> <span class="nam">logger</span><span class="op">.</span><span class="nam">error</span><span class="op">(</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t285" href="#t285">285</a></span><span class="t"> <span class="str">"No host specified, please set QBITTORRENT_HOST environment variable"</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t286" href="#t286">286</a></span><span class="t"> <span class="op">)</span> </span><span class="r"></span></p>
|
|
||||||
<p class="mis show_mis"><span class="n"><a id="t287" href="#t287">287</a></span><span class="t"> <span class="nam">sys</span><span class="op">.</span><span class="nam">exit</span><span class="op">(</span><span class="num">1</span><span class="op">)</span> </span><span class="r"></span></p>
|
|
||||||
<p class="mis show_mis"><span class="n"><a id="t288" href="#t288">288</a></span><span class="t"> <span class="key">if</span> <span class="key">not</span> <span class="nam">config</span><span class="op">[</span><span class="str">"port"</span><span class="op">]</span><span class="op">:</span> </span><span class="r"></span></p>
|
|
||||||
<p class="mis show_mis"><span class="n"><a id="t289" href="#t289">289</a></span><span class="t"> <span class="nam">logger</span><span class="op">.</span><span class="nam">error</span><span class="op">(</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t290" href="#t290">290</a></span><span class="t"> <span class="str">"No port specified, please set QBITTORRENT_PORT environment variable"</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t291" href="#t291">291</a></span><span class="t"> <span class="op">)</span> </span><span class="r"></span></p>
|
|
||||||
<p class="mis show_mis"><span class="n"><a id="t292" href="#t292">292</a></span><span class="t"> <span class="nam">sys</span><span class="op">.</span><span class="nam">exit</span><span class="op">(</span><span class="num">1</span><span class="op">)</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t293" href="#t293">293</a></span><span class="t"> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t294" href="#t294">294</a></span><span class="t"> <span class="com"># Register our custom collector</span> </span><span class="r"></span></p>
|
|
||||||
<p class="mis show_mis"><span class="n"><a id="t295" href="#t295">295</a></span><span class="t"> <span class="nam">logger</span><span class="op">.</span><span class="nam">info</span><span class="op">(</span><span class="str">"Exporter is starting up"</span><span class="op">)</span> </span><span class="r"></span></p>
|
|
||||||
<p class="mis show_mis"><span class="n"><a id="t296" href="#t296">296</a></span><span class="t"> <span class="nam">REGISTRY</span><span class="op">.</span><span class="nam">register</span><span class="op">(</span><span class="nam">QbittorrentMetricsCollector</span><span class="op">(</span><span class="nam">config</span><span class="op">)</span><span class="op">)</span> <span class="com"># type: ignore</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t297" href="#t297">297</a></span><span class="t"> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t298" href="#t298">298</a></span><span class="t"> <span class="com"># Start server</span> </span><span class="r"></span></p>
|
|
||||||
<p class="mis show_mis"><span class="n"><a id="t299" href="#t299">299</a></span><span class="t"> <span class="nam">start_http_server</span><span class="op">(</span><span class="nam">config</span><span class="op">[</span><span class="str">"exporter_port"</span><span class="op">]</span><span class="op">)</span> </span><span class="r"></span></p>
|
|
||||||
<p class="mis show_mis"><span class="n"><a id="t300" href="#t300">300</a></span><span class="t"> <span class="nam">logger</span><span class="op">.</span><span class="nam">info</span><span class="op">(</span><span class="str">f"Exporter listening on port {config['exporter_port']}"</span><span class="op">)</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t301" href="#t301">301</a></span><span class="t"> </span><span class="r"></span></p>
|
|
||||||
<p class="mis show_mis"><span class="n"><a id="t302" href="#t302">302</a></span><span class="t"> <span class="key">while</span> <span class="key">not</span> <span class="nam">signal_handler</span><span class="op">.</span><span class="nam">is_shutting_down</span><span class="op">(</span><span class="op">)</span><span class="op">:</span> </span><span class="r"></span></p>
|
|
||||||
<p class="mis show_mis"><span class="n"><a id="t303" href="#t303">303</a></span><span class="t"> <span class="nam">time</span><span class="op">.</span><span class="nam">sleep</span><span class="op">(</span><span class="num">1</span><span class="op">)</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t304" href="#t304">304</a></span><span class="t"> </span><span class="r"></span></p>
|
|
||||||
<p class="mis show_mis"><span class="n"><a id="t305" href="#t305">305</a></span><span class="t"> <span class="nam">logger</span><span class="op">.</span><span class="nam">info</span><span class="op">(</span><span class="str">"Exporter has shutdown"</span><span class="op">)</span> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t306" href="#t306">306</a></span><span class="t"> </span><span class="r"></span></p>
|
|
||||||
<p class="pln"><span class="n"><a id="t307" href="#t307">307</a></span><span class="t"> </span><span class="r"></span></p>
|
|
||||||
<p class="run"><span class="n"><a id="t308" href="#t308">308</a></span><span class="t"><span class="key">if</span> <span class="nam">__name__</span> <span class="op">==</span> <span class="str">"__main__"</span><span class="op">:</span> </span><span class="r"></span></p>
|
|
||||||
<p class="mis show_mis"><span class="n"><a id="t309" href="#t309">309</a></span><span class="t"> <span class="nam">main</span><span class="op">(</span><span class="op">)</span> </span><span class="r"></span></p>
|
|
||||||
</main>
|
|
||||||
<footer>
|
|
||||||
<div class="content">
|
|
||||||
<p>
|
|
||||||
<a id="prevFileLink" class="nav" href="index.html">« prev</a>
|
|
||||||
<a id="indexLink" class="nav" href="index.html">^ index</a>
|
|
||||||
<a id="nextFileLink" class="nav" href="index.html">» next</a>
|
|
||||||
|
|
||||||
<a class="nav" href="https://coverage.readthedocs.io/en/7.3.2">coverage.py v7.3.2</a>,
|
|
||||||
created at 2023-12-10 09:17 +0000
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</footer>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
Generated
BIN
Binary file not shown.
|
Before Width: | Height: | Size: 1.7 KiB |
Generated
-103
@@ -1,103 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
||||||
<title>Coverage report</title>
|
|
||||||
<link rel="icon" sizes="32x32" href="favicon_32.png">
|
|
||||||
<link rel="stylesheet" href="style.css" type="text/css">
|
|
||||||
<script type="text/javascript" src="coverage_html.js" defer></script>
|
|
||||||
</head>
|
|
||||||
<body class="indexfile">
|
|
||||||
<header>
|
|
||||||
<div class="content">
|
|
||||||
<h1>Coverage report:
|
|
||||||
<span class="pc_cov">68%</span>
|
|
||||||
</h1>
|
|
||||||
<aside id="help_panel_wrapper">
|
|
||||||
<input id="help_panel_state" type="checkbox">
|
|
||||||
<label for="help_panel_state">
|
|
||||||
<img id="keyboard_icon" src="keybd_closed.png" alt="Show/hide keyboard shortcuts" />
|
|
||||||
</label>
|
|
||||||
<div id="help_panel">
|
|
||||||
<p class="legend">Shortcuts on this page</p>
|
|
||||||
<div class="keyhelp">
|
|
||||||
<p>
|
|
||||||
<kbd>n</kbd>
|
|
||||||
<kbd>s</kbd>
|
|
||||||
<kbd>m</kbd>
|
|
||||||
<kbd>x</kbd>
|
|
||||||
<kbd>c</kbd>
|
|
||||||
change column sorting
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<kbd>[</kbd>
|
|
||||||
<kbd>]</kbd>
|
|
||||||
prev/next file
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<kbd>?</kbd> show/hide this help
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</aside>
|
|
||||||
<form id="filter_container">
|
|
||||||
<input id="filter" type="text" value="" placeholder="filter..." />
|
|
||||||
</form>
|
|
||||||
<p class="text">
|
|
||||||
<a class="nav" href="https://coverage.readthedocs.io/en/7.3.2">coverage.py v7.3.2</a>,
|
|
||||||
created at 2023-12-10 09:17 +0000
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</header>
|
|
||||||
<main id="index">
|
|
||||||
<table class="index" data-sortable>
|
|
||||||
<thead>
|
|
||||||
<tr class="tablehead" title="Click to sort">
|
|
||||||
<th class="name left" aria-sort="none" data-shortcut="n">Module</th>
|
|
||||||
<th aria-sort="none" data-default-sort-order="descending" data-shortcut="s">statements</th>
|
|
||||||
<th aria-sort="none" data-default-sort-order="descending" data-shortcut="m">missing</th>
|
|
||||||
<th aria-sort="none" data-default-sort-order="descending" data-shortcut="x">excluded</th>
|
|
||||||
<th class="right" aria-sort="none" data-shortcut="c">coverage</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr class="file">
|
|
||||||
<td class="name left"><a href="d_6abd174c694c1177_exporter_py.html">qbittorrent_exporter/exporter.py</a></td>
|
|
||||||
<td>132</td>
|
|
||||||
<td>42</td>
|
|
||||||
<td>0</td>
|
|
||||||
<td class="right" data-ratio="90 132">68%</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
<tfoot>
|
|
||||||
<tr class="total">
|
|
||||||
<td class="name left">Total</td>
|
|
||||||
<td>132</td>
|
|
||||||
<td>42</td>
|
|
||||||
<td>0</td>
|
|
||||||
<td class="right" data-ratio="90 132">68%</td>
|
|
||||||
</tr>
|
|
||||||
</tfoot>
|
|
||||||
</table>
|
|
||||||
<p id="no_rows">
|
|
||||||
No items found using the specified filter.
|
|
||||||
</p>
|
|
||||||
<p>1 empty file skipped.</p>
|
|
||||||
</main>
|
|
||||||
<footer>
|
|
||||||
<div class="content">
|
|
||||||
<p>
|
|
||||||
<a class="nav" href="https://coverage.readthedocs.io/en/7.3.2">coverage.py v7.3.2</a>,
|
|
||||||
created at 2023-12-10 09:17 +0000
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<aside class="hidden">
|
|
||||||
<a id="prevFileLink" class="nav" href="d_6abd174c694c1177_exporter_py.html"/>
|
|
||||||
<a id="nextFileLink" class="nav" href="d_6abd174c694c1177_exporter_py.html"/>
|
|
||||||
<button type="button" class="button_prev_file" data-shortcut="["/>
|
|
||||||
<button type="button" class="button_next_file" data-shortcut="]"/>
|
|
||||||
<button type="button" class="button_show_hide_help" data-shortcut="?"/>
|
|
||||||
</aside>
|
|
||||||
</footer>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
Generated
BIN
Binary file not shown.
|
Before Width: | Height: | Size: 8.8 KiB |
Generated
BIN
Binary file not shown.
|
Before Width: | Height: | Size: 8.8 KiB |
Generated
-1
@@ -1 +0,0 @@
|
|||||||
{"format":2,"version":"7.3.2","globals":"bb7c71700f0882ba37f84581523dd0ae","files":{"d_6abd174c694c1177_exporter_py":{"hash":"4c94f0c6e74a3d075ceebd079d81aef8","index":{"nums":[0,1,132,0,42,0,0,0],"html_filename":"d_6abd174c694c1177_exporter_py.html","relative_filename":"qbittorrent_exporter/exporter.py"}}}}
|
|
||||||
Generated
-309
@@ -1,309 +0,0 @@
|
|||||||
@charset "UTF-8";
|
|
||||||
/* Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 */
|
|
||||||
/* For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt */
|
|
||||||
/* Don't edit this .css file. Edit the .scss file instead! */
|
|
||||||
html, body, h1, h2, h3, p, table, td, th { margin: 0; padding: 0; border: 0; font-weight: inherit; font-style: inherit; font-size: 100%; font-family: inherit; vertical-align: baseline; }
|
|
||||||
|
|
||||||
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; font-size: 1em; background: #fff; color: #000; }
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) { body { background: #1e1e1e; } }
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) { body { color: #eee; } }
|
|
||||||
|
|
||||||
html > body { font-size: 16px; }
|
|
||||||
|
|
||||||
a:active, a:focus { outline: 2px dashed #007acc; }
|
|
||||||
|
|
||||||
p { font-size: .875em; line-height: 1.4em; }
|
|
||||||
|
|
||||||
table { border-collapse: collapse; }
|
|
||||||
|
|
||||||
td { vertical-align: top; }
|
|
||||||
|
|
||||||
table tr.hidden { display: none !important; }
|
|
||||||
|
|
||||||
p#no_rows { display: none; font-size: 1.2em; }
|
|
||||||
|
|
||||||
a.nav { text-decoration: none; color: inherit; }
|
|
||||||
|
|
||||||
a.nav:hover { text-decoration: underline; color: inherit; }
|
|
||||||
|
|
||||||
.hidden { display: none; }
|
|
||||||
|
|
||||||
header { background: #f8f8f8; width: 100%; z-index: 2; border-bottom: 1px solid #ccc; }
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) { header { background: black; } }
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) { header { border-color: #333; } }
|
|
||||||
|
|
||||||
header .content { padding: 1rem 3.5rem; }
|
|
||||||
|
|
||||||
header h2 { margin-top: .5em; font-size: 1em; }
|
|
||||||
|
|
||||||
header p.text { margin: .5em 0 -.5em; color: #666; font-style: italic; }
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) { header p.text { color: #aaa; } }
|
|
||||||
|
|
||||||
header.sticky { position: fixed; left: 0; right: 0; height: 2.5em; }
|
|
||||||
|
|
||||||
header.sticky .text { display: none; }
|
|
||||||
|
|
||||||
header.sticky h1, header.sticky h2 { font-size: 1em; margin-top: 0; display: inline-block; }
|
|
||||||
|
|
||||||
header.sticky .content { padding: 0.5rem 3.5rem; }
|
|
||||||
|
|
||||||
header.sticky .content p { font-size: 1em; }
|
|
||||||
|
|
||||||
header.sticky ~ #source { padding-top: 6.5em; }
|
|
||||||
|
|
||||||
main { position: relative; z-index: 1; }
|
|
||||||
|
|
||||||
footer { margin: 1rem 3.5rem; }
|
|
||||||
|
|
||||||
footer .content { padding: 0; color: #666; font-style: italic; }
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) { footer .content { color: #aaa; } }
|
|
||||||
|
|
||||||
#index { margin: 1rem 0 0 3.5rem; }
|
|
||||||
|
|
||||||
h1 { font-size: 1.25em; display: inline-block; }
|
|
||||||
|
|
||||||
#filter_container { float: right; margin: 0 2em 0 0; }
|
|
||||||
|
|
||||||
#filter_container input { width: 10em; padding: 0.2em 0.5em; border: 2px solid #ccc; background: #fff; color: #000; }
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) { #filter_container input { border-color: #444; } }
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) { #filter_container input { background: #1e1e1e; } }
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) { #filter_container input { color: #eee; } }
|
|
||||||
|
|
||||||
#filter_container input:focus { border-color: #007acc; }
|
|
||||||
|
|
||||||
header button { font-family: inherit; font-size: inherit; border: 1px solid; border-radius: .2em; color: inherit; padding: .1em .5em; margin: 1px calc(.1em + 1px); cursor: pointer; border-color: #ccc; }
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) { header button { border-color: #444; } }
|
|
||||||
|
|
||||||
header button:active, header button:focus { outline: 2px dashed #007acc; }
|
|
||||||
|
|
||||||
header button.run { background: #eeffee; }
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) { header button.run { background: #373d29; } }
|
|
||||||
|
|
||||||
header button.run.show_run { background: #dfd; border: 2px solid #00dd00; margin: 0 .1em; }
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) { header button.run.show_run { background: #373d29; } }
|
|
||||||
|
|
||||||
header button.mis { background: #ffeeee; }
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) { header button.mis { background: #4b1818; } }
|
|
||||||
|
|
||||||
header button.mis.show_mis { background: #fdd; border: 2px solid #ff0000; margin: 0 .1em; }
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) { header button.mis.show_mis { background: #4b1818; } }
|
|
||||||
|
|
||||||
header button.exc { background: #f7f7f7; }
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) { header button.exc { background: #333; } }
|
|
||||||
|
|
||||||
header button.exc.show_exc { background: #eee; border: 2px solid #808080; margin: 0 .1em; }
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) { header button.exc.show_exc { background: #333; } }
|
|
||||||
|
|
||||||
header button.par { background: #ffffd5; }
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) { header button.par { background: #650; } }
|
|
||||||
|
|
||||||
header button.par.show_par { background: #ffa; border: 2px solid #bbbb00; margin: 0 .1em; }
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) { header button.par.show_par { background: #650; } }
|
|
||||||
|
|
||||||
#help_panel, #source p .annotate.long { display: none; position: absolute; z-index: 999; background: #ffffcc; border: 1px solid #888; border-radius: .2em; color: #333; padding: .25em .5em; }
|
|
||||||
|
|
||||||
#source p .annotate.long { white-space: normal; float: right; top: 1.75em; right: 1em; height: auto; }
|
|
||||||
|
|
||||||
#help_panel_wrapper { float: right; position: relative; }
|
|
||||||
|
|
||||||
#keyboard_icon { margin: 5px; }
|
|
||||||
|
|
||||||
#help_panel_state { display: none; }
|
|
||||||
|
|
||||||
#help_panel { top: 25px; right: 0; padding: .75em; border: 1px solid #883; color: #333; }
|
|
||||||
|
|
||||||
#help_panel .keyhelp p { margin-top: .75em; }
|
|
||||||
|
|
||||||
#help_panel .legend { font-style: italic; margin-bottom: 1em; }
|
|
||||||
|
|
||||||
.indexfile #help_panel { width: 25em; }
|
|
||||||
|
|
||||||
.pyfile #help_panel { width: 18em; }
|
|
||||||
|
|
||||||
#help_panel_state:checked ~ #help_panel { display: block; }
|
|
||||||
|
|
||||||
kbd { border: 1px solid black; border-color: #888 #333 #333 #888; padding: .1em .35em; font-family: SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-weight: bold; background: #eee; border-radius: 3px; }
|
|
||||||
|
|
||||||
#source { padding: 1em 0 1em 3.5rem; font-family: SFMono-Regular, Menlo, Monaco, Consolas, monospace; }
|
|
||||||
|
|
||||||
#source p { position: relative; white-space: pre; }
|
|
||||||
|
|
||||||
#source p * { box-sizing: border-box; }
|
|
||||||
|
|
||||||
#source p .n { float: left; text-align: right; width: 3.5rem; box-sizing: border-box; margin-left: -3.5rem; padding-right: 1em; color: #999; }
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) { #source p .n { color: #777; } }
|
|
||||||
|
|
||||||
#source p .n.highlight { background: #ffdd00; }
|
|
||||||
|
|
||||||
#source p .n a { margin-top: -4em; padding-top: 4em; text-decoration: none; color: #999; }
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) { #source p .n a { color: #777; } }
|
|
||||||
|
|
||||||
#source p .n a:hover { text-decoration: underline; color: #999; }
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) { #source p .n a:hover { color: #777; } }
|
|
||||||
|
|
||||||
#source p .t { display: inline-block; width: 100%; box-sizing: border-box; margin-left: -.5em; padding-left: 0.3em; border-left: 0.2em solid #fff; }
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) { #source p .t { border-color: #1e1e1e; } }
|
|
||||||
|
|
||||||
#source p .t:hover { background: #f2f2f2; }
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) { #source p .t:hover { background: #282828; } }
|
|
||||||
|
|
||||||
#source p .t:hover ~ .r .annotate.long { display: block; }
|
|
||||||
|
|
||||||
#source p .t .com { color: #008000; font-style: italic; line-height: 1px; }
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) { #source p .t .com { color: #6a9955; } }
|
|
||||||
|
|
||||||
#source p .t .key { font-weight: bold; line-height: 1px; }
|
|
||||||
|
|
||||||
#source p .t .str { color: #0451a5; }
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) { #source p .t .str { color: #9cdcfe; } }
|
|
||||||
|
|
||||||
#source p.mis .t { border-left: 0.2em solid #ff0000; }
|
|
||||||
|
|
||||||
#source p.mis.show_mis .t { background: #fdd; }
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) { #source p.mis.show_mis .t { background: #4b1818; } }
|
|
||||||
|
|
||||||
#source p.mis.show_mis .t:hover { background: #f2d2d2; }
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) { #source p.mis.show_mis .t:hover { background: #532323; } }
|
|
||||||
|
|
||||||
#source p.run .t { border-left: 0.2em solid #00dd00; }
|
|
||||||
|
|
||||||
#source p.run.show_run .t { background: #dfd; }
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) { #source p.run.show_run .t { background: #373d29; } }
|
|
||||||
|
|
||||||
#source p.run.show_run .t:hover { background: #d2f2d2; }
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) { #source p.run.show_run .t:hover { background: #404633; } }
|
|
||||||
|
|
||||||
#source p.exc .t { border-left: 0.2em solid #808080; }
|
|
||||||
|
|
||||||
#source p.exc.show_exc .t { background: #eee; }
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) { #source p.exc.show_exc .t { background: #333; } }
|
|
||||||
|
|
||||||
#source p.exc.show_exc .t:hover { background: #e2e2e2; }
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) { #source p.exc.show_exc .t:hover { background: #3c3c3c; } }
|
|
||||||
|
|
||||||
#source p.par .t { border-left: 0.2em solid #bbbb00; }
|
|
||||||
|
|
||||||
#source p.par.show_par .t { background: #ffa; }
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) { #source p.par.show_par .t { background: #650; } }
|
|
||||||
|
|
||||||
#source p.par.show_par .t:hover { background: #f2f2a2; }
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) { #source p.par.show_par .t:hover { background: #6d5d0c; } }
|
|
||||||
|
|
||||||
#source p .r { position: absolute; top: 0; right: 2.5em; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; }
|
|
||||||
|
|
||||||
#source p .annotate { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; color: #666; padding-right: .5em; }
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) { #source p .annotate { color: #ddd; } }
|
|
||||||
|
|
||||||
#source p .annotate.short:hover ~ .long { display: block; }
|
|
||||||
|
|
||||||
#source p .annotate.long { width: 30em; right: 2.5em; }
|
|
||||||
|
|
||||||
#source p input { display: none; }
|
|
||||||
|
|
||||||
#source p input ~ .r label.ctx { cursor: pointer; border-radius: .25em; }
|
|
||||||
|
|
||||||
#source p input ~ .r label.ctx::before { content: "▶ "; }
|
|
||||||
|
|
||||||
#source p input ~ .r label.ctx:hover { background: #e8f4ff; color: #666; }
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) { #source p input ~ .r label.ctx:hover { background: #0f3a42; } }
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) { #source p input ~ .r label.ctx:hover { color: #aaa; } }
|
|
||||||
|
|
||||||
#source p input:checked ~ .r label.ctx { background: #d0e8ff; color: #666; border-radius: .75em .75em 0 0; padding: 0 .5em; margin: -.25em 0; }
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) { #source p input:checked ~ .r label.ctx { background: #056; } }
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) { #source p input:checked ~ .r label.ctx { color: #aaa; } }
|
|
||||||
|
|
||||||
#source p input:checked ~ .r label.ctx::before { content: "▼ "; }
|
|
||||||
|
|
||||||
#source p input:checked ~ .ctxs { padding: .25em .5em; overflow-y: scroll; max-height: 10.5em; }
|
|
||||||
|
|
||||||
#source p label.ctx { color: #999; display: inline-block; padding: 0 .5em; font-size: .8333em; }
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) { #source p label.ctx { color: #777; } }
|
|
||||||
|
|
||||||
#source p .ctxs { display: block; max-height: 0; overflow-y: hidden; transition: all .2s; padding: 0 .5em; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; white-space: nowrap; background: #d0e8ff; border-radius: .25em; margin-right: 1.75em; text-align: right; }
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) { #source p .ctxs { background: #056; } }
|
|
||||||
|
|
||||||
#index { font-family: SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 0.875em; }
|
|
||||||
|
|
||||||
#index table.index { margin-left: -.5em; }
|
|
||||||
|
|
||||||
#index td, #index th { text-align: right; width: 5em; padding: .25em .5em; border-bottom: 1px solid #eee; }
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) { #index td, #index th { border-color: #333; } }
|
|
||||||
|
|
||||||
#index td.name, #index th.name { text-align: left; width: auto; }
|
|
||||||
|
|
||||||
#index th { font-style: italic; color: #333; cursor: pointer; }
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) { #index th { color: #ddd; } }
|
|
||||||
|
|
||||||
#index th:hover { background: #eee; }
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) { #index th:hover { background: #333; } }
|
|
||||||
|
|
||||||
#index th[aria-sort="ascending"], #index th[aria-sort="descending"] { white-space: nowrap; background: #eee; padding-left: .5em; }
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) { #index th[aria-sort="ascending"], #index th[aria-sort="descending"] { background: #333; } }
|
|
||||||
|
|
||||||
#index th[aria-sort="ascending"]::after { font-family: sans-serif; content: " ↑"; }
|
|
||||||
|
|
||||||
#index th[aria-sort="descending"]::after { font-family: sans-serif; content: " ↓"; }
|
|
||||||
|
|
||||||
#index td.name a { text-decoration: none; color: inherit; }
|
|
||||||
|
|
||||||
#index tr.total td, #index tr.total_dynamic td { font-weight: bold; border-top: 1px solid #ccc; border-bottom: none; }
|
|
||||||
|
|
||||||
#index tr.file:hover { background: #eee; }
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) { #index tr.file:hover { background: #333; } }
|
|
||||||
|
|
||||||
#index tr.file:hover td.name { text-decoration: underline; color: inherit; }
|
|
||||||
|
|
||||||
#scroll_marker { position: fixed; z-index: 3; right: 0; top: 0; width: 16px; height: 100%; background: #fff; border-left: 1px solid #eee; will-change: transform; }
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) { #scroll_marker { background: #1e1e1e; } }
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) { #scroll_marker { border-color: #333; } }
|
|
||||||
|
|
||||||
#scroll_marker .marker { background: #ccc; position: absolute; min-height: 3px; width: 100%; }
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) { #scroll_marker .marker { background: #444; } }
|
|
||||||
@@ -0,0 +1,284 @@
|
|||||||
|
# This file is @generated by PDM.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
|
||||||
|
[metadata]
|
||||||
|
groups = ["default", "dev"]
|
||||||
|
strategy = ["cross_platform"]
|
||||||
|
lock_version = "4.4"
|
||||||
|
content_hash = "sha256:474c773ee86217d652b5fc82f921ce2fbb513b244d50fbe82b74ea9e47dad96e"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "black"
|
||||||
|
version = "23.11.0"
|
||||||
|
requires_python = ">=3.8"
|
||||||
|
summary = "The uncompromising code formatter."
|
||||||
|
dependencies = [
|
||||||
|
"click>=8.0.0",
|
||||||
|
"mypy-extensions>=0.4.3",
|
||||||
|
"packaging>=22.0",
|
||||||
|
"pathspec>=0.9.0",
|
||||||
|
"platformdirs>=2",
|
||||||
|
]
|
||||||
|
files = [
|
||||||
|
{file = "black-23.11.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:cf57719e581cfd48c4efe28543fea3d139c6b6f1238b3f0102a9c73992cbb479"},
|
||||||
|
{file = "black-23.11.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:698c1e0d5c43354ec5d6f4d914d0d553a9ada56c85415700b81dc90125aac244"},
|
||||||
|
{file = "black-23.11.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:760415ccc20f9e8747084169110ef75d545f3b0932ee21368f63ac0fee86b221"},
|
||||||
|
{file = "black-23.11.0-cp311-cp311-win_amd64.whl", hash = "sha256:58e5f4d08a205b11800332920e285bd25e1a75c54953e05502052738fe16b3b5"},
|
||||||
|
{file = "black-23.11.0-py3-none-any.whl", hash = "sha256:54caaa703227c6e0c87b76326d0862184729a69b73d3b7305b6288e1d830067e"},
|
||||||
|
{file = "black-23.11.0.tar.gz", hash = "sha256:4c68855825ff432d197229846f971bc4d6666ce90492e5b02013bcaca4d9ab05"},
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "certifi"
|
||||||
|
version = "2023.7.22"
|
||||||
|
requires_python = ">=3.6"
|
||||||
|
summary = "Python package for providing Mozilla's CA Bundle."
|
||||||
|
files = [
|
||||||
|
{file = "certifi-2023.7.22-py3-none-any.whl", hash = "sha256:92d6037539857d8206b8f6ae472e8b77db8058fec5937a1ef3f54304089edbb9"},
|
||||||
|
{file = "certifi-2023.7.22.tar.gz", hash = "sha256:539cc1d13202e33ca466e88b2807e29f4c13049d6d87031a3c110744495cb082"},
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "charset-normalizer"
|
||||||
|
version = "3.2.0"
|
||||||
|
requires_python = ">=3.7.0"
|
||||||
|
summary = "The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet."
|
||||||
|
files = [
|
||||||
|
{file = "charset-normalizer-3.2.0.tar.gz", hash = "sha256:3bb3d25a8e6c0aedd251753a79ae98a093c7e7b471faa3aa9a93a81431987ace"},
|
||||||
|
{file = "charset_normalizer-3.2.0-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:4957669ef390f0e6719db3613ab3a7631e68424604a7b448f079bee145da6e09"},
|
||||||
|
{file = "charset_normalizer-3.2.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:46fb8c61d794b78ec7134a715a3e564aafc8f6b5e338417cb19fe9f57a5a9bf2"},
|
||||||
|
{file = "charset_normalizer-3.2.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:f779d3ad205f108d14e99bb3859aa7dd8e9c68874617c72354d7ecaec2a054ac"},
|
||||||
|
{file = "charset_normalizer-3.2.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f25c229a6ba38a35ae6e25ca1264621cc25d4d38dca2942a7fce0b67a4efe918"},
|
||||||
|
{file = "charset_normalizer-3.2.0-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:2efb1bd13885392adfda4614c33d3b68dee4921fd0ac1d3988f8cbb7d589e72a"},
|
||||||
|
{file = "charset_normalizer-3.2.0-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:1f30b48dd7fa1474554b0b0f3fdfdd4c13b5c737a3c6284d3cdc424ec0ffff3a"},
|
||||||
|
{file = "charset_normalizer-3.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:246de67b99b6851627d945db38147d1b209a899311b1305dd84916f2b88526c6"},
|
||||||
|
{file = "charset_normalizer-3.2.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:9bd9b3b31adcb054116447ea22caa61a285d92e94d710aa5ec97992ff5eb7cf3"},
|
||||||
|
{file = "charset_normalizer-3.2.0-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:8c2f5e83493748286002f9369f3e6607c565a6a90425a3a1fef5ae32a36d749d"},
|
||||||
|
{file = "charset_normalizer-3.2.0-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:3170c9399da12c9dc66366e9d14da8bf7147e1e9d9ea566067bbce7bb74bd9c2"},
|
||||||
|
{file = "charset_normalizer-3.2.0-cp311-cp311-musllinux_1_1_ppc64le.whl", hash = "sha256:7a4826ad2bd6b07ca615c74ab91f32f6c96d08f6fcc3902ceeedaec8cdc3bcd6"},
|
||||||
|
{file = "charset_normalizer-3.2.0-cp311-cp311-musllinux_1_1_s390x.whl", hash = "sha256:3b1613dd5aee995ec6d4c69f00378bbd07614702a315a2cf6c1d21461fe17c23"},
|
||||||
|
{file = "charset_normalizer-3.2.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:9e608aafdb55eb9f255034709e20d5a83b6d60c054df0802fa9c9883d0a937aa"},
|
||||||
|
{file = "charset_normalizer-3.2.0-cp311-cp311-win32.whl", hash = "sha256:f2a1d0fd4242bd8643ce6f98927cf9c04540af6efa92323e9d3124f57727bfc1"},
|
||||||
|
{file = "charset_normalizer-3.2.0-cp311-cp311-win_amd64.whl", hash = "sha256:681eb3d7e02e3c3655d1b16059fbfb605ac464c834a0c629048a30fad2b27489"},
|
||||||
|
{file = "charset_normalizer-3.2.0-py3-none-any.whl", hash = "sha256:8e098148dd37b4ce3baca71fb394c81dc5d9c7728c95df695d2dca218edf40e6"},
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "click"
|
||||||
|
version = "8.1.7"
|
||||||
|
requires_python = ">=3.7"
|
||||||
|
summary = "Composable command line interface toolkit"
|
||||||
|
dependencies = [
|
||||||
|
"colorama; platform_system == \"Windows\"",
|
||||||
|
]
|
||||||
|
files = [
|
||||||
|
{file = "click-8.1.7-py3-none-any.whl", hash = "sha256:ae74fb96c20a0277a1d615f1e4d73c8414f5a98db8b799a7931d1582f3390c28"},
|
||||||
|
{file = "click-8.1.7.tar.gz", hash = "sha256:ca9853ad459e787e2192211578cc907e7594e294c7ccc834310722b41b9ca6de"},
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "colorama"
|
||||||
|
version = "0.4.6"
|
||||||
|
requires_python = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7"
|
||||||
|
summary = "Cross-platform colored terminal text."
|
||||||
|
files = [
|
||||||
|
{file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"},
|
||||||
|
{file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"},
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "coverage"
|
||||||
|
version = "7.3.2"
|
||||||
|
requires_python = ">=3.8"
|
||||||
|
summary = "Code coverage measurement for Python"
|
||||||
|
files = [
|
||||||
|
{file = "coverage-7.3.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:ac8c802fa29843a72d32ec56d0ca792ad15a302b28ca6203389afe21f8fa062c"},
|
||||||
|
{file = "coverage-7.3.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:89a937174104339e3a3ffcf9f446c00e3a806c28b1841c63edb2b369310fd074"},
|
||||||
|
{file = "coverage-7.3.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e267e9e2b574a176ddb983399dec325a80dbe161f1a32715c780b5d14b5f583a"},
|
||||||
|
{file = "coverage-7.3.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:2443cbda35df0d35dcfb9bf8f3c02c57c1d6111169e3c85fc1fcc05e0c9f39a3"},
|
||||||
|
{file = "coverage-7.3.2-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4175e10cc8dda0265653e8714b3174430b07c1dca8957f4966cbd6c2b1b8065a"},
|
||||||
|
{file = "coverage-7.3.2-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:0cbf38419fb1a347aaf63481c00f0bdc86889d9fbf3f25109cf96c26b403fda1"},
|
||||||
|
{file = "coverage-7.3.2-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:5c913b556a116b8d5f6ef834038ba983834d887d82187c8f73dec21049abd65c"},
|
||||||
|
{file = "coverage-7.3.2-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:1981f785239e4e39e6444c63a98da3a1db8e971cb9ceb50a945ba6296b43f312"},
|
||||||
|
{file = "coverage-7.3.2-cp311-cp311-win32.whl", hash = "sha256:43668cabd5ca8258f5954f27a3aaf78757e6acf13c17604d89648ecc0cc66640"},
|
||||||
|
{file = "coverage-7.3.2-cp311-cp311-win_amd64.whl", hash = "sha256:e10c39c0452bf6e694511c901426d6b5ac005acc0f78ff265dbe36bf81f808a2"},
|
||||||
|
{file = "coverage-7.3.2-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:4cbae1051ab791debecc4a5dcc4a1ff45fc27b91b9aee165c8a27514dd160836"},
|
||||||
|
{file = "coverage-7.3.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:12d15ab5833a997716d76f2ac1e4b4d536814fc213c85ca72756c19e5a6b3d63"},
|
||||||
|
{file = "coverage-7.3.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3c7bba973ebee5e56fe9251300c00f1579652587a9f4a5ed8404b15a0471f216"},
|
||||||
|
{file = "coverage-7.3.2-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:fe494faa90ce6381770746077243231e0b83ff3f17069d748f645617cefe19d4"},
|
||||||
|
{file = "coverage-7.3.2-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f6e9589bd04d0461a417562649522575d8752904d35c12907d8c9dfeba588faf"},
|
||||||
|
{file = "coverage-7.3.2-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:d51ac2a26f71da1b57f2dc81d0e108b6ab177e7d30e774db90675467c847bbdf"},
|
||||||
|
{file = "coverage-7.3.2-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:99b89d9f76070237975b315b3d5f4d6956ae354a4c92ac2388a5695516e47c84"},
|
||||||
|
{file = "coverage-7.3.2-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:fa28e909776dc69efb6ed975a63691bc8172b64ff357e663a1bb06ff3c9b589a"},
|
||||||
|
{file = "coverage-7.3.2-cp312-cp312-win32.whl", hash = "sha256:289fe43bf45a575e3ab10b26d7b6f2ddb9ee2dba447499f5401cfb5ecb8196bb"},
|
||||||
|
{file = "coverage-7.3.2-cp312-cp312-win_amd64.whl", hash = "sha256:7dbc3ed60e8659bc59b6b304b43ff9c3ed858da2839c78b804973f613d3e92ed"},
|
||||||
|
{file = "coverage-7.3.2-pp38.pp39.pp310-none-any.whl", hash = "sha256:ae97af89f0fbf373400970c0a21eef5aa941ffeed90aee43650b81f7d7f47637"},
|
||||||
|
{file = "coverage-7.3.2.tar.gz", hash = "sha256:be32ad29341b0170e795ca590e1c07e81fc061cb5b10c74ce7203491484404ef"},
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "idna"
|
||||||
|
version = "3.4"
|
||||||
|
requires_python = ">=3.5"
|
||||||
|
summary = "Internationalized Domain Names in Applications (IDNA)"
|
||||||
|
files = [
|
||||||
|
{file = "idna-3.4-py3-none-any.whl", hash = "sha256:90b77e79eaa3eba6de819a0c442c0b4ceefc341a7a2ab77d7562bf49f425c5c2"},
|
||||||
|
{file = "idna-3.4.tar.gz", hash = "sha256:814f528e8dead7d329833b91c5faa87d60bf71824cd12a7530b5526063d02cb4"},
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "iniconfig"
|
||||||
|
version = "2.0.0"
|
||||||
|
requires_python = ">=3.7"
|
||||||
|
summary = "brain-dead simple config-ini parsing"
|
||||||
|
files = [
|
||||||
|
{file = "iniconfig-2.0.0-py3-none-any.whl", hash = "sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374"},
|
||||||
|
{file = "iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3"},
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "isort"
|
||||||
|
version = "5.12.0"
|
||||||
|
requires_python = ">=3.8.0"
|
||||||
|
summary = "A Python utility / library to sort Python imports."
|
||||||
|
files = [
|
||||||
|
{file = "isort-5.12.0-py3-none-any.whl", hash = "sha256:f84c2818376e66cf843d497486ea8fed8700b340f308f076c6fb1229dff318b6"},
|
||||||
|
{file = "isort-5.12.0.tar.gz", hash = "sha256:8bef7dde241278824a6d83f44a544709b065191b95b6e50894bdc722fcba0504"},
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "mypy-extensions"
|
||||||
|
version = "1.0.0"
|
||||||
|
requires_python = ">=3.5"
|
||||||
|
summary = "Type system extensions for programs checked with the mypy type checker."
|
||||||
|
files = [
|
||||||
|
{file = "mypy_extensions-1.0.0-py3-none-any.whl", hash = "sha256:4392f6c0eb8a5668a69e23d168ffa70f0be9ccfd32b5cc2d26a34ae5b844552d"},
|
||||||
|
{file = "mypy_extensions-1.0.0.tar.gz", hash = "sha256:75dbf8955dc00442a438fc4d0666508a9a97b6bd41aa2f0ffe9d2f2725af0782"},
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "packaging"
|
||||||
|
version = "23.1"
|
||||||
|
requires_python = ">=3.7"
|
||||||
|
summary = "Core utilities for Python packages"
|
||||||
|
files = [
|
||||||
|
{file = "packaging-23.1-py3-none-any.whl", hash = "sha256:994793af429502c4ea2ebf6bf664629d07c1a9fe974af92966e4b8d2df7edc61"},
|
||||||
|
{file = "packaging-23.1.tar.gz", hash = "sha256:a392980d2b6cffa644431898be54b0045151319d1e7ec34f0cfed48767dd334f"},
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pathspec"
|
||||||
|
version = "0.11.2"
|
||||||
|
requires_python = ">=3.7"
|
||||||
|
summary = "Utility library for gitignore style pattern matching of file paths."
|
||||||
|
files = [
|
||||||
|
{file = "pathspec-0.11.2-py3-none-any.whl", hash = "sha256:1d6ed233af05e679efb96b1851550ea95bbb64b7c490b0f5aa52996c11e92a20"},
|
||||||
|
{file = "pathspec-0.11.2.tar.gz", hash = "sha256:e0d8d0ac2f12da61956eb2306b69f9469b42f4deb0f3cb6ed47b9cce9996ced3"},
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "platformdirs"
|
||||||
|
version = "4.0.0"
|
||||||
|
requires_python = ">=3.7"
|
||||||
|
summary = "A small Python package for determining appropriate platform-specific dirs, e.g. a \"user data dir\"."
|
||||||
|
files = [
|
||||||
|
{file = "platformdirs-4.0.0-py3-none-any.whl", hash = "sha256:118c954d7e949b35437270383a3f2531e99dd93cf7ce4dc8340d3356d30f173b"},
|
||||||
|
{file = "platformdirs-4.0.0.tar.gz", hash = "sha256:cb633b2bcf10c51af60beb0ab06d2f1d69064b43abf4c185ca6b28865f3f9731"},
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pluggy"
|
||||||
|
version = "1.3.0"
|
||||||
|
requires_python = ">=3.8"
|
||||||
|
summary = "plugin and hook calling mechanisms for python"
|
||||||
|
files = [
|
||||||
|
{file = "pluggy-1.3.0-py3-none-any.whl", hash = "sha256:d89c696a773f8bd377d18e5ecda92b7a3793cbe66c87060a6fb58c7b6e1061f7"},
|
||||||
|
{file = "pluggy-1.3.0.tar.gz", hash = "sha256:cf61ae8f126ac6f7c451172cf30e3e43d3ca77615509771b3a984a0730651e12"},
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "prometheus-client"
|
||||||
|
version = "0.17.1"
|
||||||
|
requires_python = ">=3.6"
|
||||||
|
summary = "Python client for the Prometheus monitoring system."
|
||||||
|
files = [
|
||||||
|
{file = "prometheus_client-0.17.1-py3-none-any.whl", hash = "sha256:e537f37160f6807b8202a6fc4764cdd19bac5480ddd3e0d463c3002b34462101"},
|
||||||
|
{file = "prometheus_client-0.17.1.tar.gz", hash = "sha256:21e674f39831ae3f8acde238afd9a27a37d0d2fb5a28ea094f0ce25d2cbf2091"},
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pytest"
|
||||||
|
version = "7.4.3"
|
||||||
|
requires_python = ">=3.7"
|
||||||
|
summary = "pytest: simple powerful testing with Python"
|
||||||
|
dependencies = [
|
||||||
|
"colorama; sys_platform == \"win32\"",
|
||||||
|
"iniconfig",
|
||||||
|
"packaging",
|
||||||
|
"pluggy<2.0,>=0.12",
|
||||||
|
]
|
||||||
|
files = [
|
||||||
|
{file = "pytest-7.4.3-py3-none-any.whl", hash = "sha256:0d009c083ea859a71b76adf7c1d502e4bc170b80a8ef002da5806527b9591fac"},
|
||||||
|
{file = "pytest-7.4.3.tar.gz", hash = "sha256:d989d136982de4e3b29dabcc838ad581c64e8ed52c11fbe86ddebd9da0818cd5"},
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "python-json-logger"
|
||||||
|
version = "2.0.7"
|
||||||
|
requires_python = ">=3.6"
|
||||||
|
summary = "A python library adding a json log formatter"
|
||||||
|
files = [
|
||||||
|
{file = "python-json-logger-2.0.7.tar.gz", hash = "sha256:23e7ec02d34237c5aa1e29a070193a4ea87583bb4e7f8fd06d3de8264c4b2e1c"},
|
||||||
|
{file = "python_json_logger-2.0.7-py3-none-any.whl", hash = "sha256:f380b826a991ebbe3de4d897aeec42760035ac760345e57b812938dc8b35e2bd"},
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "qbittorrent-api"
|
||||||
|
version = "2023.9.53"
|
||||||
|
summary = "Python client for qBittorrent v4.1+ Web API."
|
||||||
|
dependencies = [
|
||||||
|
"packaging",
|
||||||
|
"requests>=2.16.0",
|
||||||
|
"six",
|
||||||
|
"urllib3>=1.24.2",
|
||||||
|
]
|
||||||
|
files = [
|
||||||
|
{file = "qbittorrent-api-2023.9.53.tar.gz", hash = "sha256:fead1b2f55b1227ea088ea7d90b5022d94694bfd9dd9176beb5ad1c195d044ff"},
|
||||||
|
{file = "qbittorrent_api-2023.9.53-py2.py3-none-any.whl", hash = "sha256:963ae59d16a9c4a9aa1714fb7f6799539dc2693136cdc0e377daab3612ca775a"},
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "requests"
|
||||||
|
version = "2.31.0"
|
||||||
|
requires_python = ">=3.7"
|
||||||
|
summary = "Python HTTP for Humans."
|
||||||
|
dependencies = [
|
||||||
|
"certifi>=2017.4.17",
|
||||||
|
"charset-normalizer<4,>=2",
|
||||||
|
"idna<4,>=2.5",
|
||||||
|
"urllib3<3,>=1.21.1",
|
||||||
|
]
|
||||||
|
files = [
|
||||||
|
{file = "requests-2.31.0-py3-none-any.whl", hash = "sha256:58cd2187c01e70e6e26505bca751777aa9f2ee0b7f4300988b709f44e013003f"},
|
||||||
|
{file = "requests-2.31.0.tar.gz", hash = "sha256:942c5a758f98d790eaed1a29cb6eefc7ffb0d1cf7af05c3d2791656dbd6ad1e1"},
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "six"
|
||||||
|
version = "1.16.0"
|
||||||
|
requires_python = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*"
|
||||||
|
summary = "Python 2 and 3 compatibility utilities"
|
||||||
|
files = [
|
||||||
|
{file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"},
|
||||||
|
{file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"},
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "urllib3"
|
||||||
|
version = "2.0.5"
|
||||||
|
requires_python = ">=3.7"
|
||||||
|
summary = "HTTP library with thread-safe connection pooling, file post, and more."
|
||||||
|
files = [
|
||||||
|
{file = "urllib3-2.0.5-py3-none-any.whl", hash = "sha256:ef16afa8ba34a1f989db38e1dbbe0c302e4289a47856990d0682e374563ce35e"},
|
||||||
|
{file = "urllib3-2.0.5.tar.gz", hash = "sha256:13abf37382ea2ce6fb744d4dad67838eec857c9f4f57009891805e0b5e123594"},
|
||||||
|
]
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
[project]
|
||||||
|
name = "prometheus-qbittorrent-exporter"
|
||||||
|
version = "1.4.0"
|
||||||
|
description = "Prometheus exporter for qbittorrent"
|
||||||
|
authors = [
|
||||||
|
{name = "Esteban Sanchez", email = "[email protected]"},
|
||||||
|
]
|
||||||
|
dependencies = [
|
||||||
|
"prometheus-client>=0.17.1",
|
||||||
|
"python-json-logger>=2.0.7",
|
||||||
|
"qbittorrent-api>=2023.9.53",
|
||||||
|
]
|
||||||
|
requires-python = ">=3.11"
|
||||||
|
readme = "README.md"
|
||||||
|
keywords = ["prometheus", "qbittorrent"]
|
||||||
|
license = {text = "GPL-3.0"}
|
||||||
|
classifiers = []
|
||||||
|
|
||||||
|
[project.urls]
|
||||||
|
Homepage = "https://github.com/esanchezm/prometheus-qbittorrent-exporter"
|
||||||
|
Downloads = "https://github.com/esanchezm/prometheus-qbittorrent-exporter/archive/1.4.0.tar.gz"
|
||||||
|
|
||||||
|
[project.scripts]
|
||||||
|
qbittorrent-exporter = "qbittorrent_exporter.exporter:main"
|
||||||
|
|
||||||
|
[build-system]
|
||||||
|
requires = ["pdm-backend"]
|
||||||
|
build-backend = "pdm.backend"
|
||||||
|
|
||||||
|
[tool.pdm.dev-dependencies]
|
||||||
|
dev = [
|
||||||
|
"pytest>=7.4.3",
|
||||||
|
"isort>=5.12.0",
|
||||||
|
"black>=23.11.0",
|
||||||
|
"coverage>=7.3.2",
|
||||||
|
]
|
||||||
Whitespace-only changes.
@@ -0,0 +1,309 @@
|
|||||||
|
import faulthandler
|
||||||
|
import logging
|
||||||
|
import os
|
||||||
|
import signal
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
from dataclasses import dataclass, field
|
||||||
|
from enum import StrEnum, auto
|
||||||
|
from typing import Any, Iterable
|
||||||
|
|
||||||
|
from prometheus_client import start_http_server
|
||||||
|
from prometheus_client.core import REGISTRY, CounterMetricFamily, GaugeMetricFamily
|
||||||
|
from pythonjsonlogger import jsonlogger
|
||||||
|
from qbittorrentapi import Client, TorrentStates
|
||||||
|
|
||||||
|
# Enable dumps on stderr in case of segfault
|
||||||
|
faulthandler.enable()
|
||||||
|
logger = logging.getLogger()
|
||||||
|
|
||||||
|
|
||||||
|
class MetricType(StrEnum):
|
||||||
|
"""
|
||||||
|
Represents possible metric types (used in this project).
|
||||||
|
"""
|
||||||
|
|
||||||
|
GAUGE = auto()
|
||||||
|
COUNTER = auto()
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class Metric:
|
||||||
|
"""
|
||||||
|
Contains data and metadata about a single counter or gauge.
|
||||||
|
"""
|
||||||
|
|
||||||
|
name: str
|
||||||
|
value: Any
|
||||||
|
labels: dict[str, str] = field(default_factory=lambda: {}) # Default to empty dict
|
||||||
|
help_text: str = ""
|
||||||
|
metric_type: MetricType = MetricType.GAUGE
|
||||||
|
|
||||||
|
|
||||||
|
class QbittorrentMetricsCollector:
|
||||||
|
def __init__(self, config: dict) -> None:
|
||||||
|
self.config = config
|
||||||
|
self.client = Client(
|
||||||
|
host=config["host"],
|
||||||
|
port=config["port"],
|
||||||
|
username=config["username"],
|
||||||
|
password=config["password"],
|
||||||
|
VERIFY_WEBUI_CERTIFICATE=config["verify_webui_certificate"],
|
||||||
|
)
|
||||||
|
|
||||||
|
def collect(self) -> Iterable[GaugeMetricFamily | CounterMetricFamily]:
|
||||||
|
"""
|
||||||
|
Yields Prometheus gauges and counters from metrics collected from qbittorrent.
|
||||||
|
"""
|
||||||
|
metrics: list[Metric] = self.get_qbittorrent_metrics()
|
||||||
|
|
||||||
|
for metric in metrics:
|
||||||
|
if metric.metric_type == MetricType.COUNTER:
|
||||||
|
prom_metric = CounterMetricFamily(
|
||||||
|
metric.name, metric.help_text, labels=list(metric.labels.keys())
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
prom_metric = GaugeMetricFamily(
|
||||||
|
metric.name, metric.help_text, labels=list(metric.labels.keys())
|
||||||
|
)
|
||||||
|
prom_metric.add_metric(
|
||||||
|
value=metric.value, labels=list(metric.labels.values())
|
||||||
|
)
|
||||||
|
yield prom_metric
|
||||||
|
|
||||||
|
def get_qbittorrent_metrics(self) -> list[Metric]:
|
||||||
|
"""
|
||||||
|
Calls and combines qbittorrent state metrics with torrent metrics.
|
||||||
|
"""
|
||||||
|
metrics: list[Metric] = []
|
||||||
|
metrics.extend(self._get_qbittorrent_status_metrics())
|
||||||
|
metrics.extend(self._get_qbittorrent_torrent_tags_metrics())
|
||||||
|
|
||||||
|
return metrics
|
||||||
|
|
||||||
|
def _get_qbittorrent_status_metrics(self) -> list[Metric]:
|
||||||
|
"""
|
||||||
|
Returns metrics about the state of the qbittorrent server.
|
||||||
|
"""
|
||||||
|
response: dict[str, Any] = {}
|
||||||
|
version: str = ""
|
||||||
|
|
||||||
|
# Fetch data from API
|
||||||
|
try:
|
||||||
|
response = self.client.transfer.info
|
||||||
|
version = self.client.app.version
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Couldn't get server info: {e}")
|
||||||
|
|
||||||
|
return [
|
||||||
|
Metric(
|
||||||
|
name=f"{self.config['metrics_prefix']}_up",
|
||||||
|
value=bool(response),
|
||||||
|
labels={"version": version},
|
||||||
|
help_text=(
|
||||||
|
"Whether the qBittorrent server is answering requests from this"
|
||||||
|
" exporter. A `version` label with the server version is added."
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Metric(
|
||||||
|
name=f"{self.config['metrics_prefix']}_connected",
|
||||||
|
value=response.get("connection_status", "") == "connected",
|
||||||
|
labels={}, # no labels in the example
|
||||||
|
help_text=(
|
||||||
|
"Whether the qBittorrent server is connected to the Bittorrent"
|
||||||
|
" network."
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Metric(
|
||||||
|
name=f"{self.config['metrics_prefix']}_firewalled",
|
||||||
|
value=response.get("connection_status", "") == "firewalled",
|
||||||
|
labels={}, # no labels in the example
|
||||||
|
help_text=(
|
||||||
|
"Whether the qBittorrent server is connected to the Bittorrent"
|
||||||
|
" network but is behind a firewall."
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Metric(
|
||||||
|
name=f"{self.config['metrics_prefix']}_dht_nodes",
|
||||||
|
value=response.get("dht_nodes", 0),
|
||||||
|
labels={}, # no labels in the example
|
||||||
|
help_text="Number of DHT nodes connected to.",
|
||||||
|
),
|
||||||
|
Metric(
|
||||||
|
name=f"{self.config['metrics_prefix']}_dl_info_data",
|
||||||
|
value=response.get("dl_info_data", 0),
|
||||||
|
labels={}, # no labels in the example
|
||||||
|
help_text="Data downloaded since the server started, in bytes.",
|
||||||
|
metric_type=MetricType.COUNTER,
|
||||||
|
),
|
||||||
|
Metric(
|
||||||
|
name=f"{self.config['metrics_prefix']}_up_info_data",
|
||||||
|
value=response.get("up_info_data", 0),
|
||||||
|
labels={}, # no labels in the example
|
||||||
|
help_text="Data uploaded since the server started, in bytes.",
|
||||||
|
metric_type=MetricType.COUNTER,
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
||||||
|
def _fetch_categories(self) -> dict:
|
||||||
|
"""Fetches all categories in use from qbittorrent."""
|
||||||
|
try:
|
||||||
|
categories = dict(self.client.torrent_categories.categories)
|
||||||
|
for key, value in categories.items():
|
||||||
|
categories[key] = dict(value) # type: ignore
|
||||||
|
return categories
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Couldn't fetch categories: {e}")
|
||||||
|
return {}
|
||||||
|
|
||||||
|
def _fetch_torrents(self) -> list[dict]:
|
||||||
|
"""Fetches torrents from qbittorrent"""
|
||||||
|
try:
|
||||||
|
return [dict(_attr_dict) for _attr_dict in self.client.torrents.info()]
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Couldn't fetch torrents: {e}")
|
||||||
|
return []
|
||||||
|
|
||||||
|
def _filter_torrents_by_category(
|
||||||
|
self, category: str, torrents: list[dict]
|
||||||
|
) -> list[dict]:
|
||||||
|
"""Filters torrents by the given category."""
|
||||||
|
return [
|
||||||
|
torrent
|
||||||
|
for torrent in torrents
|
||||||
|
if torrent["category"] == category
|
||||||
|
or (category == "Uncategorized" and torrent["category"] == "")
|
||||||
|
]
|
||||||
|
|
||||||
|
def _filter_torrents_by_state(
|
||||||
|
self, state: TorrentStates, torrents: list[dict]
|
||||||
|
) -> list[dict]:
|
||||||
|
"""Filters torrents by the given state."""
|
||||||
|
return [torrent for torrent in torrents if torrent["state"] == state.value]
|
||||||
|
|
||||||
|
def _construct_metric(self, state: str, category: str, count: int) -> Metric:
|
||||||
|
"""Constructs and returns a metric object with a torrent count and appropriate
|
||||||
|
labels."""
|
||||||
|
return Metric(
|
||||||
|
name=f"{self.config['metrics_prefix']}_torrents_count",
|
||||||
|
value=count,
|
||||||
|
labels={
|
||||||
|
"status": state,
|
||||||
|
"category": category,
|
||||||
|
},
|
||||||
|
help_text=f"Number of torrents in status {state} under category {category}",
|
||||||
|
)
|
||||||
|
|
||||||
|
def _get_qbittorrent_torrent_tags_metrics(self) -> list[Metric]:
|
||||||
|
categories = self._fetch_categories()
|
||||||
|
torrents = self._fetch_torrents()
|
||||||
|
|
||||||
|
metrics: list[Metric] = []
|
||||||
|
categories["Uncategorized"] = {"name": "Uncategorized", "savePath": ""}
|
||||||
|
|
||||||
|
for category in categories:
|
||||||
|
category_torrents = self._filter_torrents_by_category(category, torrents)
|
||||||
|
for state in TorrentStates:
|
||||||
|
state_torrents = self._filter_torrents_by_state(
|
||||||
|
state, category_torrents
|
||||||
|
)
|
||||||
|
metric = self._construct_metric(
|
||||||
|
state.value, category, len(state_torrents)
|
||||||
|
)
|
||||||
|
metrics.append(metric)
|
||||||
|
|
||||||
|
return metrics
|
||||||
|
|
||||||
|
|
||||||
|
class ShutdownSignalHandler:
|
||||||
|
def __init__(self):
|
||||||
|
self.shutdown_count: int = 0
|
||||||
|
|
||||||
|
# Register signal handler
|
||||||
|
signal.signal(signal.SIGINT, self._on_signal_received)
|
||||||
|
signal.signal(signal.SIGTERM, self._on_signal_received)
|
||||||
|
|
||||||
|
def is_shutting_down(self):
|
||||||
|
return self.shutdown_count > 0
|
||||||
|
|
||||||
|
def _on_signal_received(self, signal, frame):
|
||||||
|
if self.shutdown_count > 1:
|
||||||
|
logger.warn("Forcibly killing exporter")
|
||||||
|
sys.exit(1)
|
||||||
|
logger.info("Exporter is shutting down")
|
||||||
|
self.shutdown_count += 1
|
||||||
|
|
||||||
|
|
||||||
|
def _get_config_value(key: str, default: str = "") -> str:
|
||||||
|
input_path = os.environ.get("FILE__" + key, None)
|
||||||
|
if input_path is not None:
|
||||||
|
try:
|
||||||
|
with open(input_path, "r") as input_file:
|
||||||
|
return input_file.read().strip()
|
||||||
|
except IOError as e:
|
||||||
|
logger.error(f"Unable to read value for {key} from {input_path}: {str(e)}")
|
||||||
|
|
||||||
|
return os.environ.get(key, default)
|
||||||
|
|
||||||
|
|
||||||
|
def get_config() -> dict:
|
||||||
|
"""Loads all config values."""
|
||||||
|
return {
|
||||||
|
"host": _get_config_value("QBITTORRENT_HOST", ""),
|
||||||
|
"port": _get_config_value("QBITTORRENT_PORT", ""),
|
||||||
|
"username": _get_config_value("QBITTORRENT_USER", ""),
|
||||||
|
"password": _get_config_value("QBITTORRENT_PASS", ""),
|
||||||
|
"exporter_port": int(_get_config_value("EXPORTER_PORT", "8000")),
|
||||||
|
"log_level": _get_config_value("EXPORTER_LOG_LEVEL", "INFO"),
|
||||||
|
"metrics_prefix": _get_config_value("METRICS_PREFIX", "qbittorrent"),
|
||||||
|
"verify_webui_certificate": (
|
||||||
|
_get_config_value("VERIFY_WEBUI_CERTIFICATE", "True") == "True"
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
# Init logger so it can be used
|
||||||
|
logHandler = logging.StreamHandler()
|
||||||
|
formatter = jsonlogger.JsonFormatter(
|
||||||
|
"%(asctime) %(levelname) %(message)", datefmt="%Y-%m-%d %H:%M:%S"
|
||||||
|
)
|
||||||
|
logHandler.setFormatter(formatter)
|
||||||
|
logger.addHandler(logHandler)
|
||||||
|
logger.setLevel("INFO") # default until config is loaded
|
||||||
|
|
||||||
|
config = get_config()
|
||||||
|
|
||||||
|
# set level once config has been loaded
|
||||||
|
logger.setLevel(config["log_level"])
|
||||||
|
|
||||||
|
# Register signal handler
|
||||||
|
signal_handler = ShutdownSignalHandler()
|
||||||
|
|
||||||
|
if not config["host"]:
|
||||||
|
logger.error(
|
||||||
|
"No host specified, please set QBITTORRENT_HOST environment variable"
|
||||||
|
)
|
||||||
|
sys.exit(1)
|
||||||
|
if not config["port"]:
|
||||||
|
logger.error(
|
||||||
|
"No port specified, please set QBITTORRENT_PORT environment variable"
|
||||||
|
)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
# Register our custom collector
|
||||||
|
logger.info("Exporter is starting up")
|
||||||
|
REGISTRY.register(QbittorrentMetricsCollector(config)) # type: ignore
|
||||||
|
|
||||||
|
# Start server
|
||||||
|
start_http_server(config["exporter_port"])
|
||||||
|
logger.info(f"Exporter listening on port {config['exporter_port']}")
|
||||||
|
|
||||||
|
while not signal_handler.is_shutting_down():
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
logger.info("Exporter has shutdown")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
Whitespace-only changes.
@@ -0,0 +1,276 @@
|
|||||||
|
import unittest
|
||||||
|
from unittest.mock import MagicMock, patch
|
||||||
|
|
||||||
|
from prometheus_client.metrics_core import CounterMetricFamily, GaugeMetricFamily
|
||||||
|
|
||||||
|
from qbittorrent_exporter.exporter import (
|
||||||
|
Metric,
|
||||||
|
MetricType,
|
||||||
|
QbittorrentMetricsCollector,
|
||||||
|
)
|
||||||
|
from qbittorrentapi import TorrentStates
|
||||||
|
|
||||||
|
|
||||||
|
class TestQbittorrentMetricsCollector(unittest.TestCase):
|
||||||
|
@patch("qbittorrent_exporter.exporter.Client")
|
||||||
|
def setUp(self, mock_client):
|
||||||
|
self.mock_client = mock_client
|
||||||
|
self.config = {
|
||||||
|
"host": "localhost",
|
||||||
|
"port": "8080",
|
||||||
|
"username": "user",
|
||||||
|
"password": "pass",
|
||||||
|
"verify_webui_certificate": False,
|
||||||
|
"metrics_prefix": "qbittorrent",
|
||||||
|
}
|
||||||
|
self.torrentsState = [
|
||||||
|
{"name": "Torrent DOWNLOADING 1", "state": TorrentStates.DOWNLOADING},
|
||||||
|
{"name": "Torrent UPLOADING 1", "state": TorrentStates.UPLOADING},
|
||||||
|
{"name": "Torrent DOWNLOADING 2", "state": TorrentStates.DOWNLOADING},
|
||||||
|
{"name": "Torrent UPLOADING 2", "state": TorrentStates.UPLOADING},
|
||||||
|
]
|
||||||
|
self.torrentsCategories = [
|
||||||
|
{"name": "Torrent Movies 1", "category": "Movies"},
|
||||||
|
{"name": "Torrent Music 1", "category": "Music"},
|
||||||
|
{"name": "Torrent Movies 2", "category": "Movies"},
|
||||||
|
{"name": "Torrent unknown", "category": ""},
|
||||||
|
{"name": "Torrent Music 2", "category": "Music"},
|
||||||
|
{"name": "Torrent Uncategorized 1", "category": "Uncategorized"},
|
||||||
|
]
|
||||||
|
self.collector = QbittorrentMetricsCollector(self.config)
|
||||||
|
|
||||||
|
def test_init(self):
|
||||||
|
self.assertEqual(self.collector.config, self.config)
|
||||||
|
self.mock_client.assert_called_once_with(
|
||||||
|
host=self.config["host"],
|
||||||
|
port=self.config["port"],
|
||||||
|
username=self.config["username"],
|
||||||
|
password=self.config["password"],
|
||||||
|
VERIFY_WEBUI_CERTIFICATE=self.config["verify_webui_certificate"],
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_collect_gauge(self):
|
||||||
|
mock_metric = Metric(
|
||||||
|
name="test_gauge",
|
||||||
|
metric_type=MetricType.GAUGE,
|
||||||
|
help_text="Test Gauge",
|
||||||
|
labels={"label1": "value1"},
|
||||||
|
value=10,
|
||||||
|
)
|
||||||
|
self.collector.get_qbittorrent_metrics = MagicMock(return_value=[mock_metric])
|
||||||
|
|
||||||
|
result = next(self.collector.collect())
|
||||||
|
|
||||||
|
self.assertIsInstance(result, GaugeMetricFamily)
|
||||||
|
self.assertEqual(result.name, "test_gauge")
|
||||||
|
self.assertEqual(result.documentation, "Test Gauge")
|
||||||
|
self.assertEqual(result.samples[0].labels, {"label1": "value1"})
|
||||||
|
self.assertEqual(result.samples[0].value, 10)
|
||||||
|
|
||||||
|
def test_collect_counter(self):
|
||||||
|
mock_metric = Metric(
|
||||||
|
name="test_counter",
|
||||||
|
metric_type=MetricType.COUNTER,
|
||||||
|
help_text="Test Counter",
|
||||||
|
labels={"label2": "value2"},
|
||||||
|
value=230,
|
||||||
|
)
|
||||||
|
self.collector.get_qbittorrent_metrics = MagicMock(return_value=[mock_metric])
|
||||||
|
|
||||||
|
result = next(self.collector.collect())
|
||||||
|
|
||||||
|
self.assertIsInstance(result, CounterMetricFamily)
|
||||||
|
self.assertEqual(result.name, "test_counter")
|
||||||
|
self.assertEqual(result.documentation, "Test Counter")
|
||||||
|
self.assertEqual(result.samples[0].labels, {"label2": "value2"})
|
||||||
|
self.assertEqual(result.samples[0].value, 230)
|
||||||
|
|
||||||
|
def test_get_qbittorrent_metrics(self):
|
||||||
|
metrics = self.collector.get_qbittorrent_metrics()
|
||||||
|
self.assertNotEqual(len(metrics), 0)
|
||||||
|
|
||||||
|
def test_fetch_categories(self):
|
||||||
|
# Mock the client.torrent_categories.categories attribute
|
||||||
|
self.collector.client.torrent_categories.categories = {
|
||||||
|
"category1": {"name": "Category 1"},
|
||||||
|
"category2": {"name": "Category 2"},
|
||||||
|
"category3": {"name": "Category 3"},
|
||||||
|
}
|
||||||
|
|
||||||
|
categories = self.collector._fetch_categories()
|
||||||
|
self.assertIsInstance(categories, dict)
|
||||||
|
self.assertNotEqual(len(categories), 0)
|
||||||
|
self.assertEqual(categories["category1"]["name"], "Category 1")
|
||||||
|
self.assertEqual(categories["category2"]["name"], "Category 2")
|
||||||
|
self.assertEqual(categories["category3"]["name"], "Category 3")
|
||||||
|
|
||||||
|
def test_fetch_categories_exception(self):
|
||||||
|
self.collector.client.torrent_categories.categories = Exception(
|
||||||
|
"Error fetching categories"
|
||||||
|
)
|
||||||
|
categories = self.collector._fetch_categories()
|
||||||
|
self.assertEqual(categories, {})
|
||||||
|
|
||||||
|
def test_fetch_torrents_success(self):
|
||||||
|
# Mock the return value of self.client.torrents.info()
|
||||||
|
self.collector.client.torrents.info.return_value = [
|
||||||
|
{"name": "Torrent 1", "size": 100},
|
||||||
|
{"name": "Torrent 2", "size": 200},
|
||||||
|
{"name": "Torrent 3", "size": 300},
|
||||||
|
]
|
||||||
|
|
||||||
|
expected_result = [
|
||||||
|
{"name": "Torrent 1", "size": 100},
|
||||||
|
{"name": "Torrent 2", "size": 200},
|
||||||
|
{"name": "Torrent 3", "size": 300},
|
||||||
|
]
|
||||||
|
|
||||||
|
result = self.collector._fetch_torrents()
|
||||||
|
self.assertEqual(result, expected_result)
|
||||||
|
|
||||||
|
def test_fetch_torrents_exception(self):
|
||||||
|
# Mock an exception being raised by self.client.torrents.info()
|
||||||
|
self.collector.client.torrents.info.side_effect = Exception("Connection error")
|
||||||
|
|
||||||
|
expected_result = []
|
||||||
|
|
||||||
|
result = self.collector._fetch_torrents()
|
||||||
|
self.assertEqual(result, expected_result)
|
||||||
|
|
||||||
|
def test_filter_torrents_by_state(self):
|
||||||
|
expected = [
|
||||||
|
{"name": "Torrent DOWNLOADING 1", "state": TorrentStates.DOWNLOADING},
|
||||||
|
{"name": "Torrent DOWNLOADING 2", "state": TorrentStates.DOWNLOADING},
|
||||||
|
]
|
||||||
|
result = self.collector._filter_torrents_by_state(
|
||||||
|
TorrentStates.DOWNLOADING, self.torrentsState
|
||||||
|
)
|
||||||
|
self.assertEqual(result, expected)
|
||||||
|
|
||||||
|
expected = [
|
||||||
|
{"name": "Torrent UPLOADING 1", "state": TorrentStates.UPLOADING},
|
||||||
|
{"name": "Torrent UPLOADING 2", "state": TorrentStates.UPLOADING},
|
||||||
|
]
|
||||||
|
result = self.collector._filter_torrents_by_state(
|
||||||
|
TorrentStates.UPLOADING, self.torrentsState
|
||||||
|
)
|
||||||
|
self.assertEqual(result, expected)
|
||||||
|
|
||||||
|
expected = []
|
||||||
|
result = self.collector._filter_torrents_by_state(
|
||||||
|
TorrentStates.ERROR, self.torrentsState
|
||||||
|
)
|
||||||
|
self.assertEqual(result, expected)
|
||||||
|
|
||||||
|
def test_filter_torrents_by_category(self):
|
||||||
|
expected_result = [
|
||||||
|
{"name": "Torrent Movies 1", "category": "Movies"},
|
||||||
|
{"name": "Torrent Movies 2", "category": "Movies"},
|
||||||
|
]
|
||||||
|
result = self.collector._filter_torrents_by_category(
|
||||||
|
"Movies", self.torrentsCategories
|
||||||
|
)
|
||||||
|
self.assertEqual(result, expected_result)
|
||||||
|
|
||||||
|
expected_result = [
|
||||||
|
{"name": "Torrent unknown", "category": ""},
|
||||||
|
{"name": "Torrent Uncategorized 1", "category": "Uncategorized"},
|
||||||
|
]
|
||||||
|
result = self.collector._filter_torrents_by_category(
|
||||||
|
"Uncategorized", self.torrentsCategories
|
||||||
|
)
|
||||||
|
self.assertEqual(result, expected_result)
|
||||||
|
|
||||||
|
expected_result = []
|
||||||
|
result = self.collector._filter_torrents_by_category(
|
||||||
|
"Books", self.torrentsCategories
|
||||||
|
)
|
||||||
|
self.assertEqual(result, expected_result)
|
||||||
|
|
||||||
|
def test_construct_metric_with_valid_state_and_category(self):
|
||||||
|
state = "downloading"
|
||||||
|
category = "movies"
|
||||||
|
count = 10
|
||||||
|
|
||||||
|
metric = self.collector._construct_metric(state, category, count)
|
||||||
|
|
||||||
|
self.assertEqual(metric.name, "qbittorrent_torrents_count")
|
||||||
|
self.assertEqual(metric.value, count)
|
||||||
|
self.assertEqual(metric.labels["status"], state)
|
||||||
|
self.assertEqual(metric.labels["category"], category)
|
||||||
|
self.assertEqual(
|
||||||
|
metric.help_text,
|
||||||
|
f"Number of torrents in status {state} under category {category}",
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_construct_metric_with_empty_state_and_category(self):
|
||||||
|
state = ""
|
||||||
|
category = ""
|
||||||
|
count = 5
|
||||||
|
|
||||||
|
metric = self.collector._construct_metric(state, category, count)
|
||||||
|
|
||||||
|
self.assertEqual(metric.name, "qbittorrent_torrents_count")
|
||||||
|
self.assertEqual(metric.value, count)
|
||||||
|
self.assertEqual(metric.labels["status"], state)
|
||||||
|
self.assertEqual(metric.labels["category"], category)
|
||||||
|
self.assertEqual(
|
||||||
|
metric.help_text, "Number of torrents in status under category "
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_get_qbittorrent_status_metrics(self):
|
||||||
|
self.collector.client.transfer.info = {"connection_status": "connected"}
|
||||||
|
self.collector.client.app.version = "1.2.3"
|
||||||
|
|
||||||
|
expected_metrics = [
|
||||||
|
Metric(
|
||||||
|
name="qbittorrent_up",
|
||||||
|
value=True,
|
||||||
|
labels={"version": "1.2.3"},
|
||||||
|
help_text=(
|
||||||
|
"Whether the qBittorrent server is answering requests from this"
|
||||||
|
" exporter. A `version` label with the server version is added."
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Metric(
|
||||||
|
name="qbittorrent_connected",
|
||||||
|
value=True,
|
||||||
|
labels={},
|
||||||
|
help_text=(
|
||||||
|
"Whether the qBittorrent server is connected to the Bittorrent"
|
||||||
|
" network."
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Metric(
|
||||||
|
name="qbittorrent_firewalled",
|
||||||
|
value=False,
|
||||||
|
labels={},
|
||||||
|
help_text=(
|
||||||
|
"Whether the qBittorrent server is connected to the Bittorrent"
|
||||||
|
" network but is behind a firewall."
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Metric(
|
||||||
|
name="qbittorrent_dht_nodes",
|
||||||
|
value=0,
|
||||||
|
labels={},
|
||||||
|
help_text="Number of DHT nodes connected to.",
|
||||||
|
),
|
||||||
|
Metric(
|
||||||
|
name="qbittorrent_dl_info_data",
|
||||||
|
value=0,
|
||||||
|
labels={},
|
||||||
|
help_text="Data downloaded since the server started, in bytes.",
|
||||||
|
metric_type=MetricType.COUNTER,
|
||||||
|
),
|
||||||
|
Metric(
|
||||||
|
name="qbittorrent_up_info_data",
|
||||||
|
value=0,
|
||||||
|
labels={},
|
||||||
|
help_text="Data uploaded since the server started, in bytes.",
|
||||||
|
metric_type=MetricType.COUNTER,
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
||||||
|
metrics = self.collector._get_qbittorrent_status_metrics()
|
||||||
|
self.assertEqual(metrics, expected_metrics)
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import unittest
|
||||||
|
|
||||||
|
from qbittorrent_exporter.exporter import Metric, MetricType
|
||||||
|
|
||||||
|
|
||||||
|
class TestMetric(unittest.TestCase):
|
||||||
|
def test_metric_initialization(self):
|
||||||
|
metric = Metric(name="test_metric", value=10)
|
||||||
|
self.assertEqual(metric.name, "test_metric")
|
||||||
|
self.assertEqual(metric.value, 10)
|
||||||
|
self.assertEqual(metric.labels, {})
|
||||||
|
self.assertEqual(metric.help_text, "")
|
||||||
|
self.assertEqual(metric.metric_type, MetricType.GAUGE)
|
||||||
Reference in new issue
Block a user