Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore some backward compatibility with 0.6.8 #1253

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pywinauto/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ def wrap(*args, **kwargs):
import win32api # noqa: E402
import pythoncom # noqa: E402

from .windows import win32defines


def _get_com_threading_mode(module_sys):
"""Set up COM threading model
Expand Down
5 changes: 5 additions & 0 deletions pywinauto/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@

if sys.platform == 'win32':
from .windows.application import Application # noqa: W0611
from .windows.application import process_module # noqa: W0611
from .windows.application import process_get_modules # noqa: W0611
from .windows.application import ProcessNotFoundError # noqa: W0611
from .windows.application import AppStartError # noqa: W0611
from .windows.application import AppNotConnected # noqa: W0611
else:
from .linux.application import Application # noqa: W0611

Expand Down
17 changes: 12 additions & 5 deletions pywinauto/findwindows.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from __future__ import unicode_literals

import re
import warnings
import six

from . import findbestmatch
Expand Down Expand Up @@ -150,17 +151,23 @@ def find_elements(**kwargs):

# tell user about new property name for every renamed one
if hasattr(backend_obj.element_info_class, 'renamed_props'):
renamed_erros = []
#renamed_erros = []
for key, value in kwargs.items():
renamed_prop = backend_obj.element_info_class.renamed_props.get(key, None)
if renamed_prop is not None:
new_key, values_map = renamed_prop
if values_map and value in values_map.keys():
renamed_erros.append('"{}={}" -> "{}={}"'.format(key, value, new_key, values_map[value]))
error_msg = '"{}={}" -> "{}={}"'.format(key, value, new_key, values_map[value])
kwargs[new_key] = values_map[value]
else:
renamed_erros.append('"{}" -> "{}"'.format(key, new_key))
if renamed_erros:
raise RenamedKeywordError('[pywinauto>=0.7.0] Some search keywords are renamed: ' + ', '.join(renamed_erros))
error_msg = '"{}" -> "{}"'.format(key, new_key)
kwargs[new_key] = kwargs[key]
del kwargs[key]
#renamed_erros.append(error_msg)
warnings.warn("[pywinauto>=0.7.0] Keyword is renamed: {}".format(error_msg), DeprecationWarning)
# TODO: raise error in future releases
#if renamed_erros:
# raise RenamedKeywordError('[pywinauto>=0.7.0] Some search keywords are renamed: ' + ', '.join(renamed_erros))

re_props = backend_obj.element_info_class.re_props
exact_only_props = backend_obj.element_info_class.exact_only_props
Expand Down
9 changes: 9 additions & 0 deletions pywinauto/windows/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,15 @@ def connect(self, **kwargs):
except TimeoutError:
raise ProcessNotFoundError('Process with PID={} not found!'.format(self.process))
connected = True
elif 'process' in kwargs:
warnings.warn("'process' keyword is deprecated, use 'pid' instead", DeprecationWarning)
kwargs['pid'] = self.process = kwargs['process']
del kwargs['process']
try:
wait_until(timeout, retry_interval, self.is_process_running, value=True)
except TimeoutError:
raise ProcessNotFoundError('Process with PID={} not found!'.format(self.process))
connected = True

elif 'handle' in kwargs:

Expand Down