Skip to content

Commit

Permalink
restruct logger module
Browse files Browse the repository at this point in the history
Signed-off-by: xcgspring <[email protected]>
  • Loading branch information
xcgspring committed Aug 4, 2015
1 parent 6bfb1f5 commit a83fd9c
Show file tree
Hide file tree
Showing 20 changed files with 81 additions and 81 deletions.
6 changes: 3 additions & 3 deletions AXUI/XML/app_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def verification(self):
try:
import pyxb
except ImportError:
LOGGER().info("pyxb not install, skip app map verification")
LOGGER.debug("pyxb not install, skip app map verification")
return

from validate import check_app_map
Expand Down Expand Up @@ -238,7 +238,7 @@ def gui_execute(self, command):
'''
(object_name_list, parameter_list) = gui_command_parser.parse(command, lexer=gui_command_lexer)
object_= self._get_object_by_name_list(object_name_list)
LOGGER().debug("GUI execute %s %s" , object_name_list, parameter_list)
LOGGER.debug("GUI execute %s %s" , object_name_list, parameter_list)
object_(*parameter_list)

def cli_execute(self, command):
Expand All @@ -257,7 +257,7 @@ def cli_execute(self, command):
if app_path:
os.chdir(app_path)

LOGGER().debug("CLI execute: %s" , repr(args))
LOGGER.debug("CLI execute: %s" , repr(args))
p = subprocess.Popen(args, shell=True)
#some app is blocking, do not wait here
#p.communicate()
Expand Down
2 changes: 1 addition & 1 deletion AXUI/XML/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ def screenshot(self):
os.remove(absfile)

self.UIElement.screenshot(absfile)
LOGGER().debug("screenshot take: %s" , absfile)
LOGGER.debug("screenshot take: %s" , absfile)
return absfile

def __getattr__(self, name):
Expand Down
4 changes: 2 additions & 2 deletions AXUI/XML/func.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ def __init__(self, xml_element, app_map):

def run(self):
if self.type == "GUI":
LOGGER().debug("run gui command: %s" , self.command)
LOGGER.debug("run gui command: %s" , self.command)
self.app_map.gui_execute(self.command)
elif self.type == "CLI":
LOGGER().debug("run cli command: %s" , self.command)
LOGGER.debug("run cli command: %s" , self.command)
self.app_map.cli_execute(self.command)
else:
raise ValueError("step type must be GUI or CLI, get: %s" % self.type)
Expand Down
8 changes: 4 additions & 4 deletions AXUI/XML/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,12 @@ def check_app_map(XSD_file, app_map_file):
with open(app_map_file) as app_map:
try:
XSD_module.CreateFromDocument(app_map.read())
LOGGER().info("Check successful")
LOGGER.debug("Check successful")
except pyxb.UnrecognizedContentError as e:
LOGGER().warn(e.details())
LOGGER.warn(e.details())
except pyxb.IncompleteElementContentError as e:
LOGGER().warn(e.details())
LOGGER.warn(e.details())
except pyxb.ValidationError as e:
LOGGER().warn(e.details())
LOGGER.warn(e.details())


4 changes: 2 additions & 2 deletions AXUI/driver/appium_driver/Translater.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ def get_translated(self):
try:
getattr(MobileBy, name.upper())
except AttributeError:
LOGGER().error("identifier not support: %s" , name)
LOGGER.error("identifier not support: %s" , name)
raise DriverException("identifier not support: %s" % name)
return getattr(MobileBy, name.upper()), value
else:
LOGGER().error("Get error parsed_id: %s" , repr(self.parsed_identifier))
LOGGER.error("Get error parsed_id: %s" , repr(self.parsed_identifier))
raise DriverException("Get error parsed_id: %s" % repr(self.parsed_identifier))


Expand Down
24 changes: 12 additions & 12 deletions AXUI/driver/appium_driver/UIElement.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
try:
import appium.webdriver as webdriver
except ImportError, e:
LOGGER().error("To use AXUI appium driver, you must install selenium and appium python client first, check https://pypi.python.org/pypi/selenium, https://pypi.python.org/pypi/Appium-Python-Client")
LOGGER.error("To use AXUI appium driver, you must install selenium and appium python client first, check https://pypi.python.org/pypi/selenium, https://pypi.python.org/pypi/Appium-Python-Client")
raise e

from selenium.common.exceptions import NoSuchElementException
Expand Down Expand Up @@ -42,7 +42,7 @@ def input(self, *values):
try:
key_value = getattr(Keys, key)
except AttributeError, e:
LOGGER().warning("Input special key not support: %s, skip this input" , key)
LOGGER.warning("Input special key not support: %s, skip this input" , key)
else:
translated_values.append(key_value)
else:
Expand Down Expand Up @@ -107,7 +107,7 @@ def __getattr__(self, name):
if name in self.interfaces:
return getattr(self.selenium_element, name)
else:
LOGGER().info("This method not exist in NormalPattern: %s", name)
LOGGER.debug("This method not exist in NormalPattern: %s", name)

class BrowserPattern(object):
'''
Expand Down Expand Up @@ -150,7 +150,7 @@ def __getattr__(self, name):
if name in self.interfaces:
return getattr(self.selenium_element, name)
else:
LOGGER().info("This method not exist in BrowserPattern: %s", name)
LOGGER.debug("This method not exist in BrowserPattern: %s", name)

