Skip to content

Commit

Permalink
Fixes #797. (#798)
Browse files Browse the repository at this point in the history
  • Loading branch information
emeryberger authored Mar 24, 2024
1 parent 34f4cef commit b23894d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
3 changes: 2 additions & 1 deletion scalene/find_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ def find_browser(browserClass=None) -> Optional[str]:
try:
# Get the default browser object
browser = webbrowser.get(browserClass)
return browser.name if browser.name not in text_browsers else None
browser_name = browser.name if browser.name else browser.__class__.__name__
return browser_name if browser_name not in text_browsers else None
except AttributeError:
# https://github.com/plasma-umass/scalene/issues/790
# https://github.com/python/cpython/issues/105545
Expand Down
11 changes: 3 additions & 8 deletions scalene/launchbrowser.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from jinja2 import Environment, FileSystemLoader
from typing import Any, NewType

import scalene.scalene_config
import scalene_config

def read_file_content(directory: str, subdirectory: str, filename: str) -> str:
file_path = os.path.join(directory, subdirectory, filename)
Expand All @@ -35,16 +35,12 @@ def launch_browser_insecure(url: str) -> None:
# Create a command with the required flags
chrome_cmd = f'{chrome_path} %s --disable-web-security --user-data-dir="{temp_dir}"'

# print(chrome_cmd)

# Register the new browser type
webbrowser.register('chrome_with_flags', None,
webbrowser.Chrome(chrome_cmd), preferred=True)

# Open a URL using the new browser type
# url = 'https://cnn.com' # Replace with your desired URL
webbrowser.get(chrome_cmd).open(url)
# webbrowser.get('chrome_with_flags').open(url)


HOST = 'localhost'
Expand Down Expand Up @@ -133,8 +129,8 @@ def generate_html(profile_fname: Filename, output_fname: Filename) -> None:
prism_js=file_contents['prism_js_text'],
tablesort_js=file_contents['tablesort_js_text'],
tablesort_number_js=file_contents['tablesort_number_js_text'],
scalene_version=scalene.scalene_config.scalene_version,
scalene_date=scalene.scalene_config.scalene_date,
scalene_version=scalene_config.scalene_version,
scalene_date=scalene_config.scalene_date,
)

# Write the rendered content to the specified output file.
Expand Down Expand Up @@ -170,7 +166,6 @@ def start(filename: str, port: int) -> None:

if __name__ == '__main__':
import sys
print(sys.argv)
if len(sys.argv) > 2:
filename = sys.argv[1]
port = int(sys.argv[2])
Expand Down
4 changes: 2 additions & 2 deletions scalene/scalene_config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Current version of Scalene; reported by --version."""

scalene_version = "1.5.37"
scalene_date = "2024.03.10"
scalene_version = "1.5.38"
scalene_date = "2024.03.24"

# Port to use for Scalene UI
SCALENE_PORT = 11235
Expand Down

0 comments on commit b23894d

Please sign in to comment.