-
-
Notifications
You must be signed in to change notification settings - Fork 591
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
Edge app #663
base: main
Are you sure you want to change the base?
Edge app #663
Changes from all commits
0ea5a25
0c243dd
463f81d
6085773
4c86c90
d69ae82
1fb06d7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ Eel.egg-info | |
*.swp | ||
venv/ | ||
.tox | ||
.vscode |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,48 @@ | ||
import platform | ||
import os | ||
import subprocess as sps | ||
import sys | ||
from typing import List | ||
|
||
from eel.types import OptionsDictT | ||
|
||
name: str = 'Edge' | ||
name: str = "Edge" | ||
|
||
|
||
def run(_path: str, options: OptionsDictT, start_urls: List[str]) -> None: | ||
cmd = 'start microsoft-edge:{}'.format(start_urls[0]) | ||
sps.Popen(cmd, stdout=sys.stdout, stderr=sys.stderr, stdin=sps.PIPE, shell=True) | ||
def run(path: str, options: OptionsDictT, start_urls: List[str]) -> None: | ||
if path != "edge_legacy": | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would propose passing back the string
|
||
if options["app_mode"]: | ||
for url in start_urls: | ||
sps.Popen([path, "--app=%s" % url] + options["cmdline_args"], stdout=sps.PIPE, stderr=sps.PIPE, stdin=sps.PIPE) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For consistency I'd suggest you break the long lines here for the calls to |
||
else: | ||
args = options["cmdline_args"] + start_urls | ||
sps.Popen([path, "--new-window"] + args, stdout=sps.PIPE, stderr=sps.PIPE, stdin=sps.PIPE) | ||
else: | ||
cmd = "start microsoft-edge:{}".format(start_urls[0]) | ||
sps.Popen(cmd, stdout=sps.PIPE, stderr=sps.PIPE, stdin=sps.PIPE, shell=True) | ||
|
||
|
||
def find_path() -> bool: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
if platform.system() == 'Windows': | ||
return True | ||
if sys.platform in ["win32", "win64"]: | ||
return _find_edge_win() | ||
else: | ||
return None | ||
|
||
return False | ||
|
||
def _find_edge_win(): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function needs a return type annotation, |
||
import winreg as reg | ||
|
||
reg_path = r"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\msedge.exe" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While semi-obvious, it would be good to annotate |
||
|
||
for install_type in reg.HKEY_CURRENT_USER, reg.HKEY_LOCAL_MACHINE: | ||
try: | ||
reg_key = reg.OpenKey(install_type, reg_path, 0, reg.KEY_READ) | ||
edge_path = reg.QueryValue(reg_key, None) | ||
reg_key.Close() | ||
if not os.path.isfile(edge_path): | ||
continue | ||
except WindowsError: | ||
edge_path = "edge_legacy" | ||
else: | ||
break | ||
|
||
return edge_path | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see two potential issues with this loop:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although admittedly there are a few inconsistencies, the eel package generally prefers single quotes for strings. I think it would be good if you could change these back throughout.