Skip to content
This repository was archived by the owner on Jul 26, 2024. It is now read-only.

Commit fa70fa3

Browse files
committed
2 parents 6a9a14f + de4bf9e commit fa70fa3

2 files changed

Lines changed: 39 additions & 15 deletions

File tree

paling/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
import gevent as gvt
1414
import json as jsn
1515
import bottle as btl
16-
import bottle.ext.websocket as wbs
16+
try:
17+
import bottle_websocket as wbs
18+
except ImportError:
19+
import bottle.ext.websocket as wbs
1720
import re as rgx
1821
import os
1922
import paling.browsers as brw

paling/edge.py

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,41 @@
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

Comments
 (0)