Skip to content

Commit

Permalink
[py]: Types and docs for wpiwebkit.service and additional args for …
Browse files Browse the repository at this point in the history
…consistency
  • Loading branch information
symonk committed Oct 5, 2022
1 parent 3e41af7 commit 4a759a8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
3 changes: 2 additions & 1 deletion py/selenium/webdriver/webkitgtk/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
import typing

from selenium.webdriver.common import service

Expand All @@ -37,5 +38,5 @@ def __init__(self, executable_path: str = DEFAULT_EXECUTABLE_PATH, port=0, log_p
log_file = open(log_path, "wb") if log_path else None
super().__init__(executable_path, port, log_file)

def command_line_args(self):
def command_line_args(self) -> typing.List[str]:
return ["-p", f"{self.port}"]
35 changes: 21 additions & 14 deletions py/selenium/webdriver/wpewebkit/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,35 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
import typing

from selenium.webdriver.common import service

DEFAULT_EXECUTABLE_PATH = "WPEWebDriver"


class Service(service.Service):
"""
Object that manages the starting and stopping of the WPEWebKitDriver
"""
"""A Service class that is responsible for the starting and stopping
of `WPEWebDriver`.
def __init__(self, executable_path: str = DEFAULT_EXECUTABLE_PATH, port=0, log_path=None):
"""
Creates a new instance of the Service
:param executable_path: install path of the WPEWebDriver executable, defaults to `WPEWebDriver`.
:param port: Port for the service to run on, defaults to 0 where the operating system will decide.
:param service_args: (Optional) Sequence 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 env: (Optional) Mapping of environment variables for the new process, defaults to `os.environ`.
"""

:Args:
- executable_path : Path to the WPEWebKitDriver
- port : Port the service is running on
- log_path : Path for the WPEWebKitDriver service to log to
"""
def __init__(
self,
executable_path: str = DEFAULT_EXECUTABLE_PATH,
port: int = 0,
log_path: typing.Optional[str] = None,
service_args: typing.Optional[typing.Sequence[str]] = None,
env: typing.Optional[typing.Mapping[str, str]] = None,
):
self.service_args = service_args or []
log_file = open(log_path, "wb") if log_path else None
super().__init__(executable_path, port, log_file)
super().__init__(executable=executable_path, port=port, log_file=log_file, env=env)

def command_line_args(self):
return ["-p", f"{self.port}"]
def command_line_args(self) -> typing.List[str]:
return ["-p", f"{self.port}"] + self.service_args

0 comments on commit 4a759a8

Please sign in to comment.