Skip to content

Commit

Permalink
[py] remove deprecated log_file methods
Browse files Browse the repository at this point in the history
  • Loading branch information
titusfortner committed Sep 17, 2023
1 parent 8c21026 commit edf28c1
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 42 deletions.
4 changes: 1 addition & 3 deletions py/selenium/webdriver/chrome/service.py
Expand Up @@ -27,7 +27,7 @@ class Service(service.ChromiumService):
:param executable_path: install path of the chromedriver executable, defaults to `chromedriver`.
:param port: Port for the service to run on, defaults to 0 where the operating system will decide.
:param service_args: (Optional) List of args to be passed to the subprocess when launching the executable.
:param log_path: (Optional) String to be passed to the executable as `--log-path`.
:param log_output: (Optional) int representation of STDOUT/DEVNULL, any IO instance or String path to file.
:param env: (Optional) Mapping of environment variables for the new process, defaults to `os.environ`.
"""

Expand All @@ -36,7 +36,6 @@ def __init__(
executable_path=None,
port: int = 0,
service_args: typing.Optional[typing.List[str]] = None,
log_path: typing.Optional[str] = None,
log_output: SubprocessStdAlias = None,
env: typing.Optional[typing.Mapping[str, str]] = None,
**kwargs,
Expand All @@ -45,7 +44,6 @@ def __init__(
executable_path=executable_path,
port=port,
service_args=service_args,
log_path=log_path,
log_output=log_output,
env=env,
**kwargs,
Expand Down
8 changes: 1 addition & 7 deletions py/selenium/webdriver/chromium/service.py
Expand Up @@ -15,7 +15,6 @@
# specific language governing permissions and limitations
# under the License.
import typing
import warnings

from selenium.common import InvalidArgumentException
from selenium.types import SubprocessStdAlias
Expand All @@ -29,7 +28,7 @@ class ChromiumService(service.Service):
:param executable_path: install path of the executable.
:param port: Port for the service to run on, defaults to 0 where the operating system will decide.
:param service_args: (Optional) List of args to be passed to the subprocess when launching the executable.
:param log_path: (Optional) String to be passed to the executable as `--log-path`.
:param log_output: (Optional) int representation of STDOUT/DEVNULL, any IO instance or String path to file.
:param env: (Optional) Mapping of environment variables for the new process, defaults to `os.environ`.
"""

Expand All @@ -38,17 +37,12 @@ def __init__(
executable_path: str = None,
port: int = 0,
service_args: typing.Optional[typing.List[str]] = None,
log_path: typing.Optional[str] = None,
log_output: SubprocessStdAlias = None,
env: typing.Optional[typing.Mapping[str, str]] = None,
**kwargs,
) -> None:
self.service_args = service_args or []
self.log_output = log_output
if log_path is not None:
warnings.warn("log_path has been deprecated, please use log_output", DeprecationWarning, stacklevel=2)
self.log_output = log_path

