Skip to content

Commit

Permalink
Release support for Python 3.8 and above versions
Browse files Browse the repository at this point in the history
Fixes #53
  • Loading branch information
amruthvvkp committed Sep 8, 2023
1 parent f638057 commit 9ea227e
Show file tree
Hide file tree
Showing 13 changed files with 1,441 additions and 352 deletions.
14 changes: 4 additions & 10 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
"uiautomation",
"versioneer"
],
"python.testing.pytestArgs": [],
"python.testing.pytestArgs": [
"tests"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"files.exclude": {
Expand All @@ -19,15 +21,7 @@
"testExplorer.mergeSuites": true,
"testExplorer.hideWhen": "noTests",
"testExplorer.showOnRun": true,
"python.linting.pylintEnabled": false,
"python.linting.enabled": true,
"python.linting.flake8Enabled": false,
"python.formatting.yapfArgs": [
"COLUMN_LIMIT=120"
],
"python.formatting.provider": "black",
"python.linting.mypyEnabled": true,
"python.analysis.extraPaths": [
"typings"
]
],
}
20 changes: 14 additions & 6 deletions config.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
import os
"""This module holds all settings for the tool."""
from pathlib import Path
from typing import List

from pydantic import BaseSettings
from pydantic import FilePath
from pydantic_settings import BaseSettings


class Settings(BaseSettings):
BIN_HOME: str = os.path.join(Path(__file__).parent.resolve(), "flaui", "bin")
WRAPPERS_HOME: str = os.path.join(Path(__file__).parent.resolve(), "flaui", "wrappers_temp")
FLAUI_HOME: str = str(Path(r"C:\Users\Amruth.Vithala\Projects\FlaUI\src"))
"""Holds all common settings for the tool"""
BIN_HOME: Path = Path(__file__).parent.joinpath("flaui", "bin")


class TestSettings(BaseSettings):
"""Holds all settings for the unit test usages"""
WPF_TEST_APP_EXE: FilePath = Path(__file__).parent.joinpath("test_applications", "WPFApplication", "WpfApplication.exe")
WPF_TEST_APP_PROCESS: str = "WpfApplication.exe"
WINFORMS_TEST_APP_EXE: FilePath = Path(__file__).parent.joinpath("test_applications", "WINFORMSApplication", "WinFormsApplication.exe")
WINFORMS_TEST_APP_PROCESS: str = "WinFormsApplication.exe"


settings = Settings()
test_settings = TestSettings()
3 changes: 3 additions & 0 deletions flaui/lib/enums.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
"""Enums for UIAutomationTypes."""
from enum import Enum


class UIAutomationTypes(Enum):
"""Enum for UIAutomationTypes."""
UIA2 = 'UIA2'
UIA3 = 'UIA3'
23 changes: 9 additions & 14 deletions flaui/lib/pythonnet_bridge.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,25 @@
import os
"""This module provides a bridge between Python and .NET using Python.NET."""

import clr
from loguru import logger

import config

from loguru import logger

def setup_pythonnet_bridge() -> None:
"""Sets up PythonNet bridge
Sets up PythonNet bridge for FlaUI and automation dependencies for UI Automation
"""
Sets up Python.NET bridge for FlaUI and automation dependencies for UI Automation
so that the interlinked C# .NET dependencies are injected into the Python environment
listed under flaui/bin folder.
:param dll_list: List of DLL's to add to the PythonNet wrapper
:raises err: On failure to load the existing C# dependencies listed under flaui/bin
"""
BIN_HOME = config.settings.BIN_HOME
logger.info(f"Looking for valid binaries at - {BIN_HOME}")
try:
for _ in os.listdir(BIN_HOME):
path, dll = os.path.join(BIN_HOME, _), _.replace(".dll", "")
clr.AddReference(path)
clr.AddReference(dll)
logger.info(f"Added {dll} DLL from {path} to PythonNet bridge")
for _ in BIN_HOME.glob("*.dll"):
clr.AddReference(_.as_posix()) # pyright: ignore
clr.AddReference(_.stem) # pyright: ignore
logger.info(f"Added {_.name} DLL from {_} to Python.NET bridge")
except Exception as err:
logger.exception(f"{err}")
raise err

logger.info("Python.NET bridge setup complete")
Empty file removed flaui/wrapper_generator/README.md
Empty file.
Empty file.
18 changes: 0 additions & 18 deletions flaui/wrapper_generator/main.py

This file was deleted.

48 changes: 0 additions & 48 deletions flaui/wrapper_generator/tools.py

This file was deleted.

6 changes: 2 additions & 4 deletions flaui/wrappers/ui_automation.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from typing import Any, Optional

import pyautogui
from typing import Any, Optional

from flaui.lib.enums import UIAutomationTypes
from FlaUI.UIA2 import UIA2Automation # pyright: ignore
Expand All @@ -10,7 +9,7 @@
class UIAutomation:
"""UIAutomation constructed wrapper for FlaUI DLL
FlaUI is written entirely on C# .Net, using it directly inside an IDE within a Python project
FlaUI is written entirely on C# .Net, using it directly inside an IDE within a Python project
would be painful since intellisense does not pick up the methods/typing hints.
This class is designed to overcome those challenges by providing Python compatible workstream.
"""
Expand All @@ -21,7 +20,6 @@ def __init__(self, ui_automation_types: UIAutomationTypes, timeout: int = 1000)
self.timeout = timeout
self.automation = UIA3Automation(
) if ui_automation_types == UIAutomationTypes.UIA3 else UIA2Automation()
self.pyautogui = pyautogui
self.cf = self.automation.ConditionFactory
self.tree_walker = self.automation.TreeWalkerFactory.GetRawViewWalker()
self.application: Optional[Any] = None
Expand Down
Loading

0 comments on commit 9ea227e

Please sign in to comment.