Skip to main content

Tool for RDP (Remote Desktop Protocol) manipulations, automations and testing via Python and Apache Guacamole

Project description

rdp-manipulations

Tool for image-based control RDP (Remote Desktop Protocol). Manipulations, automations and testing via Python and Apache Guacamole

Prerequisites

Installed and configured Apache Guacamole. I used this guacamole docker project: https://github.com/boschkundendienst/guacamole-docker-compose

Examples

see ./examples folder. To run it, clone this repo, and:

poetry shell
poetry install
python examples/copy_and_zip.py

Supported OS

Only Windows 7 is currently supported because I only needed to work with Windows 7 PCs. If you need support for other OSes, use your ASSERT_DICT, make a pull request, or write an issue. We'll figure something out.

Table of Contents

main

ASSERT_DICT

Pass it to instance of RDP for unsupported OS (see below)

{
    'prelogin': './image_asserts/prelogin.png',
    'login': './image_asserts/login.png',
    'post_login': './image_asserts/post_login.png',
    'start_btn': './image_asserts/start_btn.png',
    'start_btn_selected': './image_asserts/start_btn_selected.png',
    'run_window': './image_asserts/run_window.png',
    'lang_ru': './image_asserts/lang_ru.png',
    'lang_en': './image_asserts/lang_en.png',
    'opened_folder': './image_asserts/opened_folder.png',
    'files_copy': './image_asserts/files_copy.png',
}

RDP Objects

class RDP()

RDP class

__init__

def __init__(headless=headless,
             width=width,
             height=height,
             clear_logs=clear_logs,
             assert_dict=ASSERT_DICT) -> None

Arguments:

  • headless bool, optional - if False rdp window is shown. (default is True)
  • width int, optional - witdth of rdp window. Set it same in guacamole (default is 800)
  • height int, optional - witdth of rdp window. Set it same in guacamole (default is 600)
  • clear_logs bool, optional - if True old image logs will be removed when RDP class inited. (default is True)
  • assert_dict dict, optional - dict with assertion images. Pass it for unsupported OS (default is ASSERT_DICT)

login

def login(guacamole_user: str,
          guacamole_password: str,
          guacamole_pc_name: str,
          guacamole_url=guacamole_url) -> None

Login method. Call this first

key_press

def key_press(keys: str)

This is wrapper of playwright keyboard.press method. see: https://playwright.dev/python/docs/api/class-keyboard#keyboard-press

key_type

def key_type(text: str)

Type text on remote pc

make_screenshot

def make_screenshot(filename: Optional[str] = None,
                    path: Optional[str] = None) -> str

Make screenshot, and save it to default direcotry (./image_logs), or to given path

is_on_screen

def is_on_screen(assertion: str, threshold: float = image_threshold) -> bool

Checking assertion image is on screen (assertion is a path to image)

wait_until_appear

def wait_until_appear(assertion: str,
                      attempts: int = screen_state_attempts,
                      threshold: float = image_threshold) -> None

Waiting until assertion image is appear on screen (assertion is a path to image)

wait_until_desappear

def wait_until_desappear(assertion: str,
                         attempts: int = screen_state_attempts,
                         threshold: float = image_threshold) -> None

Waiting until assertion image is desappear on screen (assertion is a path to image)

exec_remote

def exec_remote(cmd_str: str) -> None

Execute remote command via win+r run window

copydir

def copydir(from_path: str, to_path: str) -> None

Copy folder on remote PC

copy

def copy(from_path: str, to_path: str) -> None

Copy file on remote PC

mkdir

def mkdir(dir_path: str) -> None

Making directory

opendir

def opendir(dir_path: str, local: bool = False) -> None

Open explorer.exe of given directory path

closedir

def closedir(dir_name: str) -> None

Close explorer.exe of given directory name

mouse_click

def mouse_click(x: float, y: float, click_count: int = 1) -> None

Mouse left click on remote PC by giving coordinates

mouse_move

def mouse_move(x: float, y: float) -> None

Mouse move on remote PC by giving coordinates

mouse_move_to

def mouse_move_to(assertion: str) -> Optional[tuple[float, float]]

Mouse move on remote PC by giving image assertion path

mouse_click_to

def mouse_click_to(
        assertion: str,
        button: Literal['left', 'middle', 'right'] = 'left') -> None

Mouse click on remote PC by giving image assertion path

current_lang

def current_lang() -> Optional[str]

Get a current keuboard language (now support only 'en' and 'ru')

lang_switch

def lang_switch(lang: Optional[str] = None) -> Optional[str]

Switch keuboard language (now support only 'en' and 'ru')

logout

def logout() -> None

Logout method

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rdp_manipulations-0.2.0.tar.gz (12.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rdp_manipulations-0.2.0-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

Details for the file rdp_manipulations-0.2.0.tar.gz.

File metadata

  • Download URL: rdp_manipulations-0.2.0.tar.gz
  • Upload date:
  • Size: 12.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.10.8 Darwin/21.2.0

File hashes

Hashes for rdp_manipulations-0.2.0.tar.gz
Algorithm Hash digest
SHA256 1efdec76591bd61929011c10dbde708fe652518a6aa0aa38eb2760b88592be21
MD5 79ef503131189d3bf913733e18f390dc
BLAKE2b-256 7dea6a9f849b7e1c25efeef36f59ef64196c687785e67bebc99f3b647e0785db

See more details on using hashes here.

File details

Details for the file rdp_manipulations-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: rdp_manipulations-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 12.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.10.8 Darwin/21.2.0

File hashes

Hashes for rdp_manipulations-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8ca82817f2852a66846e49ba000f383a619ffe6cab5998b7a9758e0bc4491e67
MD5 a5f6d98a09485b1b922b2b9fe0b40faa
BLAKE2b-256 52d2b0d3a9e406cf2d2716a9d336a237454ec348231b650bba25f38c67e46b69

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page