A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/seleniumhq/selenium/commit/e4b87d445601fcb1f9bbb2dcc6f47848673ce800 below:

Close `FirefoxBinary` log files when quitting `Firefox` driver … · SeleniumHQ/selenium@e4b87d4 · GitHub

File tree Expand file treeCollapse file tree 1 file changed

+21

-2

lines changed

Filter options

Expand file treeCollapse file tree 1 file changed

+21

-2

lines changed Original file line number Diff line number Diff line change

@@ -15,6 +15,7 @@

15 15

# specific language governing permissions and limitations

16 16

# under the License.

17 17

import base64

18 +

import logging

18 19

import os

19 20

import warnings

20 21

import zipfile

@@ -32,6 +33,8 @@

32 33

from .service import DEFAULT_EXECUTABLE_PATH

33 34

from .service import Service

34 35 36 +

logger = logging.getLogger(__name__)

37 + 35 38

# Default for log_path variable. To be deleted when deprecations for arguments are removed.

36 39

DEFAULT_LOG_PATH = None

37 40

DEFAULT_SERVICE_LOG_PATH = "geckodriver.log"

@@ -212,8 +215,24 @@ def quit(self) -> None:

212 215

rmtree(self.profile.path)

213 216

if self.profile.tempfolder:

214 217

rmtree(self.profile.tempfolder)

215 -

except Exception as e:

216 -

print(str(e))

218 +

except Exception:

219 +

logger.exception("Unable to remove profile specific paths.")

220 + 221 +

self._close_binary_file_handle()

222 + 223 +

def _close_binary_file_handle(self) -> None:

224 +

"""Attempts to close the underlying file handles for `FirefoxBinary`

225 +

instances if they are used and open.

226 + 227 +

To keep inline with other cleanup raising here is swallowed and

228 +

will not cause a runtime error.

229 +

"""

230 +

try:

231 +

if isinstance(self.binary, FirefoxBinary):

232 +

if hasattr(self.binary._log_file, "close"):

233 +

self.binary._log_file.close()

234 +

except Exception:

235 +

logger.exception("Unable to close open file handle for firefox binary log file.")

217 236 218 237

@property

219 238

def firefox_profile(self):

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4