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

fix: get timezone in a generic linux way #61

Merged
merged 2 commits into from
Oct 11, 2024
Merged
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
15 changes: 12 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from container_configs import ContainerConfig
from users_groups_setup import UserGroupSetup

Expand Down Expand Up @@ -31,6 +32,14 @@ def take_directory_input():
return ans
print('Please make sure the path is absolute, meaning it starts at the root of your filesystem and starts with "/":', end=' ')

def get_system_timezone():
tz_path = "/etc/localtime"

if os.path.exists(tz_path):
if os.path.islink(tz_path):
tz = os.readlink(tz_path)
return tz.split('zoneinfo/')[-1]
return None

print('Welcome to the EZarr CLI.')
print('This CLI will ask you which services you\'d like to use and more. If you\'d like more information about a '
Expand Down Expand Up @@ -114,9 +123,9 @@ def take_directory_input():
print('Please enter your timezone (like "Europe/Amsterdam") or press enter to use your system\'s configured timezone:', end=' ')
timezone = input()
if (timezone == ''):
timezone = open("/etc/timezone", "r").readline()
timezone = get_system_timezone()

if len(timezone) == 0: # if user pressed enter and reading timezone from /etc/timezone failed then default to Amsterdam
if len(timezone) == 0: # if user pressed enter and reading timezone from /etc/localtime failed then default to Amsterdam
timezone = 'Europe/Amsterdam'

plex_claim = ''
Expand Down Expand Up @@ -149,7 +158,7 @@ def take_directory_input():
getattr(permission_setup, service)()
except AttributeError:
pass
else:
else:
print("Permission and folder structure generation skipped by user.")


Expand Down
Loading