pybenutils


Namepybenutils JSON
Version 7.2.0 PyPI version JSON
download
home_pageNone
SummaryPyBEN Utilities repository contains a variety of useful methods and classes designed to allow easy access to high-level operations
upload_time2025-07-17 16:27:15
maintainerNone
docs_urlNone
authorBen Moskovitch
requires_python>=3.8
licenseNone
keywords python proxmox gui utils utilities automation automation-tools
VCS
bugtrack_url
requirements requests supertools boto3 pywin32 pypiwin32 psutil selenium multiprocess pynput boto paramiko pysocks typing idna pyOpenSSL cryptography pyautogui pywinauto proxmoxer looseversion scp Appium-Python-Client
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # pybenutils

![GitHub License](https://img.shields.io/github/license/DarkFlameBEN/pybenutils)
[![PyPI - Version](https://img.shields.io/pypi/v/pybenutils)](https://pypi.org/project/pybenutils/)
![python suggested version](https://img.shields.io/badge/python-3.12.5-red.svg)
![python minimum version](https://img.shields.io/badge/python(min)-3.10+-red.svg)
![platforms](https://img.shields.io/badge/Platforms-Linux%20|%20Windows%20|%20Mac%20-purple.svg)

## Introduction
PyBEN Utilities repository contains a variety of useful methods and classes designed to allow easy access to high-level operations 

## Table of contents
1. [Getting started](#getting-started)
2. [Modules and Classes](#modules-and-classes)
   1. [AutoGUI module](#autogui-module)
   2. [simple_browser_controller_cls.py](#simple_browser_controller_cls)
      - [SimpleBrowserController](#simpleBrowserController)
      - [kill_all_browsers](#kill_all_browsers)
      - [close_all_browsers](#close_all_browsers)
   3. [selenium_utils.py](#selenium_utils)
      - [get_driver](#get_driver)
   4. [download_manager](#download_manager)
      - [download_url](#download_url)
   5. [ssh_utils](#ssh_utils)
      - [run_commands](#run_commands)
   6. [proxmox_utils](#proxmox_utils)

## Getting started

### Installation
Win:
> python -m pip install pybenutils -U

macOS:
> python3 -m pip install pybenutils -U

## Modules and Classes

### AutoGUI module
PyBenAutoGui - Class to automate cross platform GUI interactions.
```
options:                                                                                                                   
  -h, --help            show this help message and exit                                                                    
  -t TITLE, --title TITLE                                                                                                  
                        Window title                                                                                       
  -a APP_PATH, --app_path APP_PATH                                                                                         
                        Application/Exe path                                                                               
  -b PYWINAUTO_BACKEND, --pywinauto_backend PYWINAUTO_BACKEND                                                              
                        A name of used back-end in Windows OS (values: "win32", "uia")                                     
  -c COMMAND, --command COMMAND                                                                                            
                        Function name to execute in the AutoGui Class                                                      
  -eh, --extra_help, --no-extra_help                                                                                       
                        Display extra help about the class and its functions (default: False)

```

> python -m pybenutils.autogui -t "Calculator" -a calc.exe -c get_object_details -b uia

> python3 -m pybenutils.autogui -t "Calculator" -a /Application/Calculator.app -c get_object_details

```
class AutoGui(builtins.object)
 |  AutoGui(title, app_path, pywinauto_backend='uia')
 |  
 |  Methods defined here:
 |  
 |  __init__(self, title, app_path, pywinauto_backend='uia')
 |      Unified interface to interact with Gui Elements
 |      
 |      :param title: Window title
 |      :param app_path: Application/Exe path
 |      :param pywinauto_backend: A name of used back-end in Windows OS (values: "win32", "uia")
 |  
 |  click_on_text(self, text: str)
 |      Clicks on text object location using pyautogui
 |  
 |  find_objects(self, text='', control_type='')
 |      Returns an iterable containing the matching object
 |      
 |      :param text: Text to search, In windows can also be the automation_id
 |      :param control_type: Filter by control type
 |      :return: An iterable containing the matching object
 |  
 |  focus_on_window(self)
 |      Focus on the app window - bring to front
 |  
 |  get_object_details(self, text='', control_type='')
 |      Returns an iterable containing dicts of matching objects properties
 |      
 |      :param text: Text to search, In windows can also be the automation_id
 |      :param control_type: Filter by control type
 |      :return: An iterable containing dicts of matching objects properties
 |  
 |  get_object_position_by_text(self, text)
 |      Return position as tuple (xl, yt, xr, yb) in windows / (x, y) in mac
```

### simple_browser_controller_cls
#### SimpleBrowserController
The Simple Browser Controller is a class to help directly control the host browser using keyboard inputs

Login page example:
```python
import time
from pybenutils.browsers.simple_browser_controller_cls import SimpleBrowserController

br = SimpleBrowserController('chrome')
if not br.is_running():
    br.launch()
br.set_browser_url('https://some-url')
time.sleep(5)
br.send_keys_select_all()
time.sleep(1)
br.send_keys_select_all()
br.send_keyboard_keys('username')
br.press_tab_button()
br.send_keys_select_all()
br.send_keyboard_keys('password')
br.press_enter_button()
```
#### kill_all_browsers
Closes and kills all the process sharing the given process names in the input list

#### close_all_browsers
Closes all the process sharing the given process names in the input list

### selenium_utils
#### get_driver
```
Returns an active web driver instance
:param driver_name: name of the driver:
  - chrome (selenium)
  - firefox (selenium)
  - safari (selenium)
  - headless_chrome (selenium)
  - edge (selenium)
  - ios_x - Example: ios_chrome (Appium)
  - android_x - Example: android_chrome (Appium)
:param qa_extension: Whether to use qa extension
:return: web driver object (Selenium / Appium based)
```
Chrome and Firefox drivers has additional functions added in addition to the standard ones that comes from Selenium. 

New added functions:
 - get_number_open_tabs
 - is_site_displayed
 - set_selenium_log_level
 - get_logs_levels
 - gracefully_quit
 - switch_to_first_tab
 - switch_to_last_tab
 - close_secondary_tabs
 - open_new_tab
 - open_and_navigate_to_a_new_tab
 - is_scrollbar_exist
 - is_element_visible_in_viewpoint
 - wait_until_visible_by
 - click_on_xpath

ChromeDriver class new Kwargs
```
- default_user - [Boolean] Use the default Chrome user installed on the OS (user-data-dir)
- fullscreen - [Boolean] Open window at fullscreen (--start-maximized)
- excludeSwitches - [List] of switches to exclude (options.add_experimental_option("excludeSwitches", [x]))
- crx_path - [Str] Open with extension pre-installed (options.add_extension)
- option_args - [List] of arguments to be added to options (options.add_argument(x))
- log_level - [Str] Selenium and urllib3 log level (CRITICAL / FATAL / ERROR / WARNING / INFO / DEBUG / NOTSET)
- launch_attempts - [int] Permitted number of attempts to launch the selenium web driver
- headless - [Boolean] Open the Chrome instance without visible gui (--headless)
- incognito - [Boolean] Open the Chrome instance in incognito mode
- only_current_dir_for_binary - [Boolean] Assume the binary HAS to be in the current working directory
```

FirefoxDriver class new Kwargs
```
- option_args - [List] of arguments to be added to options (options.add_argument(x))
- log_level - [Str] Selenium and urllib3 log level (CRITICAL / FATAL / ERROR / WARNING / INFO / DEBUG / NOTSET)
- launch_attempts - [int] Permitted number of attempts to launch the selenium web driver
- only_current_dir_for_binary - [Boolean] Assume the binary HAS to be in the current working directory
```

### download_manager
#### download_url
```
Downloads a URL content into a file (with large file support by streaming)

:param url: URL to download_url
:param file_path: Local file name to contain the data downloaded
:param attempts: Number of attempts
:param raise_failure: Raise Exception on failure
:param verify_ssl: Verify the domain ssl
:return: New file path. Empty string if the download_url failed
```

### ssh_utils
#### run_commands
```
Execute the given commands trough ssh connection

 Special commands:
  - RECURSIVE-PUT file_path/folder_path [To local_path] - Copy the target from remote to local recursively
  - GET file_path/folder_path [To local_path] - Copy the target from remote to local
  - RECURSIVE-PUT file_path/folder_path TO remote_path - Sends file from local to remote recursively
  - PUT file_path/folder_path TO remote_path - Sends file from local to remote

:param server: Remote server ip
:param username: Remote server username
:param password: Remote server password
:param commands: List of commands to execute
:param stop_on_exception: Will stop executing commands if an exception occurred
:param stop_on_error: Will stop executing commands if an execution returned an stderr string
:return: List of return objects [{'ssh_stdin': str, 'ssh_stdout': str, 'ssh_stderr': str}]
```

### proxmox_utils
#### ProxmoxCls class
PyBEN Proxmox repository is an easy to use python utility class for Proxmox server solution

![Static Badge](https://img.shields.io/badge/pybenproxmox-blue?link=https%3A%2F%2Fpypi.org%2Fproject%2Fpybenproxmox%2F)
[![PyPI - Version](https://img.shields.io/pypi/v/pybenproxmox)](https://pypi.org/project/pybenproxmox/)

Some of the included functions:
 - get_vms: Returns a full list of vms, or list with matching vms by id or name
 - clone_vms
 - migrate_vm_to_node
 - delete_vm
 - start_vm
 - stop_vm
 - snapshot handling
 - and more ...

### More functions
There are a lot of additional functions i have created over the years. Look around and find some treasures

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "pybenutils",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "Ben Moskovitch <darkflameben@gmail.com>",
    "keywords": "python, proxmox, gui, utils, utilities, automation, automation-tools",
    "author": "Ben Moskovitch",
    "author_email": "Ben Moskovitch <darkflameben@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/3b/0c/e6cb4d8d575fa89ea81141c0382416112c115895af1d4815b846a416ce48/pybenutils-7.2.0.tar.gz",
    "platform": null,
    "description": "# pybenutils\r\n\r\n![GitHub License](https://img.shields.io/github/license/DarkFlameBEN/pybenutils)\r\n[![PyPI - Version](https://img.shields.io/pypi/v/pybenutils)](https://pypi.org/project/pybenutils/)\r\n![python suggested version](https://img.shields.io/badge/python-3.12.5-red.svg)\r\n![python minimum version](https://img.shields.io/badge/python(min)-3.10+-red.svg)\r\n![platforms](https://img.shields.io/badge/Platforms-Linux%20|%20Windows%20|%20Mac%20-purple.svg)\r\n\r\n## Introduction\r\nPyBEN Utilities repository contains a variety of useful methods and classes designed to allow easy access to high-level operations \r\n\r\n## Table of contents\r\n1. [Getting started](#getting-started)\r\n2. [Modules and Classes](#modules-and-classes)\r\n   1. [AutoGUI module](#autogui-module)\r\n   2. [simple_browser_controller_cls.py](#simple_browser_controller_cls)\r\n      - [SimpleBrowserController](#simpleBrowserController)\r\n      - [kill_all_browsers](#kill_all_browsers)\r\n      - [close_all_browsers](#close_all_browsers)\r\n   3. [selenium_utils.py](#selenium_utils)\r\n      - [get_driver](#get_driver)\r\n   4. [download_manager](#download_manager)\r\n      - [download_url](#download_url)\r\n   5. [ssh_utils](#ssh_utils)\r\n      - [run_commands](#run_commands)\r\n   6. [proxmox_utils](#proxmox_utils)\r\n\r\n## Getting started\r\n\r\n### Installation\r\nWin:\r\n> python -m pip install pybenutils -U\r\n\r\nmacOS:\r\n> python3 -m pip install pybenutils -U\r\n\r\n## Modules and Classes\r\n\r\n### AutoGUI module\r\nPyBenAutoGui - Class to automate cross platform GUI interactions.\r\n```\r\noptions:                                                                                                                   \r\n  -h, --help            show this help message and exit                                                                    \r\n  -t TITLE, --title TITLE                                                                                                  \r\n                        Window title                                                                                       \r\n  -a APP_PATH, --app_path APP_PATH                                                                                         \r\n                        Application/Exe path                                                                               \r\n  -b PYWINAUTO_BACKEND, --pywinauto_backend PYWINAUTO_BACKEND                                                              \r\n                        A name of used back-end in Windows OS (values: \"win32\", \"uia\")                                     \r\n  -c COMMAND, --command COMMAND                                                                                            \r\n                        Function name to execute in the AutoGui Class                                                      \r\n  -eh, --extra_help, --no-extra_help                                                                                       \r\n                        Display extra help about the class and its functions (default: False)\r\n\r\n```\r\n\r\n> python -m pybenutils.autogui -t \"Calculator\" -a calc.exe -c get_object_details -b uia\r\n\r\n> python3 -m pybenutils.autogui -t \"Calculator\" -a /Application/Calculator.app -c get_object_details\r\n\r\n```\r\nclass AutoGui(builtins.object)\r\n |  AutoGui(title, app_path, pywinauto_backend='uia')\r\n |  \r\n |  Methods defined here:\r\n |  \r\n |  __init__(self, title, app_path, pywinauto_backend='uia')\r\n |      Unified interface to interact with Gui Elements\r\n |      \r\n |      :param title: Window title\r\n |      :param app_path: Application/Exe path\r\n |      :param pywinauto_backend: A name of used back-end in Windows OS (values: \"win32\", \"uia\")\r\n |  \r\n |  click_on_text(self, text: str)\r\n |      Clicks on text object location using pyautogui\r\n |  \r\n |  find_objects(self, text='', control_type='')\r\n |      Returns an iterable containing the matching object\r\n |      \r\n |      :param text: Text to search, In windows can also be the automation_id\r\n |      :param control_type: Filter by control type\r\n |      :return: An iterable containing the matching object\r\n |  \r\n |  focus_on_window(self)\r\n |      Focus on the app window - bring to front\r\n |  \r\n |  get_object_details(self, text='', control_type='')\r\n |      Returns an iterable containing dicts of matching objects properties\r\n |      \r\n |      :param text: Text to search, In windows can also be the automation_id\r\n |      :param control_type: Filter by control type\r\n |      :return: An iterable containing dicts of matching objects properties\r\n |  \r\n |  get_object_position_by_text(self, text)\r\n |      Return position as tuple (xl, yt, xr, yb) in windows / (x, y) in mac\r\n```\r\n\r\n### simple_browser_controller_cls\r\n#### SimpleBrowserController\r\nThe Simple Browser Controller is a class to help directly control the host browser using keyboard inputs\r\n\r\nLogin page example:\r\n```python\r\nimport time\r\nfrom pybenutils.browsers.simple_browser_controller_cls import SimpleBrowserController\r\n\r\nbr = SimpleBrowserController('chrome')\r\nif not br.is_running():\r\n    br.launch()\r\nbr.set_browser_url('https://some-url')\r\ntime.sleep(5)\r\nbr.send_keys_select_all()\r\ntime.sleep(1)\r\nbr.send_keys_select_all()\r\nbr.send_keyboard_keys('username')\r\nbr.press_tab_button()\r\nbr.send_keys_select_all()\r\nbr.send_keyboard_keys('password')\r\nbr.press_enter_button()\r\n```\r\n#### kill_all_browsers\r\nCloses and kills all the process sharing the given process names in the input list\r\n\r\n#### close_all_browsers\r\nCloses all the process sharing the given process names in the input list\r\n\r\n### selenium_utils\r\n#### get_driver\r\n```\r\nReturns an active web driver instance\r\n:param driver_name: name of the driver:\r\n  - chrome (selenium)\r\n  - firefox (selenium)\r\n  - safari (selenium)\r\n  - headless_chrome (selenium)\r\n  - edge (selenium)\r\n  - ios_x - Example: ios_chrome (Appium)\r\n  - android_x - Example: android_chrome (Appium)\r\n:param qa_extension: Whether to use qa extension\r\n:return: web driver object (Selenium / Appium based)\r\n```\r\nChrome and Firefox drivers has additional functions added in addition to the standard ones that comes from Selenium. \r\n\r\nNew added functions:\r\n - get_number_open_tabs\r\n - is_site_displayed\r\n - set_selenium_log_level\r\n - get_logs_levels\r\n - gracefully_quit\r\n - switch_to_first_tab\r\n - switch_to_last_tab\r\n - close_secondary_tabs\r\n - open_new_tab\r\n - open_and_navigate_to_a_new_tab\r\n - is_scrollbar_exist\r\n - is_element_visible_in_viewpoint\r\n - wait_until_visible_by\r\n - click_on_xpath\r\n\r\nChromeDriver class new Kwargs\r\n```\r\n- default_user - [Boolean] Use the default Chrome user installed on the OS (user-data-dir)\r\n- fullscreen - [Boolean] Open window at fullscreen (--start-maximized)\r\n- excludeSwitches - [List] of switches to exclude (options.add_experimental_option(\"excludeSwitches\", [x]))\r\n- crx_path - [Str] Open with extension pre-installed (options.add_extension)\r\n- option_args - [List] of arguments to be added to options (options.add_argument(x))\r\n- log_level - [Str] Selenium and urllib3 log level (CRITICAL / FATAL / ERROR / WARNING / INFO / DEBUG / NOTSET)\r\n- launch_attempts - [int] Permitted number of attempts to launch the selenium web driver\r\n- headless - [Boolean] Open the Chrome instance without visible gui (--headless)\r\n- incognito - [Boolean] Open the Chrome instance in incognito mode\r\n- only_current_dir_for_binary - [Boolean] Assume the binary HAS to be in the current working directory\r\n```\r\n\r\nFirefoxDriver class new Kwargs\r\n```\r\n- option_args - [List] of arguments to be added to options (options.add_argument(x))\r\n- log_level - [Str] Selenium and urllib3 log level (CRITICAL / FATAL / ERROR / WARNING / INFO / DEBUG / NOTSET)\r\n- launch_attempts - [int] Permitted number of attempts to launch the selenium web driver\r\n- only_current_dir_for_binary - [Boolean] Assume the binary HAS to be in the current working directory\r\n```\r\n\r\n### download_manager\r\n#### download_url\r\n```\r\nDownloads a URL content into a file (with large file support by streaming)\r\n\r\n:param url: URL to download_url\r\n:param file_path: Local file name to contain the data downloaded\r\n:param attempts: Number of attempts\r\n:param raise_failure: Raise Exception on failure\r\n:param verify_ssl: Verify the domain ssl\r\n:return: New file path. Empty string if the download_url failed\r\n```\r\n\r\n### ssh_utils\r\n#### run_commands\r\n```\r\nExecute the given commands trough ssh connection\r\n\r\n Special commands:\r\n  - RECURSIVE-PUT file_path/folder_path [To local_path] - Copy the target from remote to local recursively\r\n  - GET file_path/folder_path [To local_path] - Copy the target from remote to local\r\n  - RECURSIVE-PUT file_path/folder_path TO remote_path - Sends file from local to remote recursively\r\n  - PUT file_path/folder_path TO remote_path - Sends file from local to remote\r\n\r\n:param server: Remote server ip\r\n:param username: Remote server username\r\n:param password: Remote server password\r\n:param commands: List of commands to execute\r\n:param stop_on_exception: Will stop executing commands if an exception occurred\r\n:param stop_on_error: Will stop executing commands if an execution returned an stderr string\r\n:return: List of return objects [{'ssh_stdin': str, 'ssh_stdout': str, 'ssh_stderr': str}]\r\n```\r\n\r\n### proxmox_utils\r\n#### ProxmoxCls class\r\nPyBEN Proxmox repository is an easy to use python utility class for Proxmox server solution\r\n\r\n![Static Badge](https://img.shields.io/badge/pybenproxmox-blue?link=https%3A%2F%2Fpypi.org%2Fproject%2Fpybenproxmox%2F)\r\n[![PyPI - Version](https://img.shields.io/pypi/v/pybenproxmox)](https://pypi.org/project/pybenproxmox/)\r\n\r\nSome of the included functions:\r\n - get_vms: Returns a full list of vms, or list with matching vms by id or name\r\n - clone_vms\r\n - migrate_vm_to_node\r\n - delete_vm\r\n - start_vm\r\n - stop_vm\r\n - snapshot handling\r\n - and more ...\r\n\r\n### More functions\r\nThere are a lot of additional functions i have created over the years. Look around and find some treasures\r\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "PyBEN Utilities repository contains a variety of useful methods and classes designed to allow easy access to high-level operations",
    "version": "7.2.0",
    "project_urls": {
        "Homepage": "https://github.com/DarkFlameBEN/pybenutils.git"
    },
    "split_keywords": [
        "python",
        " proxmox",
        " gui",
        " utils",
        " utilities",
        " automation",
        " automation-tools"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "83ce108f9203b369e56076d2e3035c1ba4518626e987e76bc24a844a9cc075bd",
                "md5": "b8f3df81c412fbcad5fcb96d497f5e26",
                "sha256": "09f293ca9b3e7151fd67c842b4be142f42abf2a3d9af761790683f126000f99d"
            },
            "downloads": -1,
            "filename": "pybenutils-7.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b8f3df81c412fbcad5fcb96d497f5e26",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 62305,
            "upload_time": "2025-07-17T16:27:14",
            "upload_time_iso_8601": "2025-07-17T16:27:14.024512Z",
            "url": "https://files.pythonhosted.org/packages/83/ce/108f9203b369e56076d2e3035c1ba4518626e987e76bc24a844a9cc075bd/pybenutils-7.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "3b0ce6cb4d8d575fa89ea81141c0382416112c115895af1d4815b846a416ce48",
                "md5": "996402abe2857f514db84b795787e1ff",
                "sha256": "06ad04e41e6782d5d778a9c89de3777775ecf10913f091c545dfc95b65ec1cf3"
            },
            "downloads": -1,
            "filename": "pybenutils-7.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "996402abe2857f514db84b795787e1ff",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 57180,
            "upload_time": "2025-07-17T16:27:15",
            "upload_time_iso_8601": "2025-07-17T16:27:15.173988Z",
            "url": "https://files.pythonhosted.org/packages/3b/0c/e6cb4d8d575fa89ea81141c0382416112c115895af1d4815b846a416ce48/pybenutils-7.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-17 16:27:15",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "DarkFlameBEN",
    "github_project": "pybenutils",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "requests",
            "specs": []
        },
        {
            "name": "supertools",
            "specs": []
        },
        {
            "name": "boto3",
            "specs": []
        },
        {
            "name": "pywin32",
            "specs": []
        },
        {
            "name": "pypiwin32",
            "specs": []
        },
        {
            "name": "psutil",
            "specs": []
        },
        {
            "name": "selenium",
            "specs": []
        },
        {
            "name": "multiprocess",
            "specs": []
        },
        {
            "name": "pynput",
            "specs": []
        },
        {
            "name": "boto",
            "specs": []
        },
        {
            "name": "paramiko",
            "specs": []
        },
        {
            "name": "pysocks",
            "specs": []
        },
        {
            "name": "typing",
            "specs": []
        },
        {
            "name": "idna",
            "specs": []
        },
        {
            "name": "pyOpenSSL",
            "specs": []
        },
        {
            "name": "cryptography",
            "specs": []
        },
        {
            "name": "pyautogui",
            "specs": []
        },
        {
            "name": "pywinauto",
            "specs": []
        },
        {
            "name": "proxmoxer",
            "specs": []
        },
        {
            "name": "looseversion",
            "specs": []
        },
        {
            "name": "scp",
            "specs": []
        },
        {
            "name": "Appium-Python-Client",
            "specs": []
        }
    ],
    "lcname": "pybenutils"
}
        
Elapsed time: 1.88733s