if "--append-log" in self.service_args or "--readable-timestamp" in self.service_args:
if isinstance(self.log_output, str):
self.service_args.append(f"--log-path={self.log_output}")
Expand Down
9 changes: 1 addition & 8 deletions py/selenium/webdriver/common/service.py
Expand Up @@ -19,7 +19,6 @@
import os
import subprocess
import typing
import warnings
from abc import ABC
from abc import abstractmethod
from platform import system
Expand All @@ -43,16 +42,14 @@ class Service(ABC):
:param executable: install path of the executable.
:param port: Port for the service to run on, defaults to 0 where the operating system will decide.
:param log_file: (Optional) file descriptor (pos int) or file object with a valid file descriptor.
subprocess.PIPE & subprocess.DEVNULL are also valid values.
:param log_output: (Optional) int representation of STDOUT/DEVNULL, any IO instance or String path to file.
:param env: (Optional) Mapping of environment variables for the new process, defaults to `os.environ`.
"""

def __init__(
self,
executable: str = None,
port: int = 0,
log_file: SubprocessStdAlias = None,
log_output: SubprocessStdAlias = None,
env: typing.Optional[typing.Mapping[typing.Any, typing.Any]] = None,
**kwargs,
Expand All @@ -66,10 +63,6 @@ def __init__(
else:
self.log_output = log_output

if log_file is not None:
warnings.warn("log_file has been deprecated, please use log_output", DeprecationWarning, stacklevel=2)
self.log_output = open(log_file, "a+", encoding="utf-8")

self._path = executable
self.port = port or utils.free_port()
# Default value for every python subprocess: subprocess.Popen(..., creationflags=0)
Expand Down
4 changes: 1 addition & 3 deletions py/selenium/webdriver/edge/service.py
Expand Up @@ -29,7 +29,7 @@ class Service(service.ChromiumService):
:param port: Port for the service to run on, defaults to 0 where the operating system will decide.
:param verbose: (Deprecated) Whether to make the webdriver more verbose (passes the --verbose option to the binary).
Defaults to False.
:param log_path: (Optional) String to be passed to the executable as `--log-path`.
:param log_output: (Optional) int representation of STDOUT/DEVNULL, any IO instance or String path to file.
:param service_args: (Optional) List of args to be passed to the subprocess when launching the executable.
:param env: (Optional) Mapping of environment variables for the new process, defaults to `os.environ`.
"""
Expand All @@ -39,7 +39,6 @@ def __init__(
executable_path: str = None,
port: int = 0,
verbose: bool = False,
log_path: typing.Optional[str] = None,
log_output: SubprocessStdAlias = None,
service_args: typing.Optional[typing.List[str]] = None,
env: typing.Optional[typing.Mapping[str, str]] = None,
Expand All @@ -59,7 +58,6 @@ def __init__(
executable_path=executable_path,
port=port,
service_args=service_args,
log_path=log_path,
log_output=log_output,
env=env,
**kwargs,
Expand Down
16 changes: 1 addition & 15 deletions py/selenium/webdriver/firefox/service.py
Expand Up @@ -15,7 +15,6 @@
# specific language governing permissions and limitations
# under the License.
import typing
import warnings
from typing import List

from selenium.types import SubprocessStdAlias
Expand All @@ -30,8 +29,7 @@ class Service(service.Service):
:param executable_path: install path of the geckodriver executable, defaults to `geckodriver`.
:param port: Port for the service to run on, defaults to 0 where the operating system will decide.
:param service_args: (Optional) List of args to be passed to the subprocess when launching the executable.
:param log_path: (Optional) File path for the file to be opened and passed as the subprocess stdout/stderr handler,
defaults to `geckodriver.log`.
:param log_output: (Optional) int representation of STDOUT/DEVNULL, any IO instance or String path to file.
:param env: (Optional) Mapping of environment variables for the new process, defaults to `os.environ`.
"""

Expand All @@ -40,23 +38,11 @@ def __init__(
executable_path: str = None,
port: int = 0,
service_args: typing.Optional[typing.List[str]] = None,
log_path: typing.Optional[str] = None,
log_output: SubprocessStdAlias = None,
env: typing.Optional[typing.Mapping[str, str]] = None,
**kwargs,
) -> None:
self.service_args = service_args or []
if log_path is not None:
warnings.warn("log_path has been deprecated, please use log_output", DeprecationWarning, stacklevel=2)
log_output = open(log_path, "a+", encoding="utf-8")

if log_path is None and log_output is None:
warnings.warn(
"Firefox will soon stop logging to geckodriver.log by default; Specify desired logs with log_output",
DeprecationWarning,
stacklevel=2,
)
log_output = open("geckodriver.log", "a+", encoding="utf-8")

super().__init__(
executable=executable_path,
Expand Down
7 changes: 1 addition & 6 deletions py/selenium/webdriver/ie/service.py
Expand Up @@ -15,7 +15,6 @@
# specific language governing permissions and limitations
# under the License.
import typing
import warnings
from typing import List

from selenium.types import SubprocessStdAlias
Expand All @@ -33,7 +32,6 @@ def __init__(
service_args: typing.Optional[typing.List[str]] = None,
log_level: typing.Optional[str] = None,
log_output: SubprocessStdAlias = None,
log_file: typing.Optional[str] = None,
**kwargs,
) -> None:
"""Creates a new instance of the Service.
Expand All @@ -44,17 +42,14 @@ def __init__(
- host : IP address the service port is bound
- log_level : Level of logging of service, may be "FATAL", "ERROR", "WARN", "INFO", "DEBUG", "TRACE".
Default is "FATAL".
- log_file : Target of logging of service, may be "stdout", "stderr" or file path.
- log_output: (Optional) int representation of STDOUT/DEVNULL, any IO instance or String path to file.
Default is "stdout".
"""
self.service_args = service_args or []
if host:
self.service_args.append(f"--host={host}")
if log_level:
self.service_args.append(f"--log-level={log_level}")
if log_file:
warnings.warn("log_file has been deprecated, please use log_output", DeprecationWarning, stacklevel=2)
self.service_args.append(f"--log-file={log_file}")

super().__init__(
executable_path,
Expand Down

0 comments on commit edf28c1

Please sign in to comment.