Skip to content

Commit

Permalink
fix(pre-commit): address pre-commit issues
Browse files Browse the repository at this point in the history
  • Loading branch information
vringar committed Jun 26, 2023
1 parent 03874ea commit 39d3175
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 20 deletions.
2 changes: 1 addition & 1 deletion hide_commands/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .commands import (SetResolution, SetPosition)
from .commands import SetPosition, SetResolution
37 changes: 18 additions & 19 deletions hide_commands/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@
"""
import logging

from tkinter import ttk

from selenium.webdriver import Firefox

from openwpm.commands.types import BaseCommand
from openwpm.config import BrowserParams, ManagerParams
from openwpm.socket_interface import ClientSocket

from selenium.webdriver import Firefox


def get_screen_resolution(driver):
def get_screen_resolution(driver: Firefox) -> list[int]:
return driver.execute_script("return [screen.width, screen.height];")


class SetResolution(BaseCommand):
""" Sets the browser window resolution """
def __init__(self, width, height) -> None:
"""Sets the browser window resolution"""

def __init__(self, width: int, height: int) -> None:
self.logger = logging.getLogger("openwpm")
self.width = width
self.height = height
Expand All @@ -39,22 +39,22 @@ def execute(
browser_params: BrowserParams,
manager_params: ManagerParams,
extension_socket: ClientSocket,
):

) -> None:
self.logger.info(f"Setting window resolution to {self.width} x {self.height} ")
driver.set_window_size(self.width, self.height)

resolution = get_screen_resolution(driver)
if resolution[0] <= self.width or resolution[1] <= self.height:
self.logger.warn(
f"Browser window resolution ({self.width} x {self.height}) exceeds " +
f"screen resolution ({resolution[0]} x {resolution[1]})")

f"Browser window resolution ({self.width} x {self.height}) exceeds "
+ f"screen resolution ({resolution[0]} x {resolution[1]})"
)


class SetPosition(BaseCommand):
""" Sets the browser window position """
def __init__(self, x, y) -> None:
"""Sets the browser window position"""

def __init__(self, x: int, y: int) -> None:
self.logger = logging.getLogger("openwpm")
self.x = x
self.y = y
Expand All @@ -68,6 +68,5 @@ def execute(
browser_params: BrowserParams,
manager_params: ManagerParams,
extension_socket: ClientSocket,
):

driver.set_window_position(self.x, self.y, windowHandle='current')
) -> None:
driver.set_window_position(self.x, self.y, windowHandle="current")

0 comments on commit 39d3175

Please sign in to comment.