class MobilePattern(object):
'''
Expand Down Expand Up @@ -205,7 +205,7 @@ def __getattr__(self, name):
if name in self.interfaces:
return getattr(self.selenium_element, name)
else:
LOGGER().info("This method not exist in MobileRootPattern: %s", name)
LOGGER.debug("This method not exist in MobileRootPattern: %s", name)

class UIElement(object):
'''This class defines interfaces for common UI element
Expand Down Expand Up @@ -237,7 +237,7 @@ def find_element(self, parsed_identifier):
try:
selenium_element = self.selenium_element.find_element(by=translated_identifier[0], value=translated_identifier[1])
except NoSuchElementException:
LOGGER().debug("Cannot find target element")
LOGGER.debug("Cannot find target element")
return None
else:
return UIElement(selenium_element)
Expand All @@ -262,13 +262,13 @@ def get_property(self, name):
try:
obj = getattr(self.selenium_element, name)
except AttributeError:
LOGGER().debug("Cannot find this attribute: %s" , name)
LOGGER.debug("Cannot find this attribute: %s" , name)
if hasattr(self.selenium_element, "get_attribute"):
LOGGER().debug("Try get_attribute method")
LOGGER.debug("Try get_attribute method")
return self.selenium_element.get_attribute(name)
else:
if inspect.ismethod(obj):
LOGGER().info("This is a method, not a property: %s" , name)
LOGGER.debug("This is a method, not a property: %s" , name)
return None
else:
return obj
Expand Down Expand Up @@ -398,19 +398,19 @@ def get_keyboard(self):
'''
get keyboard class to use keyboard related methods
'''
LOGGER().info("Browser not support keyboard action")
LOGGER.debug("Browser not support keyboard action")
return None

def get_mouse(self):
'''
get mouse class to use mouse related methods
'''
LOGGER().info("Browser not support mouse action")
LOGGER.debug("Browser not support mouse action")
return None

def get_touch(self):
'''
get touch class to use touch related methods
'''
LOGGER().info("Browser not support touch action")
LOGGER.debug("Browser not support touch action")
return None
4 changes: 2 additions & 2 deletions AXUI/driver/selenium_driver/Translater.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ def get_translated(self):
try:
getattr(By, name.upper())
except AttributeError:
LOGGER().error("identifier not support: %s" , name)
LOGGER.error("identifier not support: %s" , name)
raise DriverException("identifier not support: %s" % name)
return getattr(By, name.upper()), value
else:
LOGGER().error("Get error parsed_id: %s" , repr(self.parsed_identifier))
LOGGER.error("Get error parsed_id: %s" , repr(self.parsed_identifier))
raise DriverException("Get error parsed_id: %s" % repr(self.parsed_identifier))


Expand Down
26 changes: 13 additions & 13 deletions AXUI/driver/selenium_driver/UIElement.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
try:
import selenium.webdriver as webdriver
except ImportError, e:
LOGGER().error("To use AXUI selenium driver, you must install selenium python project first, check https://pypi.python.org/pypi/selenium")
LOGGER.error("To use AXUI selenium driver, you must install selenium python project first, check https://pypi.python.org/pypi/selenium")
raise e

