Skip to content

Commit

Permalink
Update pattrmm.py with vars updates
Browse files Browse the repository at this point in the history
  • Loading branch information
InsertDisc authored Feb 17, 2024
1 parent 56b7a6e commit 4e689ae
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions pattrmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ def log_setup():
import tzlocal
today = datetime.datetime.today()
import os
import sys
library = ""
is_docker = os.environ.get('PATTRMM_DOCKER', "False")
Expand All @@ -233,6 +234,16 @@ def log_setup():
config_path = configPathPrefix + 'config.yml'
settings_path = 'preferences/settings.yml'
def get_os():
if sys.platform.startswith('linux'):
return 'Linux'
elif sys.platform.startswith('darwin'):
return 'macOS'
elif sys.platform.startswith('win'):
return 'Windows'
else:
return 'Unknown'
def date_within_range(item_date, start_date, end_date):
if (start_date.month, start_date.day) <= (end_date.month, end_date.day):
return (
Expand Down Expand Up @@ -994,29 +1005,31 @@ def setting(value):
try:
print(f"Attempting to get local timezone from host environment")
if is_docker == "True":
print("=> Docker environment detected")
try:
timezone = os.environ.get('TZ')
if timezone is None:
print("Could not retrieve timezone information from docker 'TZ' environment variable.")
print("Attempting 'Docker Host'")
print(" Could not retrieve timezone information from docker 'TZ' environment variable.")
print(" => Attempting 'Docker Host'")
try:
print(" Docker Host Detected:", get_os())
system_tz = tzlocal.get_localzone()
timezone = str(system_tz)
print(f"Using locality {timezone} to adjust for airing dates.")
print(f" Using locality {timezone} to adjust for airing dates.")
except Exception as e:
print("Could not retrieve timezone information from 'Docker Host'.")
print(f"An error occured: {e}")
print("Falling back to default")
print(" Could not retrieve timezone information from 'Docker Host'.")
print(f" An error occured: {e}")
print(" Falling back to default")
timezone = "America/New_York"
print(f"Using locality {timezone} to adjust for airing dates.")
print(f" Using locality {timezone} to adjust for airing dates.")
except Exception as e:
print(f"An error occured: {e}")
print(f"Details:")
print(f"Environment detected")
print(f" => Docker")
print(f"Failed to retrieve timezone from:")
print(f" => Docker 'TZ' environment variable")
print(f" => Docker Host OS")
print(f" => Docker Host OS:", get_os())
print("--Falling back to default--")
timezone = "America/New_York"
print(f"Using locality {timezone} to adjust for airing dates.")
Expand Down Expand Up @@ -1587,7 +1600,6 @@ def get_missing_episodes_count(self, series_id):
self.missing_count = available_missing_episodes
self.total_count = total_episodes
return self
""")
create_vars_file.close()
else:
Expand Down

0 comments on commit 4e689ae

Please sign in to comment.