mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-10 04:00:23 +08:00
修复set_flags的一个问题;修改quit()逻辑
This commit is contained in:
parent
2157fcf9e3
commit
4a9ef7d6b2
@ -203,24 +203,31 @@ class Browser(object):
|
||||
:param force: 是否立刻强制终止进程
|
||||
:return: None
|
||||
"""
|
||||
pids = [pid['id'] for pid in self.run_cdp('SystemInfo.getProcessInfo')['processInfo']]
|
||||
for tab in self._all_drivers.values():
|
||||
try:
|
||||
self.run_cdp('Browser.close')
|
||||
except PageDisconnectedError:
|
||||
pass
|
||||
self.driver.stop()
|
||||
|
||||
drivers = list(self._all_drivers.values())
|
||||
for tab in drivers:
|
||||
for driver in tab:
|
||||
driver.stop()
|
||||
|
||||
if force:
|
||||
from psutil import Process
|
||||
for pid in pids:
|
||||
try:
|
||||
Process(pid).kill()
|
||||
except:
|
||||
pass
|
||||
else:
|
||||
if not force:
|
||||
return
|
||||
|
||||
try:
|
||||
pids = [pid['id'] for pid in self.run_cdp('SystemInfo.getProcessInfo')['processInfo']]
|
||||
except:
|
||||
return
|
||||
|
||||
from psutil import Process
|
||||
for pid in pids:
|
||||
try:
|
||||
self.run_cdp('Browser.close')
|
||||
self.driver.stop()
|
||||
except PageDisconnectedError:
|
||||
self.driver.stop()
|
||||
Process(pid).kill()
|
||||
except:
|
||||
pass
|
||||
|
||||
from os import popen
|
||||
from platform import system
|
||||
|
@ -176,8 +176,8 @@ def set_flags(opt):
|
||||
states_dict = load(f)
|
||||
except JSONDecodeError:
|
||||
states_dict = {}
|
||||
flags_list = [] if opt.clear_file_flags else states_dict.setdefault(
|
||||
'browser', {}).setdefault('enabled_labs_experiments', [])
|
||||
states_dict.setdefault('browser', {}).setdefault('enabled_labs_experiments', [])
|
||||
flags_list = [] if opt.clear_file_flags else states_dict['browser']['enabled_labs_experiments']
|
||||
flags_dict = {}
|
||||
for i in flags_list:
|
||||
f = str(i).split('@', 1)
|
||||
|
@ -474,7 +474,7 @@ class ChromiumBase(BasePage):
|
||||
|
||||
def cookies(self, as_dict=False, all_domains=False, all_info=False):
|
||||
"""返回cookies信息
|
||||
:param as_dict: 为True时返回由{name: value}键值对组成的dict,为True时返回list且all_info无效
|
||||
:param as_dict: 为True时以dict格式返回,为False时返回list且all_info无效
|
||||
:param all_domains: 是否返回所有域的cookies
|
||||
:param all_info: 是否返回所有信息,为False时只返回name、value、domain
|
||||
:return: cookies信息
|
||||
|
@ -363,7 +363,7 @@ class WebPageTab(SessionPage, ChromiumTab, BasePage):
|
||||
|
||||
def cookies(self, as_dict=False, all_domains=False, all_info=False):
|
||||
"""返回cookies
|
||||
:param as_dict: 是否以字典方式返回
|
||||
:param as_dict: 为True时以dict格式返回,为False时返回list且all_info无效
|
||||
:param all_domains: 是否返回所有域的cookies
|
||||
:param all_info: 是否返回所有信息,False则只返回name、value、domain
|
||||
:return: cookies信息
|
||||
|
@ -221,7 +221,7 @@ class SessionPage(BasePage):
|
||||
|
||||
def cookies(self, as_dict=False, all_domains=False, all_info=False):
|
||||
"""返回cookies
|
||||
:param as_dict: 是否以字典方式返回,False则以list返回
|
||||
:param as_dict: 为True时以dict格式返回,为False时返回list且all_info无效
|
||||
:param all_domains: 是否返回所有域的cookies
|
||||
:param all_info: 是否返回所有信息,False则只返回name、value、domain
|
||||
:return: cookies信息
|
||||
|
@ -298,7 +298,7 @@ class WebPage(SessionPage, ChromiumPage, BasePage):
|
||||
|
||||
def cookies(self, as_dict=False, all_domains=False, all_info=False):
|
||||
"""返回cookies
|
||||
:param as_dict: 是否以字典方式返回,False以list形式返回
|
||||
:param as_dict: 为True时以dict格式返回,为False时返回list且all_info无效
|
||||
:param all_domains: 是否返回所有域的cookies
|
||||
:param all_info: 是否返回所有信息,False则只返回name、value、domain
|
||||
:return: cookies信息
|
||||
|
Loading…
x
Reference in New Issue
Block a user