Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Requirements update - remove unused requirements #137

Merged
merged 2 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ plexapi = "*"
pillow = "*"
prettytable = "*"
croniter = "*"
"ruamel.yaml" = "*"
docker = "*"
python-dateutil = "*"

[dev-packages]
Expand Down
87 changes: 7 additions & 80 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 2 additions & 5 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
-i https://pypi.org/simple
certifi==2024.2.2; python_version >= '3.6'
charset-normalizer==3.3.2; python_full_version >= '3.7.0'
croniter==2.0.2; python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'
docker==7.0.0; python_version >= '3.8'
croniter==2.0.3; python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'
idna==3.6; python_version >= '3.5'
packaging==23.2; python_version >= '3.7'
packaging==24.0; python_version >= '3.7'
pillow==10.2.0; python_version >= '3.8'
plexapi==4.15.10; python_version >= '3.8'
prettytable==3.10.0; python_version >= '3.8'
Expand All @@ -13,8 +12,6 @@ pytz==2024.1
pyyaml==6.0.1; python_version >= '3.6'
qbittorrent-api==2024.2.59; python_version >= '3.8'
requests==2.31.0; python_version >= '3.7'
ruamel.yaml==0.18.6; python_version >= '3.7'
ruamel.yaml.clib==0.2.8; python_version < '3.13' and platform_python_implementation == 'CPython'
six==1.16.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
tqdm==4.66.2; python_version >= '3.7'
unidecode==1.3.8; python_version >= '3.5'
Expand Down
95 changes: 1 addition & 94 deletions util/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
from pathlib import Path
from util.utility import *
import time
from ruamel.yaml import YAML


# Set the config file path
if os.environ.get('DOCKER_ENV'):
Expand Down Expand Up @@ -83,95 +81,4 @@ def load_config(self):
self.sonarr_config = self.instances_config.get('sonarr', {}) # Sonarr configurations
self.qbit_config = self.instances_config.get('qbittorrent', {}) # qBittorrent configurations
self.plex_config = self.instances_config.get('plex', {}) # Plex configurations


# Add data to config file
def add_to_config(self, add_type, container, logger, message=None):
"""
Add data to the config file for the backup_appdata key

Args:
add_type (str): stop_list or no_stop_list
container_name (str): Name of the container to add to the config file

Returns:
None
"""
yaml = YAML()

# Load the config file
with open(self.config_path, "r") as file:
config = yaml.load(file)

container_name = container.name
container_name_message = f"{container_name}\t\t\t{message}" if message else f"{container_name}"
stop_list = config['backup_appdata']['stop_list']
no_stop_list = config['backup_appdata']['no_stop_list']
exclusion_list = config['backup_appdata']['exclusion_list']

logger.debug(f"Adding {container_name} to {add_type} list")
# Add the container to the stop_list or no_stop_list
if add_type == "stop":
if not stop_list:
stop_list = [container_name_message]
elif container_name_message not in stop_list:
stop_list.append(container_name_message)
elif add_type == "no_stop":
if not no_stop_list:
no_stop_list = [container_name_message]
elif container_name_message not in no_stop_list:
no_stop_list.append(container_name_message)
elif add_type == "exclude":
if not exclusion_list:
exclusion_list = [container_name_message]
elif container_name_message not in exclusion_list:
exclusion_list.append(container_name_message)

# Add the new data to the config file
config['backup_appdata']['stop_list'] = stop_list
config['backup_appdata']['no_stop_list'] = no_stop_list
config['backup_appdata']['exclusion_list'] = exclusion_list

with open(self.config_path, "w") as file:
yaml.dump(config, file)

def remove_from_config(self, containers_to_remove, logger):
"""
Removes container names from appdata_backup stop_list or no_stop_list
if the container is removed from the system

Args:
remove_type (str): stop_list or no_stop_list
container_name (str): Name of the container to remove from the config file

Returns:
None
"""
yaml = YAML()

# Load the config file
with open(self.config_path, "r") as file:
config = yaml.load(file)

stop_list = config['backup_appdata']['stop_list']
no_stop_list = config['backup_appdata']['no_stop_list']
exclusion_list = config['backup_appdata']['exclusion_list']

for container in containers_to_remove:
if container in stop_list:
logger.debug(f"Removing {container} from stop_list")
stop_list.remove(container)
if container in no_stop_list:
logger.debug(f"Removing {container} from no_stop_list")
no_stop_list.remove(container)
if container in exclusion_list:
logger.debug(f"Removing {container} from exclusion_list")
exclusion_list.remove(container)

# Add the new data to the config file
config['backup_appdata']['stop_list'] = stop_list
config['backup_appdata']['no_stop_list'] = no_stop_list
config['backup_appdata']['exclusion_list'] = exclusion_list

with open(self.config_path, "w") as file:
yaml.dump(config, file)