Skip to content

Commit

Permalink
feat: default browser paths added for common OSes
Browse files Browse the repository at this point in the history
  • Loading branch information
Holf committed Sep 30, 2024
1 parent 7f64684 commit 5474236
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
3 changes: 2 additions & 1 deletion weduc_timetable_extractor/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ def main():

print("Launching browser ...")

chromium_path = get_chromium_path() or "/usr/bin/google-chrome"
chromium_path = get_chromium_path()
print("path", chromium_path)
browser = p.chromium.launch(
executable_path=chromium_path, headless=use_headless
)
Expand Down
24 changes: 16 additions & 8 deletions weduc_timetable_extractor/config_management.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import configparser
import platform
import sys
from pathlib import Path

Expand Down Expand Up @@ -32,14 +33,10 @@ def get_config_option(section, option, throw_if_absent=False):

if not config.has_option(section, option):
if throw_if_absent:
sys.stderr.write(
f"\nError: There is no '{section}.{option}' present in config.ini"
)
sys.exit(2)
else:
return None
sys.exit(f"\nError: There is no '{section}.{option}' present in config.ini")
return None

return config.get(section, option)
return config.get(section, option).strip() or None


def get_weduc_credentials():
Expand All @@ -58,7 +55,18 @@ def get_weduc_credentials():


def get_chromium_path():
return get_config_option(WEDUC_SECTION_NAME, "chromium_path")
chromium_path = get_config_option(WEDUC_SECTION_NAME, "chromium_path")

if chromium_path != None:
return chromium_path

os_map = {
"Windows": r"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe",
"Linux": "/usr/bin/google-chrome",
"Darwin": "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
}

return os_map.get(platform.system())


def get_student_configs():
Expand Down

0 comments on commit 5474236

Please sign in to comment.