1- import platform
2- import subprocess as sps
3- import sys
4- from typing import List
1+ import sys , subprocess as sps , os
52
6- from paling . types import OptionsDictT
3+ name = 'Edge'
74
8- name : str = 'Edge'
5+ def run (path , options , start_urls ):
6+ if path != 'edge_legacy' :
7+ if options ['app_mode' ]:
8+ for url in start_urls :
9+ sps .Popen ([path , '--app=%s' % url ] + options ['cmdline_args' ],
10+ stdout = sps .PIPE , stderr = sps .PIPE , stdin = sps .PIPE )
11+ else :
12+ args = options ['cmdline_args' ] + start_urls
13+ sps .Popen ([path , '--new-window' ] + args ,
14+ stdout = sps .PIPE , stderr = sys .stderr , stdin = sps .PIPE )
15+ else :
16+ cmd = 'start microsoft-edge:{}' .format (start_urls [0 ])
17+ sps .Popen (cmd , stdout = sys .stdout , stderr = sys .stderr , stdin = sps .PIPE , shell = True )
918
19+ def find_path ():
20+ if sys .platform in ['win32' , 'win64' ]:
21+ return _find_edge_win ()
22+ else :
23+ return None
1024
11- def run ( _path : str , options : OptionsDictT , start_urls : List [ str ]) -> None :
12- cmd = 'start microsoft-edge:{}' . format ( start_urls [ 0 ])
13- sps . Popen ( cmd , stdout = sys . stdout , stderr = sys . stderr , stdin = sps . PIPE , shell = True )
25+ def _find_edge_win () :
26+ import winreg as reg
27+ reg_path = r'SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\msedge.exe'
1428
29+ for install_type in reg .HKEY_CURRENT_USER , reg .HKEY_LOCAL_MACHINE :
30+ try :
31+ reg_key = reg .OpenKey (install_type , reg_path , 0 , reg .KEY_READ )
32+ edge_path = reg .QueryValue (reg_key , None )
33+ reg_key .Close ()
34+ if not os .path .isfile (edge_path ):
35+ continue
36+ except WindowsError :
37+ edge_path = 'edge_legacy'
38+ else :
39+ break
1540
16- def find_path () -> bool :
17- if platform .system () == 'Windows' :
18- return True
19-
20- return False
41+ return edge_path
0 commit comments