mirror of
https://github.com/ep1cman/unifi-protect-backup.git
synced 2025-12-05 23:53:30 +00:00
Initial commit
This commit is contained in:
12
.bumpversion.cfg
Normal file
12
.bumpversion.cfg
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
[bumpversion]
|
||||||
|
current_version = 0.1.0
|
||||||
|
commit = True
|
||||||
|
tag = True
|
||||||
|
|
||||||
|
[bumpversion:file:pyproject.toml]
|
||||||
|
search = version = "{current_version}"
|
||||||
|
replace = version = "{new_version}"
|
||||||
|
|
||||||
|
[bumpversion:file:unifi_protect_backup/__init__.py]
|
||||||
|
search = __version__ = '{current_version}'
|
||||||
|
replace = __version__ = '{new_version}'
|
||||||
24
.editorconfig
Normal file
24
.editorconfig
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
# http://editorconfig.org
|
||||||
|
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
insert_final_newline = true
|
||||||
|
charset = utf-8
|
||||||
|
end_of_line = lf
|
||||||
|
|
||||||
|
[*.bat]
|
||||||
|
indent_style = tab
|
||||||
|
end_of_line = crlf
|
||||||
|
|
||||||
|
[LICENSE]
|
||||||
|
insert_final_newline = false
|
||||||
|
|
||||||
|
[Makefile]
|
||||||
|
indent_style = tab
|
||||||
|
|
||||||
|
[*.{yml, yaml}]
|
||||||
|
indent_size = 2
|
||||||
15
.github/ISSUE_TEMPLATE.md
vendored
Normal file
15
.github/ISSUE_TEMPLATE.md
vendored
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
* Unifi Protect Backup version:
|
||||||
|
* Python version:
|
||||||
|
* Operating System:
|
||||||
|
|
||||||
|
### Description
|
||||||
|
|
||||||
|
Describe what you were trying to get done.
|
||||||
|
Tell us what happened, what went wrong, and what you expected to happen.
|
||||||
|
|
||||||
|
### What I Did
|
||||||
|
|
||||||
|
```
|
||||||
|
Paste the command(s) you ran and the output.
|
||||||
|
If there was a crash, please include the traceback here.
|
||||||
|
```
|
||||||
50
.github/workflows/dev.yml
vendored
Normal file
50
.github/workflows/dev.yml
vendored
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
# This is a basic workflow to help you get started with Actions
|
||||||
|
|
||||||
|
name: dev workflow
|
||||||
|
|
||||||
|
# Controls when the action will run.
|
||||||
|
on:
|
||||||
|
# Triggers the workflow on push or pull request events but only for the master branch
|
||||||
|
push:
|
||||||
|
branches: [ master, main ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ master, main ]
|
||||||
|
|
||||||
|
# Allows you to run this workflow manually from the Actions tab
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
|
||||||
|
jobs:
|
||||||
|
# This workflow contains a single job called "test"
|
||||||
|
test:
|
||||||
|
# The type of runner that the job will run on
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
python-versions: [3.7, 3.8, 3.9]
|
||||||
|
os: [ubuntu-18.04, macos-latest, windows-latest]
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
||||||
|
# Steps represent a sequence of tasks that will be executed as part of the job
|
||||||
|
steps:
|
||||||
|
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-python@v2
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-versions }}
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip install poetry tox tox-gh-actions
|
||||||
|
|
||||||
|
- name: test with tox
|
||||||
|
run:
|
||||||
|
tox
|
||||||
|
|
||||||
|
- name: list files
|
||||||
|
run: ls -l .
|
||||||
|
|
||||||
|
- uses: codecov/codecov-action@v1
|
||||||
|
with:
|
||||||
|
fail_ci_if_error: true
|
||||||
|
files: coverage.xml
|
||||||
50
.github/workflows/preview.yml
vendored
Normal file
50
.github/workflows/preview.yml
vendored
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
# This is a basic workflow to help you get started with Actions
|
||||||
|
|
||||||
|
name: stage & preview workflow
|
||||||
|
|
||||||
|
# Controls when the action will run.
|
||||||
|
on:
|
||||||
|
# Triggers the workflow on push or pull request events but only for the master branch
|
||||||
|
push:
|
||||||
|
branches: [ master, main ]
|
||||||
|
|
||||||
|
# Allows you to run this workflow manually from the Actions tab
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
|
||||||
|
jobs:
|
||||||
|
publish_dev_build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
python-versions: [ 3.8 ]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-python@v2
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-versions }}
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip install poetry tox tox-gh-actions
|
||||||
|
|
||||||
|
- name: test with tox
|
||||||
|
run:
|
||||||
|
tox
|
||||||
|
|
||||||
|
- name: Build wheels and source tarball
|
||||||
|
run: |
|
||||||
|
poetry version $(poetry version --short)-dev.$GITHUB_RUN_NUMBER
|
||||||
|
poetry version --short
|
||||||
|
poetry build
|
||||||
|
|
||||||
|
- name: publish to Test PyPI
|
||||||
|
uses: pypa/gh-action-pypi-publish@master
|
||||||
|
with:
|
||||||
|
user: __token__
|
||||||
|
password: ${{ secrets.TEST_PYPI_API_TOKEN}}
|
||||||
|
repository_url: https://test.pypi.org/legacy/
|
||||||
|
skip_existing: true
|
||||||
89
.github/workflows/release.yml
vendored
Normal file
89
.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
# Publish package on main branch if it's tagged with 'v*'
|
||||||
|
|
||||||
|
name: release & publish workflow
|
||||||
|
|
||||||
|
# Controls when the action will run.
|
||||||
|
on:
|
||||||
|
# Triggers the workflow on push events but only for the master branch
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
|
||||||
|
# Allows you to run this workflow manually from the Actions tab
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
|
||||||
|
jobs:
|
||||||
|
# This workflow contains a single job called "release"
|
||||||
|
release:
|
||||||
|
name: Create Release
|
||||||
|
runs-on: ubuntu-20.04
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
python-versions: [3.8]
|
||||||
|
|
||||||
|
# Steps represent a sequence of tasks that will be executed as part of the job
|
||||||
|
steps:
|
||||||
|
- name: Get version from tag
|
||||||
|
id: tag_name
|
||||||
|
run: |
|
||||||
|
echo ::set-output name=current_version::${GITHUB_REF#refs/tags/v}
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Get Changelog Entry
|
||||||
|
id: changelog_reader
|
||||||
|
uses: mindsers/changelog-reader-action@v2
|
||||||
|
with:
|
||||||
|
validation_depth: 10
|
||||||
|
version: ${{ steps.tag_name.outputs.current_version }}
|
||||||
|
path: ./CHANGELOG.md
|
||||||
|
|
||||||
|
- uses: actions/setup-python@v2
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-versions }}
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip install poetry
|
||||||
|
|
||||||
|
- name: build documentation
|
||||||
|
run: |
|
||||||
|
poetry install -E doc
|
||||||
|
poetry run mkdocs build
|
||||||
|
|
||||||
|
- name: publish documentation
|
||||||
|
uses: peaceiris/actions-gh-pages@v3
|
||||||
|
with:
|
||||||
|
personal_token: ${{ secrets.PERSONAL_TOKEN }}
|
||||||
|
publish_dir: ./site
|
||||||
|
|
||||||
|
- name: Build wheels and source tarball
|
||||||
|
run: >-
|
||||||
|
poetry build
|
||||||
|
|
||||||
|
- name: show temporary files
|
||||||
|
run: >-
|
||||||
|
ls -l
|
||||||
|
|
||||||
|
- name: create github release
|
||||||
|
id: create_release
|
||||||
|
uses: softprops/action-gh-release@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
body: ${{ steps.changelog_reader.outputs.changes }}
|
||||||
|
files: dist/*.whl
|
||||||
|
draft: false
|
||||||
|
prerelease: false
|
||||||
|
|
||||||
|
- name: publish to PyPI
|
||||||
|
uses: pypa/gh-action-pypi-publish@release/v1
|
||||||
|
with:
|
||||||
|
user: __token__
|
||||||
|
password: ${{ secrets.PYPI_API_TOKEN }}
|
||||||
|
skip_existing: true
|
||||||
114
.gitignore
vendored
Normal file
114
.gitignore
vendored
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
# macOS
|
||||||
|
.DS_Store
|
||||||
|
.AppleDouble
|
||||||
|
.LSOverride
|
||||||
|
|
||||||
|
# Byte-compiled / optimized / DLL files
|
||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
*$py.class
|
||||||
|
|
||||||
|
# C extensions
|
||||||
|
*.so
|
||||||
|
|
||||||
|
# Distribution / packaging
|
||||||
|
.Python
|
||||||
|
env/
|
||||||
|
build/
|
||||||
|
develop-eggs/
|
||||||
|
dist/
|
||||||
|
downloads/
|
||||||
|
eggs/
|
||||||
|
.eggs/
|
||||||
|
lib/
|
||||||
|
lib64/
|
||||||
|
parts/
|
||||||
|
sdist/
|
||||||
|
var/
|
||||||
|
wheels/
|
||||||
|
*.egg-info/
|
||||||
|
.installed.cfg
|
||||||
|
*.egg
|
||||||
|
|
||||||
|
# PyInstaller
|
||||||
|
# Usually these files are written by a python script from a template
|
||||||
|
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||||
|
*.manifest
|
||||||
|
*.spec
|
||||||
|
|
||||||
|
# Installer logs
|
||||||
|
pip-log.txt
|
||||||
|
pip-delete-this-directory.txt
|
||||||
|
|
||||||
|
# Unit test / coverage reports
|
||||||
|
htmlcov/
|
||||||
|
.tox/
|
||||||
|
.coverage
|
||||||
|
.coverage.*
|
||||||
|
.cache
|
||||||
|
nosetests.xml
|
||||||
|
coverage.xml
|
||||||
|
*.cover
|
||||||
|
.hypothesis/
|
||||||
|
.pytest_cache/
|
||||||
|
|
||||||
|
# Translations
|
||||||
|
*.mo
|
||||||
|
*.pot
|
||||||
|
|
||||||
|
# Django stuff:
|
||||||
|
*.log
|
||||||
|
local_settings.py
|
||||||
|
|
||||||
|
# Flask stuff:
|
||||||
|
instance/
|
||||||
|
.webassets-cache
|
||||||
|
|
||||||
|
# Scrapy stuff:
|
||||||
|
.scrapy
|
||||||
|
|
||||||
|
# Sphinx documentation
|
||||||
|
docs/_build/
|
||||||
|
|
||||||
|
# PyBuilder
|
||||||
|
target/
|
||||||
|
|
||||||
|
# Jupyter Notebook
|
||||||
|
.ipynb_checkpoints
|
||||||
|
|
||||||
|
# pyenv
|
||||||
|
.python-version
|
||||||
|
|
||||||
|
# celery beat schedule file
|
||||||
|
celerybeat-schedule
|
||||||
|
|
||||||
|
# SageMath parsed files
|
||||||
|
*.sage.py
|
||||||
|
|
||||||
|
# dotenv
|
||||||
|
.env
|
||||||
|
|
||||||
|
# virtualenv
|
||||||
|
.venv
|
||||||
|
venv/
|
||||||
|
ENV/
|
||||||
|
|
||||||
|
# Spyder project settings
|
||||||
|
.spyderproject
|
||||||
|
.spyproject
|
||||||
|
|
||||||
|
# Rope project settings
|
||||||
|
.ropeproject
|
||||||
|
|
||||||
|
# mkdocs documentation
|
||||||
|
/site
|
||||||
|
|
||||||
|
# mypy
|
||||||
|
.mypy_cache/
|
||||||
|
|
||||||
|
# IDE settings
|
||||||
|
.vscode/
|
||||||
|
.idea/
|
||||||
|
|
||||||
|
# mkdocs build dir
|
||||||
|
site/
|
||||||
36
.pre-commit-config.yaml
Normal file
36
.pre-commit-config.yaml
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
repos:
|
||||||
|
- repo: https://github.com/Lucas-C/pre-commit-hooks
|
||||||
|
rev: v1.1.9
|
||||||
|
hooks:
|
||||||
|
- id: forbid-crlf
|
||||||
|
- id: remove-crlf
|
||||||
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
|
rev: v3.4.0
|
||||||
|
hooks:
|
||||||
|
- id: trailing-whitespace
|
||||||
|
- id: end-of-file-fixer
|
||||||
|
- id: check-merge-conflict
|
||||||
|
- id: check-yaml
|
||||||
|
args: [ --unsafe ]
|
||||||
|
- repo: https://github.com/pre-commit/mirrors-isort
|
||||||
|
rev: v5.8.0
|
||||||
|
hooks:
|
||||||
|
- id: isort
|
||||||
|
args: [ "--filter-files" ]
|
||||||
|
- repo: https://github.com/ambv/black
|
||||||
|
rev: 21.5b1
|
||||||
|
hooks:
|
||||||
|
- id: black
|
||||||
|
language_version: python3.8
|
||||||
|
- repo: https://github.com/pycqa/flake8
|
||||||
|
rev: 3.9.2
|
||||||
|
hooks:
|
||||||
|
- id: flake8
|
||||||
|
additional_dependencies: [ flake8-typing-imports==1.10.0 ]
|
||||||
|
- repo: https://github.com/pre-commit/mirrors-mypy
|
||||||
|
rev: v0.901
|
||||||
|
hooks:
|
||||||
|
- id: mypy
|
||||||
|
exclude: tests/
|
||||||
|
additional_dependencies:
|
||||||
|
- types-click
|
||||||
5
CHANGELOG.md
Normal file
5
CHANGELOG.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
## 0.1.0 (2022-02-18)
|
||||||
|
|
||||||
|
* First release on PyPI.
|
||||||
123
CONTRIBUTING.md
Normal file
123
CONTRIBUTING.md
Normal file
@@ -0,0 +1,123 @@
|
|||||||
|
# Contributing
|
||||||
|
|
||||||
|
Contributions are welcome, and they are greatly appreciated! Every little bit
|
||||||
|
helps, and credit will always be given.
|
||||||
|
|
||||||
|
You can contribute in many ways:
|
||||||
|
|
||||||
|
## Types of Contributions
|
||||||
|
|
||||||
|
### Report Bugs
|
||||||
|
|
||||||
|
Report bugs at https://github.com/ep1cman/unifi-protect-backup/issues.
|
||||||
|
|
||||||
|
If you are reporting a bug, please include:
|
||||||
|
|
||||||
|
* Your operating system name and version.
|
||||||
|
* Any details about your local setup that might be helpful in troubleshooting.
|
||||||
|
* Detailed steps to reproduce the bug.
|
||||||
|
|
||||||
|
### Fix Bugs
|
||||||
|
|
||||||
|
Look through the GitHub issues for bugs. Anything tagged with "bug" and "help
|
||||||
|
wanted" is open to whoever wants to implement it.
|
||||||
|
|
||||||
|
### Implement Features
|
||||||
|
|
||||||
|
Look through the GitHub issues for features. Anything tagged with "enhancement"
|
||||||
|
and "help wanted" is open to whoever wants to implement it.
|
||||||
|
|
||||||
|
### Write Documentation
|
||||||
|
|
||||||
|
Unifi Protect Backup could always use more documentation, whether as part of the
|
||||||
|
official Unifi Protect Backup docs, in docstrings, or even on the web in blog posts,
|
||||||
|
articles, and such.
|
||||||
|
|
||||||
|
### Submit Feedback
|
||||||
|
|
||||||
|
The best way to send feedback is to file an issue at https://github.com/ep1cman/unifi-protect-backup/issues.
|
||||||
|
|
||||||
|
If you are proposing a feature:
|
||||||
|
|
||||||
|
* Explain in detail how it would work.
|
||||||
|
* Keep the scope as narrow as possible, to make it easier to implement.
|
||||||
|
* Remember that this is a volunteer-driven project, and that contributions
|
||||||
|
are welcome :)
|
||||||
|
|
||||||
|
## Get Started!
|
||||||
|
|
||||||
|
Ready to contribute? Here's how to set up `unifi-protect-backup` for local development.
|
||||||
|
|
||||||
|
1. Fork the `unifi-protect-backup` repo on GitHub.
|
||||||
|
2. Clone your fork locally
|
||||||
|
|
||||||
|
```
|
||||||
|
$ git clone git@github.com:your_name_here/unifi-protect-backup.git
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Ensure [poetry](https://python-poetry.org/docs/) is installed.
|
||||||
|
4. Install dependencies and start your virtualenv:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ poetry install -E test -E doc -E dev
|
||||||
|
```
|
||||||
|
|
||||||
|
5. Create a branch for local development:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ git checkout -b name-of-your-bugfix-or-feature
|
||||||
|
```
|
||||||
|
|
||||||
|
Now you can make your changes locally.
|
||||||
|
|
||||||
|
6. When you're done making changes, check that your changes pass the
|
||||||
|
tests, including testing other Python versions, with tox:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ poetry run tox
|
||||||
|
```
|
||||||
|
|
||||||
|
7. Commit your changes and push your branch to GitHub:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ git add .
|
||||||
|
$ git commit -m "Your detailed description of your changes."
|
||||||
|
$ git push origin name-of-your-bugfix-or-feature
|
||||||
|
```
|
||||||
|
|
||||||
|
8. Submit a pull request through the GitHub website.
|
||||||
|
|
||||||
|
## Pull Request Guidelines
|
||||||
|
|
||||||
|
Before you submit a pull request, check that it meets these guidelines:
|
||||||
|
|
||||||
|
1. The pull request should include tests.
|
||||||
|
2. If the pull request adds functionality, the docs should be updated. Put
|
||||||
|
your new functionality into a function with a docstring, and add the
|
||||||
|
feature to the list in README.md.
|
||||||
|
3. The pull request should work for Python 3.7, 3.8 and 3.9. Check
|
||||||
|
https://github.com/ep1cman/unifi-protect-backup/actions
|
||||||
|
and make sure that the tests pass for all supported Python versions.
|
||||||
|
|
||||||
|
## Tips
|
||||||
|
|
||||||
|
```
|
||||||
|
$ poetry run pytest tests/test_unifi_protect_backup.py
|
||||||
|
```
|
||||||
|
|
||||||
|
To run a subset of tests.
|
||||||
|
|
||||||
|
|
||||||
|
## Deploying
|
||||||
|
|
||||||
|
A reminder for the maintainers on how to deploy.
|
||||||
|
Make sure all your changes are committed (including an entry in CHANGELOG.md).
|
||||||
|
Then run:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ poetry run bump2version patch # possible: major / minor / patch
|
||||||
|
$ git push
|
||||||
|
$ git push --tags
|
||||||
|
```
|
||||||
|
|
||||||
|
GitHub Actions will then deploy to PyPI if tests pass.
|
||||||
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2022, sebastian.goscik
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
26
README.md
Normal file
26
README.md
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
# Unifi Protect Backup
|
||||||
|
|
||||||
|
|
||||||
|
[](https://pypi.org/project/unifi-protect-backup/)
|
||||||
|
[](https://pypi.org/project/unifi-protect-backup/)
|
||||||
|
[](https://github.com/ep1cman/unifi-protect-backup/actions/workflows/dev.yml)
|
||||||
|
[](https://codecov.io/github/ep1cman/unifi-protect-backup)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Python tool to backup unifi event clips in realtime
|
||||||
|
|
||||||
|
|
||||||
|
* Documentation: <https://ep1cman.github.io/unifi-protect-backup>
|
||||||
|
* GitHub: <https://github.com/ep1cman/unifi-protect-backup>
|
||||||
|
* PyPI: <https://pypi.org/project/unifi-protect-backup/>
|
||||||
|
* Free software: MIT
|
||||||
|
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
* TODO
|
||||||
|
|
||||||
|
## Credits
|
||||||
|
|
||||||
|
This package was created with [Cookiecutter](https://github.com/audreyr/cookiecutter) and the [waynerv/cookiecutter-pypackage](https://github.com/waynerv/cookiecutter-pypackage) project template.
|
||||||
1
docs/api.md
Normal file
1
docs/api.md
Normal file
@@ -0,0 +1 @@
|
|||||||
|
::: unifi_protect_backup
|
||||||
3
docs/changelog.md
Normal file
3
docs/changelog.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{%
|
||||||
|
include-markdown "../CHANGELOG.md"
|
||||||
|
%}
|
||||||
3
docs/contributing.md
Normal file
3
docs/contributing.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{%
|
||||||
|
include-markdown "../CONTRIBUTING.md"
|
||||||
|
%}
|
||||||
3
docs/index.md
Normal file
3
docs/index.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{%
|
||||||
|
include-markdown "../README.md"
|
||||||
|
%}
|
||||||
43
docs/installation.md
Normal file
43
docs/installation.md
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
# Installation
|
||||||
|
|
||||||
|
## Stable release
|
||||||
|
|
||||||
|
To install Unifi Protect Backup, run this command in your
|
||||||
|
terminal:
|
||||||
|
|
||||||
|
``` console
|
||||||
|
$ pip install unifi-protect-backup
|
||||||
|
```
|
||||||
|
|
||||||
|
This is the preferred method to install Unifi Protect Backup, as it will always install the most recent stable release.
|
||||||
|
|
||||||
|
If you don't have [pip][] installed, this [Python installation guide][]
|
||||||
|
can guide you through the process.
|
||||||
|
|
||||||
|
## From source
|
||||||
|
|
||||||
|
The source for Unifi Protect Backup can be downloaded from
|
||||||
|
the [Github repo][].
|
||||||
|
|
||||||
|
You can either clone the public repository:
|
||||||
|
|
||||||
|
``` console
|
||||||
|
$ git clone git://github.com/ep1cman/unifi-protect-backup
|
||||||
|
```
|
||||||
|
|
||||||
|
Or download the [tarball][]:
|
||||||
|
|
||||||
|
``` console
|
||||||
|
$ curl -OJL https://github.com/ep1cman/unifi-protect-backup/tarball/master
|
||||||
|
```
|
||||||
|
|
||||||
|
Once you have a copy of the source, you can install it with:
|
||||||
|
|
||||||
|
``` console
|
||||||
|
$ pip install .
|
||||||
|
```
|
||||||
|
|
||||||
|
[pip]: https://pip.pypa.io
|
||||||
|
[Python installation guide]: http://docs.python-guide.org/en/latest/starting/installation/
|
||||||
|
[Github repo]: https://github.com/%7B%7B%20cookiecutter.github_username%20%7D%7D/%7B%7B%20cookiecutter.project_slug%20%7D%7D
|
||||||
|
[tarball]: https://github.com/%7B%7B%20cookiecutter.github_username%20%7D%7D/%7B%7B%20cookiecutter.project_slug%20%7D%7D/tarball/master
|
||||||
7
docs/usage.md
Normal file
7
docs/usage.md
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
# Usage
|
||||||
|
|
||||||
|
To use Unifi Protect Backup in a project
|
||||||
|
|
||||||
|
```
|
||||||
|
import unifi_protect_backup
|
||||||
|
```
|
||||||
27
makefile
Normal file
27
makefile
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
sources = unifi_protect_backup
|
||||||
|
|
||||||
|
.PHONY: test format lint unittest coverage pre-commit clean
|
||||||
|
test: format lint unittest
|
||||||
|
|
||||||
|
format:
|
||||||
|
isort $(sources) tests
|
||||||
|
black $(sources) tests
|
||||||
|
|
||||||
|
lint:
|
||||||
|
flake8 $(sources) tests
|
||||||
|
mypy $(sources) tests
|
||||||
|
|
||||||
|
unittest:
|
||||||
|
pytest
|
||||||
|
|
||||||
|
coverage:
|
||||||
|
pytest --cov=$(sources) --cov-branch --cov-report=term-missing tests
|
||||||
|
|
||||||
|
pre-commit:
|
||||||
|
pre-commit run --all-files
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf .mypy_cache .pytest_cache
|
||||||
|
rm -rf *.egg-info
|
||||||
|
rm -rf .tox dist site
|
||||||
|
rm -rf coverage.xml .coverage
|
||||||
75
mkdocs.yml
Normal file
75
mkdocs.yml
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
site_name: Unifi Protect Backup
|
||||||
|
site_url: https://ep1cman.github.io/unifi-protect-backup
|
||||||
|
repo_url: https://github.com/ep1cman/unifi-protect-backup
|
||||||
|
repo_name: ep1cman/unifi-protect-backup
|
||||||
|
#strict: true
|
||||||
|
nav:
|
||||||
|
- Home: index.md
|
||||||
|
- Installation: installation.md
|
||||||
|
- Usage: usage.md
|
||||||
|
- Modules: api.md
|
||||||
|
- Contributing: contributing.md
|
||||||
|
- Changelog: changelog.md
|
||||||
|
theme:
|
||||||
|
name: material
|
||||||
|
language: en
|
||||||
|
#logo: assets/logo.png
|
||||||
|
palette:
|
||||||
|
scheme: preference
|
||||||
|
primary: indigo
|
||||||
|
accent: indigo
|
||||||
|
features:
|
||||||
|
- navigation.indexes
|
||||||
|
- navigation.instant
|
||||||
|
- navigation.tabs.sticky
|
||||||
|
markdown_extensions:
|
||||||
|
- pymdownx.emoji:
|
||||||
|
emoji_index: !!python/name:materialx.emoji.twemoji
|
||||||
|
emoji_generator: !!python/name:materialx.emoji.to_svg
|
||||||
|
- pymdownx.critic
|
||||||
|
- pymdownx.caret
|
||||||
|
- pymdownx.mark
|
||||||
|
- pymdownx.tilde
|
||||||
|
- pymdownx.tabbed
|
||||||
|
- attr_list
|
||||||
|
- pymdownx.arithmatex:
|
||||||
|
generic: true
|
||||||
|
- pymdownx.highlight:
|
||||||
|
linenums: false
|
||||||
|
- pymdownx.superfences
|
||||||
|
- pymdownx.inlinehilite
|
||||||
|
- pymdownx.details
|
||||||
|
- admonition
|
||||||
|
- toc:
|
||||||
|
baselevel: 2
|
||||||
|
permalink: true
|
||||||
|
slugify: !!python/name:pymdownx.slugs.uslugify
|
||||||
|
- meta
|
||||||
|
plugins:
|
||||||
|
- include-markdown
|
||||||
|
- search:
|
||||||
|
lang: en
|
||||||
|
- mkdocstrings:
|
||||||
|
watch:
|
||||||
|
- unifi-protect-backup
|
||||||
|
extra:
|
||||||
|
social:
|
||||||
|
- icon: fontawesome/brands/twitter
|
||||||
|
# replace with your own tweet link below
|
||||||
|
link: https://github.com/waynerv/cookiecutter-pypackage
|
||||||
|
name: Tweet
|
||||||
|
- icon: fontawesome/brands/facebook
|
||||||
|
# replace with your own facebook link below
|
||||||
|
link: https://github.com/waynerv/cookiecutter-pypackage
|
||||||
|
name: Facebook
|
||||||
|
- icon: fontawesome/brands/github
|
||||||
|
link: https://github.com/ep1cman/unifi-protect-backup
|
||||||
|
name: Github
|
||||||
|
- icon: material/email
|
||||||
|
link: "mailto:sebastian@goscik.com"
|
||||||
|
# to enable disqus, uncomment the following and put your disqus id below
|
||||||
|
# disqus: disqus_id
|
||||||
|
# uncomment the following and put your google tracking id below to enable GA
|
||||||
|
#google_analytics:
|
||||||
|
#- UA-xxx
|
||||||
|
#- auto
|
||||||
2197
poetry.lock
generated
Normal file
2197
poetry.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
110
pyproject.toml
Normal file
110
pyproject.toml
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
[tool]
|
||||||
|
[tool.poetry]
|
||||||
|
name = "unifi-protect-backup"
|
||||||
|
version = "0.1.0"
|
||||||
|
homepage = "https://github.com/ep1cman/unifi-protect-backup"
|
||||||
|
description = "Python tool to backup unifi event clips in realtime."
|
||||||
|
authors = ["sebastian.goscik <sebastian@goscik.com>"]
|
||||||
|
readme = "README.md"
|
||||||
|
license = "MIT"
|
||||||
|
classifiers=[
|
||||||
|
'Development Status :: 2 - Pre-Alpha',
|
||||||
|
'Intended Audience :: Developers',
|
||||||
|
'License :: OSI Approved :: MIT License',
|
||||||
|
'Natural Language :: English',
|
||||||
|
'Programming Language :: Python :: 3',
|
||||||
|
'Programming Language :: Python :: 3.7',
|
||||||
|
'Programming Language :: Python :: 3.8',
|
||||||
|
'Programming Language :: Python :: 3.9',
|
||||||
|
]
|
||||||
|
packages = [
|
||||||
|
{ include = "unifi_protect_backup" },
|
||||||
|
{ include = "tests", format = "sdist" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[tool.poetry.dependencies]
|
||||||
|
python = ">=3.7.0,<4.0"
|
||||||
|
click = "8.0.1"
|
||||||
|
|
||||||
|
black = { version = "^21.5b2", optional = true}
|
||||||
|
isort = { version = "^5.8.0", optional = true}
|
||||||
|
flake8 = { version = "^3.9.2", optional = true}
|
||||||
|
flake8-docstrings = { version = "^1.6.0", optional = true }
|
||||||
|
mypy = {version = "^0.900", optional = true}
|
||||||
|
pytest = { version = "^6.2.4", optional = true}
|
||||||
|
pytest-cov = { version = "^2.12.0", optional = true}
|
||||||
|
tox = { version = "^3.20.1", optional = true}
|
||||||
|
virtualenv = { version = "^20.2.2", optional = true}
|
||||||
|
pip = { version = "^20.3.1", optional = true}
|
||||||
|
mkdocs = { version = "^1.1.2", optional = true}
|
||||||
|
mkdocs-include-markdown-plugin = { version = "^1.0.0", optional = true}
|
||||||
|
mkdocs-material = { version = "^6.1.7", optional = true}
|
||||||
|
mkdocstrings = { version = "^0.15.2", optional = true}
|
||||||
|
mkdocs-material-extensions = { version = "^1.0.1", optional = true}
|
||||||
|
twine = { version = "^3.3.0", optional = true}
|
||||||
|
mkdocs-autorefs = {version = "^0.2.1", optional = true}
|
||||||
|
pre-commit = {version = "^2.12.0", optional = true}
|
||||||
|
toml = {version = "^0.10.2", optional = true}
|
||||||
|
bump2version = {version = "^1.0.1", optional = true}
|
||||||
|
tox-asdf = {version = "^0.1.0", optional = true}
|
||||||
|
pyunifiprotect = "^3.2.1"
|
||||||
|
|
||||||
|
[tool.poetry.extras]
|
||||||
|
test = [
|
||||||
|
"pytest",
|
||||||
|
"black",
|
||||||
|
"isort",
|
||||||
|
"mypy",
|
||||||
|
"flake8",
|
||||||
|
"flake8-docstrings",
|
||||||
|
"pytest-cov"
|
||||||
|
]
|
||||||
|
|
||||||
|
dev = ["tox", "pre-commit", "virtualenv", "pip", "twine", "toml", "bump2version", "tox-asdf"]
|
||||||
|
|
||||||
|
doc = [
|
||||||
|
"mkdocs",
|
||||||
|
"mkdocs-include-markdown-plugin",
|
||||||
|
"mkdocs-material",
|
||||||
|
"mkdocstrings",
|
||||||
|
"mkdocs-material-extension",
|
||||||
|
"mkdocs-autorefs"
|
||||||
|
]
|
||||||
|
|
||||||
|
[tool.poetry.scripts]
|
||||||
|
unifi-protect-backup = 'unifi_protect_backup.cli:main'
|
||||||
|
|
||||||
|
[tool.black]
|
||||||
|
line-length = 120
|
||||||
|
skip-string-normalization = true
|
||||||
|
target-version = ['py37', 'py38']
|
||||||
|
include = '\.pyi?$'
|
||||||
|
exclude = '''
|
||||||
|
/(
|
||||||
|
\.eggs
|
||||||
|
| \.git
|
||||||
|
| \.hg
|
||||||
|
| \.mypy_cache
|
||||||
|
| \.tox
|
||||||
|
| \.venv
|
||||||
|
| _build
|
||||||
|
| buck-out
|
||||||
|
| build
|
||||||
|
| dist
|
||||||
|
)/
|
||||||
|
'''
|
||||||
|
|
||||||
|
[tool.isort]
|
||||||
|
multi_line_output = 3
|
||||||
|
include_trailing_comma = true
|
||||||
|
force_grid_wrap = 0
|
||||||
|
use_parentheses = true
|
||||||
|
ensure_newline_before_comments = true
|
||||||
|
line_length = 120
|
||||||
|
skip_gitignore = true
|
||||||
|
# you can skip files as below
|
||||||
|
#skip_glob = docs/conf.py
|
||||||
|
|
||||||
|
[build-system]
|
||||||
|
requires = ["poetry-core>=1.0.0"]
|
||||||
|
build-backend = "poetry.core.masonry.api"
|
||||||
93
setup.cfg
Normal file
93
setup.cfg
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
[flake8]
|
||||||
|
max-line-length = 120
|
||||||
|
max-complexity = 18
|
||||||
|
ignore = E203, E266, W503
|
||||||
|
docstring-convention = google
|
||||||
|
per-file-ignores = __init__.py:F401
|
||||||
|
exclude = .git,
|
||||||
|
__pycache__,
|
||||||
|
setup.py,
|
||||||
|
build,
|
||||||
|
dist,
|
||||||
|
docs,
|
||||||
|
releases,
|
||||||
|
.venv,
|
||||||
|
.tox,
|
||||||
|
.mypy_cache,
|
||||||
|
.pytest_cache,
|
||||||
|
.vscode,
|
||||||
|
.github,
|
||||||
|
# By default test codes will be linted.
|
||||||
|
# tests
|
||||||
|
|
||||||
|
[mypy]
|
||||||
|
ignore_missing_imports = True
|
||||||
|
|
||||||
|
[coverage:run]
|
||||||
|
# uncomment the following to omit files during running
|
||||||
|
#omit =
|
||||||
|
[coverage:report]
|
||||||
|
exclude_lines =
|
||||||
|
pragma: no cover
|
||||||
|
def __repr__
|
||||||
|
if self.debug:
|
||||||
|
if settings.DEBUG
|
||||||
|
raise AssertionError
|
||||||
|
raise NotImplementedError
|
||||||
|
if 0:
|
||||||
|
if __name__ == .__main__.:
|
||||||
|
def main
|
||||||
|
|
||||||
|
[tox:tox]
|
||||||
|
isolated_build = true
|
||||||
|
envlist = py37, py38, py39, format, lint, build
|
||||||
|
|
||||||
|
[gh-actions]
|
||||||
|
python =
|
||||||
|
3.9: py39
|
||||||
|
3.8: py38, format, lint, build
|
||||||
|
3.7: py37
|
||||||
|
|
||||||
|
[testenv]
|
||||||
|
allowlist_externals = pytest
|
||||||
|
extras =
|
||||||
|
test
|
||||||
|
passenv = *
|
||||||
|
setenv =
|
||||||
|
PYTHONPATH = {toxinidir}
|
||||||
|
PYTHONWARNINGS = ignore
|
||||||
|
commands =
|
||||||
|
pytest --cov=unifi_protect_backup --cov-branch --cov-report=xml --cov-report=term-missing tests
|
||||||
|
|
||||||
|
[testenv:format]
|
||||||
|
allowlist_externals =
|
||||||
|
isort
|
||||||
|
black
|
||||||
|
extras =
|
||||||
|
test
|
||||||
|
commands =
|
||||||
|
isort unifi_protect_backup
|
||||||
|
black unifi_protect_backup tests
|
||||||
|
|
||||||
|
[testenv:lint]
|
||||||
|
allowlist_externals =
|
||||||
|
flake8
|
||||||
|
mypy
|
||||||
|
extras =
|
||||||
|
test
|
||||||
|
commands =
|
||||||
|
flake8 unifi_protect_backup tests
|
||||||
|
mypy unifi_protect_backup tests
|
||||||
|
|
||||||
|
[testenv:build]
|
||||||
|
allowlist_externals =
|
||||||
|
poetry
|
||||||
|
mkdocs
|
||||||
|
twine
|
||||||
|
extras =
|
||||||
|
doc
|
||||||
|
dev
|
||||||
|
commands =
|
||||||
|
poetry build
|
||||||
|
mkdocs build
|
||||||
|
twine check dist/*
|
||||||
1
tests/__init__.py
Normal file
1
tests/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
"""Unit test package for unifi-protect-backup."""
|
||||||
35
tests/test_unifi_protect_backup.py
Normal file
35
tests/test_unifi_protect_backup.py
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
"""Tests for `unifi_protect_backup` package."""
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
from click.testing import CliRunner
|
||||||
|
|
||||||
|
from unifi_protect_backup import cli
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def response():
|
||||||
|
"""Sample pytest fixture.
|
||||||
|
|
||||||
|
See more at: http://doc.pytest.org/en/latest/fixture.html
|
||||||
|
"""
|
||||||
|
# import requests
|
||||||
|
# return requests.get('https://github.com/audreyr/cookiecutter-pypackage')
|
||||||
|
|
||||||
|
|
||||||
|
def test_content(response):
|
||||||
|
"""Sample pytest test function with the pytest fixture as an argument."""
|
||||||
|
# from bs4 import BeautifulSoup
|
||||||
|
# assert 'GitHub' in BeautifulSoup(response.content).title.string
|
||||||
|
del response
|
||||||
|
|
||||||
|
|
||||||
|
def test_command_line_interface():
|
||||||
|
"""Test the CLI."""
|
||||||
|
runner = CliRunner()
|
||||||
|
result = runner.invoke(cli.main)
|
||||||
|
assert result.exit_code == 0
|
||||||
|
assert 'unifi-protect-backup' in result.output
|
||||||
|
help_result = runner.invoke(cli.main, ['--help'])
|
||||||
|
assert help_result.exit_code == 0
|
||||||
|
assert '--help Show this message and exit.' in help_result.output
|
||||||
5
unifi_protect_backup/__init__.py
Normal file
5
unifi_protect_backup/__init__.py
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
"""Top-level package for Unifi Protect Backup."""
|
||||||
|
|
||||||
|
__author__ = """sebastian.goscik"""
|
||||||
|
__email__ = 'sebastian@goscik.com'
|
||||||
|
__version__ = '0.1.0'
|
||||||
15
unifi_protect_backup/cli.py
Normal file
15
unifi_protect_backup/cli.py
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
"""Console script for unifi_protect_backup."""
|
||||||
|
|
||||||
|
import click
|
||||||
|
|
||||||
|
|
||||||
|
@click.command()
|
||||||
|
def main():
|
||||||
|
"""Main entrypoint."""
|
||||||
|
click.echo("unifi-protect-backup")
|
||||||
|
click.echo("=" * len("unifi-protect-backup"))
|
||||||
|
click.echo("Python tool to backup unifi event clips in realtime")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main() # pragma: no cover
|
||||||
1
unifi_protect_backup/unifi_protect_backup.py
Normal file
1
unifi_protect_backup/unifi_protect_backup.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
"""Main module."""
|
||||||
Reference in New Issue
Block a user