from selenium.common.exceptions import NoSuchElementException
Expand Down Expand Up @@ -42,7 +42,7 @@ def input(self, *values):
try:
key_value = getattr(Keys, key)
except AttributeError, e:
LOGGER().warning("Input special key not support: %s, skip this input" , key)
LOGGER.warning("Input special key not support: %s, skip this input" , key)
else:
translated_values.append(key_value)
else:
Expand Down Expand Up @@ -83,7 +83,7 @@ def __getattr__(self, name):
if name in self.interfaces:
return getattr(self.selenium_element, name)
else:
LOGGER().info("This method not exist in NormalPattern: %s", name)
LOGGER.debug("This method not exist in NormalPattern: %s", name)

class BrowserPattern(object):
'''
Expand Down Expand Up @@ -126,7 +126,7 @@ def __getattr__(self, name):
if name in self.interfaces:
return getattr(self.selenium_element, name)
else:
LOGGER().info("This method not exist in BrowserPattern: %s", name)
LOGGER.debug("This method not exist in BrowserPattern: %s", name)

class UIElement(object):
'''This class defines interfaces for common UI element
Expand Down Expand Up @@ -158,7 +158,7 @@ def find_element(self, parsed_identifier):
try:
selenium_element = self.selenium_element.find_element(by=translated_identifier[0], value=translated_identifier[1])
except NoSuchElementException:
LOGGER().debug("Cannot find target element")
LOGGER.debug("Cannot find target element")
return None
else:
return UIElement(selenium_element)
Expand All @@ -183,13 +183,13 @@ def get_property(self, name):
try:
obj = getattr(self.selenium_element, name)
except AttributeError:
LOGGER().debug("Cannot find this attribute: %s" , name)
LOGGER.debug("Cannot find this attribute: %s" , name)
if hasattr(self.selenium_element, "get_attribute"):
LOGGER().debug("Try get_attribute method")
LOGGER.debug("Try get_attribute method")
return self.selenium_element.get_attribute(name)
else:
if inspect.ismethod(obj):
LOGGER().info("This is a method, not a property: %s" , name)
LOGGER.debug("This is a method, not a property: %s" , name)
return None
else:
return obj
Expand Down Expand Up @@ -292,12 +292,12 @@ def start(self, **kwargs):
other kwargs are same as normal selenium webdrivers
'''
if not "browser_name" in kwargs:
LOGGER().error("Browser name not specified")
LOGGER.error("Browser name not specified")
raise DriverException("Browser name not specified")

browser_name = kwargs["browser_name"]
if not browser_name.upper() in self.support_browsers:
LOGGER().error("Unsupported browser name: %s" , browser_name)
LOGGER.error("Unsupported browser name: %s" , browser_name)
raise DriverException("Unsupported browser name: %s" % browser_name)

#remove browser_name key from kwargs
Expand Down Expand Up @@ -357,19 +357,19 @@ def get_keyboard(self):
'''
get keyboard class to use keyboard related methods
'''
LOGGER().info("Browser not support keyboard action")
LOGGER.debug("Browser not support keyboard action")
return None

def get_mouse(self):
'''
get mouse class to use mouse related methods
'''
LOGGER().info("Browser not support mouse action")
LOGGER.debug("Browser not support mouse action")
return None

def get_touch(self):
'''
get touch class to use touch related methods
'''
LOGGER().info("Browser not support touch action")
LOGGER.debug("Browser not support touch action")
return None
2 changes: 1 addition & 1 deletion AXUI/driver/windows_driver/Translater.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def _translated_atomic_identifier(self, parsed_atomic_id):
return UIA.IUIAutomation_object.CreatePropertyCondition(UIA.UIA_control_pattern_property_identifiers_mapping[parsed_atomic_id[0]], parsed_atomic_id[1])
else:
#use no UIA identifier will be skipped
LOGGER().warn("identifier: %s not in UIA property maps" , parsed_atomic_id[0])
LOGGER.warn("identifier: %s not in UIA property maps" , parsed_atomic_id[0])
return None

def _translated_relational_identifier(self, relation, translated_id_1, translated_id_2):
Expand Down
20 changes: 10 additions & 10 deletions AXUI/driver/windows_driver/UIA.py
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,7 @@ class UIAException(Exception):
if enum_name_type is not ctypes.c_int:
#enum type should be c_int in UIA wrapper namespace
#skip this enum if enum type is not c_int
LOGGER().debug("Enum: %s not exist in current UIA namespace" , enum_name)
LOGGER.debug("Enum: %s not exist in current UIA namespace" , enum_name)
continue

for enum_content_name in enum_contents:
Expand All @@ -989,7 +989,7 @@ class UIAException(Exception):
for identifier in UIA_automation_element_property_identifers:
value = getattr(UIA_wrapper, "UIA_"+identifier+"PropertyId", None)
if value is None:
LOGGER().debug("Automation element property identifier: %s not exist in current UIA namespace" , identifier)
LOGGER.debug("Automation element property identifier: %s not exist in current UIA namespace" , identifier)
continue
UIA_automation_element_property_identifers_mapping[identifier] = value

Expand All @@ -998,7 +998,7 @@ class UIAException(Exception):
for identifier in UIA_control_pattern_property_identifiers:
value = getattr(UIA_wrapper, "UIA_"+identifier+"PropertyId", None)
if value is None:
LOGGER().debug("Automation element control pattern property identifier: %s not exist in current UIA namespace" , identifier)
LOGGER.debug("Automation element control pattern property identifier: %s not exist in current UIA namespace" , identifier)
continue
UIA_control_pattern_property_identifiers_mapping[identifier] = value

Expand All @@ -1007,7 +1007,7 @@ class UIAException(Exception):
for identifier in UIA_control_pattern_availability_property_identifiers:
value = getattr(UIA_wrapper, "UIA_"+identifier+"PropertyId", None)
if value is None:
LOGGER().debug("Control pattern property identifier: %s not exist in current UIA namespace" , identifier)
LOGGER.debug("Control pattern property identifier: %s not exist in current UIA namespace" , identifier)
continue
UIA_control_pattern_availability_property_identifiers_mapping[identifier] = value

Expand All @@ -1017,7 +1017,7 @@ class UIAException(Exception):
identifier_value = getattr(UIA_wrapper, "UIA_"+identifier+"Id", None)
interface_value = getattr(UIA_wrapper, "IUIAutomation"+identifier, None)
if identifier_value is None:
LOGGER().debug("Control pattern identifier: %s not exist in current UIA namespace" , identifier)
LOGGER.debug("Control pattern identifier: %s not exist in current UIA namespace" , identifier)
continue
UIA_control_pattern_identifers_mapping[identifier] = (identifier_value, interface_value)

Expand All @@ -1034,18 +1034,18 @@ def get_property_by_id(UIAElement, property_identifier):
if property_identifier in UIA_automation_element_property_identifers_mapping:
property_value = UIAElement.GetCurrentPropertyValue(UIA_automation_element_property_identifers_mapping[property_identifier])
if property_value is None:
LOGGER().debug("This property:%s is not supported by this UIAElment" , property_identifier)
LOGGER.debug("This property:%s is not supported by this UIAElment" , property_identifier)
return ""
return property_value

elif property_identifier in UIA_control_pattern_availability_property_identifiers_mapping:
property_value = UIAElement.GetCurrentPropertyValue(UIA_control_pattern_availability_property_identifiers_mapping[property_identifier])
if property_value is None:
LOGGER().debug("This property:%s is not supported by this UIAElment" , property_identifier)
LOGGER.debug("This property:%s is not supported by this UIAElment" , property_identifier)
return ""
return property_value
else:
LOGGER().debug("This property identifier is not support: %s, cannot get it from UIA typelib" % property_identifier)
LOGGER.debug("This property identifier is not support: %s, cannot get it from UIA typelib" % property_identifier)
return None

def get_pattern_by_id(UIAElement, pattern_identifier):
Expand All @@ -1064,7 +1064,7 @@ def get_pattern_by_id(UIAElement, pattern_identifier):

pattern = UIAElement.GetCurrentPatternAs(UIA_pattern_identifier, UIA_pattern_interface._iid_)
if pattern is None:
LOGGER().debug("This pattern:%s is not supported by this UIAElment" , pattern_identifier)
LOGGER.debug("This pattern:%s is not supported by this UIAElment" , pattern_identifier)
return None
return ctypes.POINTER(UIA_pattern_interface)(pattern)
'''
Expand All @@ -1073,5 +1073,5 @@ def get_pattern_by_id(UIAElement, pattern_identifier):
return pattern
'''
else:
LOGGER().debug("This pattern identifier is not support: %s, cannot get it from UIA typelib" , pattern_identifier)
LOGGER.debug("This pattern identifier is not support: %s, cannot get it from UIA typelib" , pattern_identifier)
return None
Loading

0 comments on commit a83fd9c

Please sign in to comment.