mirror of
https://github.com/StuffAnThings/qbit_manage.git
synced 2024-09-20 07:16:04 +08:00
fix pre-commit and update requirements
This commit is contained in:
parent
0a6e31eebd
commit
51a10de7e3
|
@ -31,17 +31,19 @@ repos:
|
||||||
hooks:
|
hooks:
|
||||||
- id: yamlfix
|
- id: yamlfix
|
||||||
exclude: ^.github/
|
exclude: ^.github/
|
||||||
- repo: https://github.com/asottile/reorder-python-imports
|
- repo: https://github.com/pycqa/isort
|
||||||
rev: v3.12.0
|
rev: 5.13.2
|
||||||
hooks:
|
hooks:
|
||||||
- id: reorder-python-imports
|
- id: isort
|
||||||
|
name: isort (python)
|
||||||
|
args: [--force-single-line-imports, --profile, black]
|
||||||
- repo: https://github.com/asottile/pyupgrade
|
- repo: https://github.com/asottile/pyupgrade
|
||||||
rev: v3.15.0
|
rev: v3.15.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: pyupgrade
|
- id: pyupgrade
|
||||||
args: [--py3-plus]
|
args: [--py3-plus]
|
||||||
- repo: https://github.com/psf/black
|
- repo: https://github.com/psf/black
|
||||||
rev: 23.12.1
|
rev: 24.1.1
|
||||||
hooks:
|
hooks:
|
||||||
- id: black
|
- id: black
|
||||||
language_version: python3
|
language_version: python3
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
"""Apprise notification class"""
|
"""Apprise notification class"""
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from modules import util
|
from modules import util
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
"""Module for BeyondHD (BHD) tracker."""
|
"""Module for BeyondHD (BHD) tracker."""
|
||||||
|
|
||||||
from json import JSONDecodeError
|
from json import JSONDecodeError
|
||||||
|
|
||||||
from modules import util
|
from modules import util
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
"""Config class for qBittorrent-Manage"""
|
"""Config class for qBittorrent-Manage"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import stat
|
import stat
|
||||||
|
@ -13,9 +14,9 @@ from modules.apprise import Apprise
|
||||||
from modules.bhd import BeyondHD
|
from modules.bhd import BeyondHD
|
||||||
from modules.notifiarr import Notifiarr
|
from modules.notifiarr import Notifiarr
|
||||||
from modules.qbittorrent import Qbt
|
from modules.qbittorrent import Qbt
|
||||||
from modules.util import check
|
|
||||||
from modules.util import Failed
|
|
||||||
from modules.util import YAML
|
from modules.util import YAML
|
||||||
|
from modules.util import Failed
|
||||||
|
from modules.util import check
|
||||||
from modules.webhooks import Webhooks
|
from modules.webhooks import Webhooks
|
||||||
|
|
||||||
logger = util.logger
|
logger = util.logger
|
||||||
|
|
|
@ -2,8 +2,8 @@ from qbittorrentapi import NotFound404Error
|
||||||
from qbittorrentapi import TrackerStatus
|
from qbittorrentapi import TrackerStatus
|
||||||
|
|
||||||
from modules import util
|
from modules import util
|
||||||
from modules.util import list_in_text
|
|
||||||
from modules.util import TorrentMessages
|
from modules.util import TorrentMessages
|
||||||
|
from modules.util import list_in_text
|
||||||
|
|
||||||
logger = util.logger
|
logger = util.logger
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
"""Logging module"""
|
"""Logging module"""
|
||||||
|
|
||||||
import io
|
import io
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
"""Qbittorrent Module"""
|
"""Qbittorrent Module"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
@ -10,8 +11,8 @@ from qbittorrentapi import Version
|
||||||
|
|
||||||
from modules import util
|
from modules import util
|
||||||
from modules.util import Failed
|
from modules.util import Failed
|
||||||
from modules.util import list_in_text
|
|
||||||
from modules.util import TorrentMessages
|
from modules.util import TorrentMessages
|
||||||
|
from modules.util import list_in_text
|
||||||
|
|
||||||
logger = util.logger
|
logger = util.logger
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
""" Utility functions for qBit Manage. """
|
""" Utility functions for qBit Manage. """
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
"""Class to handle webhooks."""
|
"""Class to handle webhooks."""
|
||||||
|
|
||||||
import time
|
import time
|
||||||
from json import JSONDecodeError
|
from json import JSONDecodeError
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ from datetime import timedelta
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import schedule
|
import schedule
|
||||||
|
|
||||||
from modules.logs import MyLogger
|
from modules.logs import MyLogger
|
||||||
except ModuleNotFoundError:
|
except ModuleNotFoundError:
|
||||||
print("Requirements Error: Requirements are not installed")
|
print("Requirements Error: Requirements are not installed")
|
||||||
|
@ -231,7 +232,8 @@ def get_arg(env_str, default, arg_bool=False, arg_int=False):
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from git import Repo, InvalidGitRepositoryError
|
from git import InvalidGitRepositoryError
|
||||||
|
from git import Repo
|
||||||
|
|
||||||
try:
|
try:
|
||||||
git_branch = Repo(path=".").head.ref.name # noqa
|
git_branch = Repo(path=".").head.ref.name # noqa
|
||||||
|
@ -340,16 +342,16 @@ from modules import util # noqa
|
||||||
|
|
||||||
util.logger = logger
|
util.logger = logger
|
||||||
from modules.config import Config # noqa
|
from modules.config import Config # noqa
|
||||||
from modules.util import GracefulKiller # noqa
|
|
||||||
from modules.util import Failed # noqa
|
|
||||||
from modules.core.category import Category # noqa
|
from modules.core.category import Category # noqa
|
||||||
from modules.core.tags import Tags # noqa
|
|
||||||
from modules.core.remove_unregistered import RemoveUnregistered # noqa
|
|
||||||
from modules.core.cross_seed import CrossSeed # noqa
|
from modules.core.cross_seed import CrossSeed # noqa
|
||||||
from modules.core.recheck import ReCheck # noqa
|
from modules.core.recheck import ReCheck # noqa
|
||||||
from modules.core.tag_nohardlinks import TagNoHardLinks # noqa
|
|
||||||
from modules.core.remove_orphaned import RemoveOrphaned # noqa
|
from modules.core.remove_orphaned import RemoveOrphaned # noqa
|
||||||
|
from modules.core.remove_unregistered import RemoveUnregistered # noqa
|
||||||
from modules.core.share_limits import ShareLimits # noqa
|
from modules.core.share_limits import ShareLimits # noqa
|
||||||
|
from modules.core.tag_nohardlinks import TagNoHardLinks # noqa
|
||||||
|
from modules.core.tags import Tags # noqa
|
||||||
|
from modules.util import Failed # noqa
|
||||||
|
from modules.util import GracefulKiller # noqa
|
||||||
|
|
||||||
|
|
||||||
def my_except_hook(exctype, value, tbi):
|
def my_except_hook(exctype, value, tbi):
|
||||||
|
|
|
@ -3,5 +3,5 @@ GitPython==3.1.41
|
||||||
qbittorrent-api==2024.1.58
|
qbittorrent-api==2024.1.58
|
||||||
requests==2.31.0
|
requests==2.31.0
|
||||||
retrying==1.3.4
|
retrying==1.3.4
|
||||||
ruamel.yaml==0.18.5
|
ruamel.yaml==0.18.6
|
||||||
schedule==1.2.1
|
schedule==1.2.1
|
||||||
|
|
|
@ -4,13 +4,13 @@ You can also allow incomplete torrents to be deleted.
|
||||||
Torrents will be deleted starting with the ones with the most seeds, only torrents with a single hardlink will be deleted.
|
Torrents will be deleted starting with the ones with the most seeds, only torrents with a single hardlink will be deleted.
|
||||||
Only torrents on configured drive path will be deleted. To monitor multiple drives, use multiple copies of this script.
|
Only torrents on configured drive path will be deleted. To monitor multiple drives, use multiple copies of this script.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import qbittorrentapi
|
import qbittorrentapi
|
||||||
|
|
||||||
|
|
||||||
"""===Config==="""
|
"""===Config==="""
|
||||||
# qBittorrent WebUi Login
|
# qBittorrent WebUi Login
|
||||||
qbt_login = {"host": "localhost", "port": 8080, "username": "???", "password": "???"}
|
qbt_login = {"host": "localhost", "port": 8080, "username": "???", "password": "???"}
|
||||||
|
|
|
@ -14,7 +14,9 @@ NEW_TRACKER = "https://blutopia.cc" # This is the tracker you want to replace i
|
||||||
# --START SCRIPT--#
|
# --START SCRIPT--#
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from qbittorrentapi import Client, LoginFailed, APIConnectionError
|
from qbittorrentapi import APIConnectionError
|
||||||
|
from qbittorrentapi import Client
|
||||||
|
from qbittorrentapi import LoginFailed
|
||||||
except ModuleNotFoundError:
|
except ModuleNotFoundError:
|
||||||
print('Requirements Error: qbittorrent-api not installed. Please install using the command "pip install qbittorrent-api"')
|
print('Requirements Error: qbittorrent-api not installed. Please install using the command "pip install qbittorrent-api"')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
|
@ -18,7 +18,9 @@ parser.add_argument("--days_to", help="Set Number of Days to stop torrents betwe
|
||||||
|
|
||||||
# --START SCRIPT--#
|
# --START SCRIPT--#
|
||||||
try:
|
try:
|
||||||
from qbittorrentapi import Client, LoginFailed, APIConnectionError
|
from qbittorrentapi import APIConnectionError
|
||||||
|
from qbittorrentapi import Client
|
||||||
|
from qbittorrentapi import LoginFailed
|
||||||
except ModuleNotFoundError:
|
except ModuleNotFoundError:
|
||||||
print('Requirements Error: qbittorrent-api not installed. Please install using the command "pip install qbittorrent-api"')
|
print('Requirements Error: qbittorrent-api not installed. Please install using the command "pip install qbittorrent-api"')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
staged_changes=$(git diff-index --cached HEAD | wc -l | awk '{print $1}')
|
|
||||||
|
|
||||||
# Check if there are any changes staged for commit
|
# Check if there are any changes staged for commit
|
||||||
if [ "$staged_changes" -eq 0 ]; then
|
if [[ -z $(git diff --cached --name-only) ]]; then
|
||||||
echo "There are no changes staged for commit. Skipping version update."
|
echo "There are no changes staged for commit. Skipping version update."
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
@ -15,19 +13,17 @@ if git diff --cached --name-only | grep -q "VERSION"; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Read the current version from the VERSION file
|
# Read the current version from the VERSION file
|
||||||
current_version=$(cat VERSION)
|
current_version=$(<VERSION)
|
||||||
echo "Current version: $current_version"
|
echo "Current version: $current_version"
|
||||||
|
|
||||||
# Check if "develop" is not present in the version string
|
# Check if "develop" is not present in the version string
|
||||||
if [[ $current_version != *"develop"* ]]; then
|
if [[ $current_version != *"develop"* ]]; then
|
||||||
echo "The word 'develop' is not present in the version string."
|
echo "The word 'develop' is not present in the version string."
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Get the version number from the HEAD commit
|
|
||||||
current_version=$(git show HEAD:VERSION 2>/dev/null)
|
|
||||||
|
|
||||||
# Extract the version number after "develop"
|
# Extract the version number after "develop"
|
||||||
version_number=$(echo "$current_version" | grep -oP '(?<=develop)\d+')
|
version_number=$(echo "$current_version" | sed -n 's/.*develop\([0-9]*\).*/\1/p')
|
||||||
|
|
||||||
# Increment the version number
|
# Increment the version number
|
||||||
new_version_number=$((version_number + 1))
|
new_version_number=$((version_number + 1))
|
||||||
|
@ -36,6 +32,6 @@ new_version_number=$((version_number + 1))
|
||||||
new_version=$(echo "$current_version" | sed "s/develop$version_number/develop$new_version_number/")
|
new_version=$(echo "$current_version" | sed "s/develop$version_number/develop$new_version_number/")
|
||||||
|
|
||||||
# Update the VERSION file
|
# Update the VERSION file
|
||||||
echo "$new_version" > VERSION
|
sed -i "s/$current_version/$new_version/" VERSION
|
||||||
|
|
||||||
echo "Version updated to: $new_version"
|
echo "Version updated to: $new_version"
|
||||||
|
|
13
setup.py
13
setup.py
|
@ -1,8 +1,10 @@
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from distutils.core import setup
|
from distutils.core import setup
|
||||||
|
|
||||||
from setuptools import find_packages
|
from setuptools import find_packages
|
||||||
|
|
||||||
|
from modules import __version__
|
||||||
|
|
||||||
# User-friendly description from README.md
|
# User-friendly description from README.md
|
||||||
current_directory = os.path.dirname(os.path.abspath(__file__))
|
current_directory = os.path.dirname(os.path.abspath(__file__))
|
||||||
try:
|
try:
|
||||||
|
@ -11,20 +13,17 @@ try:
|
||||||
except Exception:
|
except Exception:
|
||||||
long_description = ""
|
long_description = ""
|
||||||
|
|
||||||
try:
|
|
||||||
with open(os.path.join(current_directory, "VERSION"), encoding="utf-8") as f:
|
|
||||||
version_no = f.read()
|
|
||||||
except Exception:
|
|
||||||
version_no = ""
|
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
# Name of the package
|
# Name of the package
|
||||||
name="qbit_manage",
|
name="qbit_manage",
|
||||||
# Packages to include into the distribution
|
# Packages to include into the distribution
|
||||||
packages=find_packages("."),
|
packages=find_packages("."),
|
||||||
|
package_data={"": ["../*"]},
|
||||||
|
include_package_data=True,
|
||||||
# Start with a small number and increase it with
|
# Start with a small number and increase it with
|
||||||
# every change you make https://semver.org
|
# every change you make https://semver.org
|
||||||
version=version_no,
|
version=__version__,
|
||||||
# Chose a license from here: https: //
|
# Chose a license from here: https: //
|
||||||
# help.github.com / articles / licensing - a -
|
# help.github.com / articles / licensing - a -
|
||||||
# repository. For example: MIT
|
# repository. For example: MIT
|
||||||
|
|
Loading…
Reference in a new issue