From 221bb03fe65ac7935fa5d94ec45cd74c61a12577 Mon Sep 17 00:00:00 2001 From: Stefan Cosma Date: Fri, 21 Apr 2023 21:14:24 +0300 Subject: [PATCH] Fixes paths for files when running cronjob --- plexorcist.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/plexorcist.py b/plexorcist.py index e8545db..53c1344 100755 --- a/plexorcist.py +++ b/plexorcist.py @@ -1,6 +1,7 @@ #!/usr/bin/env python """Main Plexorcist execution file!""" +import os import configparser import functools from datetime import datetime, timedelta @@ -10,6 +11,12 @@ import requests import xmltodict +# Get the absolute path of the directory containing the script +script_dir = os.path.dirname(os.path.abspath(__file__)) + +# Construct the absolute path of the INI file +config_file_path = os.path.join(script_dir, "plexorcist.ini") + # Read the config file config = configparser.ConfigParser() config.read("plexorcist.ini") @@ -31,7 +38,8 @@ I18N[option] = config.get("i18n", option) # Set the log file name -LOG_FILE = "plexorcist.log" +log_file_path = os.path.join(script_dir, "plexorcist.log") +LOG_FILE = log_file_path # Create a rotating file handler with a maximum size of 1 MB handler = RotatingFileHandler(LOG_FILE, maxBytes=1024 * 1024, backupCount=2)