Files
Zordon/lib/utilities/misc_helper.py
2023-06-04 13:05:30 -05:00

15 lines
590 B
Python

import logging
import subprocess
logger = logging.getLogger()
def launch_url(url):
if subprocess.run(['which', 'xdg-open'], capture_output=True).returncode == 0:
subprocess.run(['xdg-open', url]) # linux
elif subprocess.run(['which', 'open'], capture_output=True).returncode == 0:
subprocess.run(['open', url]) # macos
elif subprocess.run(['which', 'start'], capture_output=True).returncode == 0:
subprocess.run(['start', url]) # windows - need to validate this works
else:
logger.error(f"No valid launchers found to launch url: {url}")