Make log / file opening work on linux / windows

This commit is contained in:
Brett Williams
2023-06-04 12:58:23 -05:00
parent 0ba89553ab
commit a5d49abfae
2 changed files with 18 additions and 4 deletions

View File

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