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: 是否立刻强制终止进程
|
:param force: 是否立刻强制终止进程
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
pids = [pid['id'] for pid in self.run_cdp('SystemInfo.getProcessInfo')['processInfo']]
|
try:
|
||||||
for tab in self._all_drivers.values():
|
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:
|
for driver in tab:
|
||||||
driver.stop()
|
driver.stop()
|
||||||
|
|
||||||
if force:
|
if not force:
|
||||||
from psutil import Process
|
return
|
||||||
for pid in pids:
|
|
||||||
try:
|
try:
|
||||||
Process(pid).kill()
|
pids = [pid['id'] for pid in self.run_cdp('SystemInfo.getProcessInfo')['processInfo']]
|
||||||
except:
|
except:
|
||||||
pass
|
return
|
||||||
else:
|
|
||||||
|
from psutil import Process
|
||||||
|
for pid in pids:
|
||||||
try:
|
try:
|
||||||
self.run_cdp('Browser.close')
|
Process(pid).kill()
|
||||||
self.driver.stop()
|
except:
|
||||||
except PageDisconnectedError:
|
pass
|
||||||
self.driver.stop()
|
|
||||||
|
|
||||||
from os import popen
|
from os import popen
|
||||||
from platform import system
|
from platform import system
|
||||||
|
@ -176,8 +176,8 @@ def set_flags(opt):
|
|||||||
states_dict = load(f)
|
states_dict = load(f)
|
||||||
except JSONDecodeError:
|
except JSONDecodeError:
|
||||||
states_dict = {}
|
states_dict = {}
|
||||||
flags_list = [] if opt.clear_file_flags else states_dict.setdefault(
|
states_dict.setdefault('browser', {}).setdefault('enabled_labs_experiments', [])
|
||||||
'browser', {}).setdefault('enabled_labs_experiments', [])
|
flags_list = [] if opt.clear_file_flags else states_dict['browser']['enabled_labs_experiments']
|
||||||
flags_dict = {}
|
flags_dict = {}
|
||||||
for i in flags_list:
|
for i in flags_list:
|
||||||
f = str(i).split('@', 1)
|
f = str(i).split('@', 1)
|
||||||
|
@ -474,7 +474,7 @@ class ChromiumBase(BasePage):
|
|||||||
|
|
||||||
def cookies(self, as_dict=False, all_domains=False, all_info=False):
|
def cookies(self, as_dict=False, all_domains=False, all_info=False):
|
||||||
"""返回cookies信息
|
"""返回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_domains: 是否返回所有域的cookies
|
||||||
:param all_info: 是否返回所有信息,为False时只返回name、value、domain
|
:param all_info: 是否返回所有信息,为False时只返回name、value、domain
|
||||||
:return: cookies信息
|
:return: cookies信息
|
||||||
|
@ -363,7 +363,7 @@ class WebPageTab(SessionPage, ChromiumTab, BasePage):
|
|||||||
|
|
||||||
def cookies(self, as_dict=False, all_domains=False, all_info=False):
|
def cookies(self, as_dict=False, all_domains=False, all_info=False):
|
||||||
"""返回cookies
|
"""返回cookies
|
||||||
:param as_dict: 是否以字典方式返回
|
:param as_dict: 为True时以dict格式返回,为False时返回list且all_info无效
|
||||||
:param all_domains: 是否返回所有域的cookies
|
:param all_domains: 是否返回所有域的cookies
|
||||||
:param all_info: 是否返回所有信息,False则只返回name、value、domain
|
:param all_info: 是否返回所有信息,False则只返回name、value、domain
|
||||||
:return: cookies信息
|
:return: cookies信息
|
||||||
|
@ -221,7 +221,7 @@ class SessionPage(BasePage):
|
|||||||
|
|
||||||
def cookies(self, as_dict=False, all_domains=False, all_info=False):
|
def cookies(self, as_dict=False, all_domains=False, all_info=False):
|
||||||
"""返回cookies
|
"""返回cookies
|
||||||
:param as_dict: 是否以字典方式返回,False则以list返回
|
:param as_dict: 为True时以dict格式返回,为False时返回list且all_info无效
|
||||||
:param all_domains: 是否返回所有域的cookies
|
:param all_domains: 是否返回所有域的cookies
|
||||||
:param all_info: 是否返回所有信息,False则只返回name、value、domain
|
:param all_info: 是否返回所有信息,False则只返回name、value、domain
|
||||||
:return: cookies信息
|
:return: cookies信息
|
||||||
|
@ -298,7 +298,7 @@ class WebPage(SessionPage, ChromiumPage, BasePage):
|
|||||||
|
|
||||||
def cookies(self, as_dict=False, all_domains=False, all_info=False):
|
def cookies(self, as_dict=False, all_domains=False, all_info=False):
|
||||||
"""返回cookies
|
"""返回cookies
|
||||||
:param as_dict: 是否以字典方式返回,False以list形式返回
|
:param as_dict: 为True时以dict格式返回,为False时返回list且all_info无效
|
||||||
:param all_domains: 是否返回所有域的cookies
|
:param all_domains: 是否返回所有域的cookies
|
||||||
:param all_info: 是否返回所有信息,False则只返回name、value、domain
|
:param all_info: 是否返回所有信息,False则只返回name、value、domain
|
||||||
:return: cookies信息
|
:return: cookies信息
|
||||||
|
Loading…
x
Reference in New Issue
Block a user