pybenutils 7.12.0__tar.gz → 7.14.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pybenutils-7.12.0/pybenutils.egg-info → pybenutils-7.14.0}/PKG-INFO +1 -1
- {pybenutils-7.12.0 → pybenutils-7.14.0}/pybenutils/browsers/simple_browser_controller_cls.py +18 -3
- {pybenutils-7.12.0 → pybenutils-7.14.0}/pybenutils/os_operations/mac_operations.py +32 -0
- pybenutils-7.14.0/pybenutils/utils_logger/config_logger.py +50 -0
- {pybenutils-7.12.0 → pybenutils-7.14.0/pybenutils.egg-info}/PKG-INFO +1 -1
- {pybenutils-7.12.0 → pybenutils-7.14.0}/pyproject.toml +1 -1
- pybenutils-7.12.0/pybenutils/utils_logger/config_logger.py +0 -48
- {pybenutils-7.12.0 → pybenutils-7.14.0}/DEPLOYMENT.md +0 -0
- {pybenutils-7.12.0 → pybenutils-7.14.0}/LICENSE +0 -0
- {pybenutils-7.12.0 → pybenutils-7.14.0}/MANIFEST.in +0 -0
- {pybenutils-7.12.0 → pybenutils-7.14.0}/README.md +0 -0
- {pybenutils-7.12.0 → pybenutils-7.14.0}/deploy_requirements.txt +0 -0
- {pybenutils-7.12.0 → pybenutils-7.14.0}/pybenutils/__init__.py +0 -0
- {pybenutils-7.12.0 → pybenutils-7.14.0}/pybenutils/amazon_boto3/__init__.py +0 -0
- {pybenutils-7.12.0 → pybenutils-7.14.0}/pybenutils/amazon_boto3/amazon_obj.py +0 -0
- {pybenutils-7.12.0 → pybenutils-7.14.0}/pybenutils/autogui/__init__.py +0 -0
- {pybenutils-7.12.0 → pybenutils-7.14.0}/pybenutils/autogui/__main__.py +0 -0
- {pybenutils-7.12.0 → pybenutils-7.14.0}/pybenutils/autogui/auto_gui_cls.py +0 -0
- {pybenutils-7.12.0 → pybenutils-7.14.0}/pybenutils/browsers/__init__.py +0 -0
- {pybenutils-7.12.0 → pybenutils-7.14.0}/pybenutils/browsers/chrome.py +0 -0
- {pybenutils-7.12.0 → pybenutils-7.14.0}/pybenutils/browsers/firefox.py +0 -0
- {pybenutils-7.12.0 → pybenutils-7.14.0}/pybenutils/browsers/selenium_utils.py +0 -0
- {pybenutils-7.12.0 → pybenutils-7.14.0}/pybenutils/browsers/web_driver.py +0 -0
- {pybenutils-7.12.0 → pybenutils-7.14.0}/pybenutils/browsers/windows_browsers_keywords.py +0 -0
- {pybenutils-7.12.0 → pybenutils-7.14.0}/pybenutils/cli_tools.py +0 -0
- {pybenutils-7.12.0 → pybenutils-7.14.0}/pybenutils/network/__init__.py +0 -0
- {pybenutils-7.12.0 → pybenutils-7.14.0}/pybenutils/network/download_manager.py +0 -0
- {pybenutils-7.12.0 → pybenutils-7.14.0}/pybenutils/network/http_cert_info.py +0 -0
- {pybenutils-7.12.0 → pybenutils-7.14.0}/pybenutils/network/s3_bucket_cls.py +0 -0
- {pybenutils-7.12.0 → pybenutils-7.14.0}/pybenutils/network/ssh_helper.py +0 -0
- {pybenutils-7.12.0 → pybenutils-7.14.0}/pybenutils/network/ssh_utils.py +0 -0
- {pybenutils-7.12.0 → pybenutils-7.14.0}/pybenutils/os_operations/__init__.py +0 -0
- {pybenutils-7.12.0 → pybenutils-7.14.0}/pybenutils/os_operations/files_and_directories.py +0 -0
- {pybenutils-7.12.0 → pybenutils-7.14.0}/pybenutils/os_operations/mac_application_control.py +0 -0
- {pybenutils-7.12.0 → pybenutils-7.14.0}/pybenutils/os_operations/mac_input_control.py +0 -0
- {pybenutils-7.12.0 → pybenutils-7.14.0}/pybenutils/os_operations/mac_popup_handler.py +0 -0
- {pybenutils-7.12.0 → pybenutils-7.14.0}/pybenutils/os_operations/process.py +0 -0
- {pybenutils-7.12.0 → pybenutils-7.14.0}/pybenutils/os_operations/window_operations.py +0 -0
- {pybenutils-7.12.0 → pybenutils-7.14.0}/pybenutils/proxmox_utils.py +0 -0
- {pybenutils-7.12.0 → pybenutils-7.14.0}/pybenutils/tests_files_utils.py +0 -0
- {pybenutils-7.12.0 → pybenutils-7.14.0}/pybenutils/useful.py +0 -0
- {pybenutils-7.12.0 → pybenutils-7.14.0}/pybenutils/utils_logger/__init__.py +0 -0
- {pybenutils-7.12.0 → pybenutils-7.14.0}/pybenutils/windows_registry.py +0 -0
- {pybenutils-7.12.0 → pybenutils-7.14.0}/pybenutils.egg-info/SOURCES.txt +0 -0
- {pybenutils-7.12.0 → pybenutils-7.14.0}/pybenutils.egg-info/dependency_links.txt +0 -0
- {pybenutils-7.12.0 → pybenutils-7.14.0}/pybenutils.egg-info/requires.txt +0 -0
- {pybenutils-7.12.0 → pybenutils-7.14.0}/pybenutils.egg-info/top_level.txt +0 -0
- {pybenutils-7.12.0 → pybenutils-7.14.0}/setup.cfg +0 -0
- {pybenutils-7.12.0 → pybenutils-7.14.0}/tests/test_self_import.py +0 -0
- {pybenutils-7.12.0 → pybenutils-7.14.0}/webserver/pyserver.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pybenutils
|
|
3
|
-
Version: 7.
|
|
3
|
+
Version: 7.14.0
|
|
4
4
|
Summary: PyBEN Utilities repository contains a variety of useful methods and classes designed to allow easy access to high-level operations
|
|
5
5
|
Author: Ben Moskovitch
|
|
6
6
|
Author-email: Ben Moskovitch <darkflameben@gmail.com>
|
{pybenutils-7.12.0 → pybenutils-7.14.0}/pybenutils/browsers/simple_browser_controller_cls.py
RENAMED
|
@@ -16,7 +16,7 @@ if sys.platform == 'win32':
|
|
|
16
16
|
import win32com.client
|
|
17
17
|
import win32gui
|
|
18
18
|
elif sys.platform == 'darwin':
|
|
19
|
-
from pybenutils.os_operations.mac_operations import run_apple_script
|
|
19
|
+
from pybenutils.os_operations.mac_operations import run_apple_script, get_front_window_bounds
|
|
20
20
|
|
|
21
21
|
logger = get_logger()
|
|
22
22
|
|
|
@@ -727,8 +727,23 @@ class SimpleBrowserController:
|
|
|
727
727
|
# xdotool windowactivate is the closest analogue: brings window to front + focus.
|
|
728
728
|
return self._linux_focus_browser()
|
|
729
729
|
else:
|
|
730
|
-
|
|
731
|
-
|
|
730
|
+
try:
|
|
731
|
+
bounds = get_front_window_bounds(self.browser_name)
|
|
732
|
+
if not bounds:
|
|
733
|
+
return False
|
|
734
|
+
x, y, w, h = bounds
|
|
735
|
+
# Click just below the title bar, near the top-left of the window's content area
|
|
736
|
+
click_x = x + min(10, max(1, w - 1))
|
|
737
|
+
click_y = y + min(130, max(1, h - 1))
|
|
738
|
+
from pynput.mouse import Button, Controller
|
|
739
|
+
mouse = Controller()
|
|
740
|
+
mouse.position = (click_x, click_y)
|
|
741
|
+
mouse.press(Button.left)
|
|
742
|
+
mouse.release(Button.left)
|
|
743
|
+
return True
|
|
744
|
+
except Exception as ex:
|
|
745
|
+
logger.error(f'Failed to set focus by mouse click on mac: {ex}')
|
|
746
|
+
return False
|
|
732
747
|
|
|
733
748
|
def send_console_command(self, command: str):
|
|
734
749
|
"""Sends console commands to the browser using keyboard navigation"""
|
|
@@ -123,6 +123,38 @@ def run_apple_script(cmd, timeout=300):
|
|
|
123
123
|
return None
|
|
124
124
|
|
|
125
125
|
|
|
126
|
+
def get_front_window_bounds(app_name):
|
|
127
|
+
"""Return the position and size of the front window of the given macOS app.
|
|
128
|
+
|
|
129
|
+
Runs an AppleScript that activates the app and asks System Events for the
|
|
130
|
+
front window's position and size.
|
|
131
|
+
|
|
132
|
+
:param app_name: The macOS application name (e.g. "Google Chrome")
|
|
133
|
+
:return: Tuple (x, y, w, h) or None if the app / window was not found
|
|
134
|
+
"""
|
|
135
|
+
cmd = f'''
|
|
136
|
+
set appName to "{app_name}"
|
|
137
|
+
tell application "System Events"
|
|
138
|
+
if (name of processes) contains appName then
|
|
139
|
+
tell application appName to activate
|
|
140
|
+
delay 0.2
|
|
141
|
+
tell process appName
|
|
142
|
+
if (count of windows) > 0 then
|
|
143
|
+
set winPos to position of front window
|
|
144
|
+
set winSize to size of front window
|
|
145
|
+
return ((item 1 of winPos) as string) & "," & ((item 2 of winPos) as string) & "," & ((item 1 of winSize) as string) & "," & ((item 2 of winSize) as string)
|
|
146
|
+
end if
|
|
147
|
+
end tell
|
|
148
|
+
end if
|
|
149
|
+
end tell
|
|
150
|
+
return ""
|
|
151
|
+
'''
|
|
152
|
+
result = run_apple_script(cmd)
|
|
153
|
+
if not result:
|
|
154
|
+
return None
|
|
155
|
+
return tuple(int(v) for v in result.split(','))
|
|
156
|
+
|
|
157
|
+
|
|
126
158
|
def mount_image_mac(image_path, raise_on_error=False, space_in_name=True):
|
|
127
159
|
"""Mount image in macOS
|
|
128
160
|
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import inspect
|
|
2
|
+
import logging
|
|
3
|
+
import logging.config
|
|
4
|
+
import os
|
|
5
|
+
import sys
|
|
6
|
+
import time
|
|
7
|
+
from collections import defaultdict
|
|
8
|
+
from logging.handlers import RotatingFileHandler
|
|
9
|
+
|
|
10
|
+
INITIALIZED = defaultdict(bool)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def set_logger(logger_name):
|
|
14
|
+
logger = logging.getLogger(logger_name)
|
|
15
|
+
|
|
16
|
+
if not logger.handlers:
|
|
17
|
+
logger.setLevel(logging.DEBUG)
|
|
18
|
+
fh = RotatingFileHandler('{}.log'.format(logger_name), 'w+', encoding='utf-8')
|
|
19
|
+
formatter = logging.Formatter(
|
|
20
|
+
'[%(asctime)s] | %(module)-20s | %(funcName)-20s | %(levelname)-7s : %(message)s')
|
|
21
|
+
formatter.converter = time.localtime
|
|
22
|
+
fh.setFormatter(formatter)
|
|
23
|
+
|
|
24
|
+
ch = logging.StreamHandler(stream=sys.stdout)
|
|
25
|
+
ch.setLevel(logging.DEBUG)
|
|
26
|
+
ch.setFormatter(formatter)
|
|
27
|
+
|
|
28
|
+
eh = logging.StreamHandler(stream=sys.stderr)
|
|
29
|
+
eh.setLevel(logging.ERROR)
|
|
30
|
+
eh.setFormatter(formatter)
|
|
31
|
+
|
|
32
|
+
logger.addHandler(ch)
|
|
33
|
+
logger.addHandler(fh)
|
|
34
|
+
|
|
35
|
+
INITIALIZED[logger_name] = True
|
|
36
|
+
|
|
37
|
+
return logger
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def get_logger(logger_name='main_logger'):
|
|
41
|
+
"""Returns a logger object with a given title.
|
|
42
|
+
|
|
43
|
+
:param logger_name: If empty the logger name will be based on the calling module
|
|
44
|
+
:return: logging.Logger object
|
|
45
|
+
"""
|
|
46
|
+
if not logger_name:
|
|
47
|
+
frame = inspect.stack()[1]
|
|
48
|
+
module = inspect.getmodule(frame[0])
|
|
49
|
+
logger_name = os.path.basename(module.__file__)
|
|
50
|
+
return logging.getLogger(logger_name) if INITIALIZED[logger_name] else set_logger(logger_name)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pybenutils
|
|
3
|
-
Version: 7.
|
|
3
|
+
Version: 7.14.0
|
|
4
4
|
Summary: PyBEN Utilities repository contains a variety of useful methods and classes designed to allow easy access to high-level operations
|
|
5
5
|
Author: Ben Moskovitch
|
|
6
6
|
Author-email: Ben Moskovitch <darkflameben@gmail.com>
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "pybenutils"
|
|
7
|
-
version = "7.
|
|
7
|
+
version = "7.14.0"
|
|
8
8
|
description = "PyBEN Utilities repository contains a variety of useful methods and classes designed to allow easy access to high-level operations"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.8"
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import inspect
|
|
2
|
-
import logging
|
|
3
|
-
import logging.config
|
|
4
|
-
import os
|
|
5
|
-
import sys
|
|
6
|
-
import time
|
|
7
|
-
from collections import defaultdict
|
|
8
|
-
from logging.handlers import RotatingFileHandler
|
|
9
|
-
|
|
10
|
-
INITIALIZED = defaultdict(bool)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
def set_logger(logger_name):
|
|
14
|
-
logger = logging.getLogger(logger_name)
|
|
15
|
-
logger.setLevel(logging.DEBUG)
|
|
16
|
-
fh = RotatingFileHandler('{}.log'.format(logger_name), 'w+', encoding='utf-8')
|
|
17
|
-
formatter = logging.Formatter(
|
|
18
|
-
'[%(asctime)s] | %(module)-20s | %(funcName)-20s | %(levelname)-7s : %(message)s')
|
|
19
|
-
formatter.converter = time.localtime
|
|
20
|
-
fh.setFormatter(formatter)
|
|
21
|
-
|
|
22
|
-
ch = logging.StreamHandler(stream=sys.stdout)
|
|
23
|
-
ch.setLevel(logging.DEBUG)
|
|
24
|
-
ch.setFormatter(formatter)
|
|
25
|
-
|
|
26
|
-
eh = logging.StreamHandler(stream=sys.stderr)
|
|
27
|
-
eh.setLevel(logging.ERROR)
|
|
28
|
-
eh.setFormatter(formatter)
|
|
29
|
-
|
|
30
|
-
logger.addHandler(ch)
|
|
31
|
-
logger.addHandler(fh)
|
|
32
|
-
|
|
33
|
-
INITIALIZED[logger_name] = True
|
|
34
|
-
|
|
35
|
-
return logger
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
def get_logger(logger_name='main_logger'):
|
|
39
|
-
"""Returns a logger object with a given title
|
|
40
|
-
|
|
41
|
-
:param logger_name: If empty the logger name will be based on the calling module
|
|
42
|
-
:return: Logger object
|
|
43
|
-
"""
|
|
44
|
-
if not logger_name:
|
|
45
|
-
frame = inspect.stack()[1]
|
|
46
|
-
module = inspect.getmodule(frame[0])
|
|
47
|
-
logger_name = os.path.basename(module.__file__)
|
|
48
|
-
return logging.getLogger(logger_name) if INITIALIZED[logger_name] else set_logger(logger_name)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|