本文整理汇总了Python中robot.api.logger.warn函数的典型用法代码示例。如果您正苦于以下问题:Python warn函数的具体用法?Python warn怎么用?Python warn使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了warn函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_user_password
def get_user_password(self, user_login_id):
if self.db_conn == None:
logger.warn("Please use conn to initialize the connection first")
return False
self.db_cursor = self.db_conn.cursor()
query = ''
self.cursor.execute()
示例2: revoke_company_permission
def revoke_company_permission(self, driver, group_label, group_id, company_label, company_id):
'''
From the Design document, you already know the group_label, group_id, company_label, company_id
So, we use this parameter to select the new permission and check it.
'''
group_elem_xpath = self.page.get_xpath(group_id, 'group')
comp_elem_xpath = self.page.get_xpath(company_id, 'single')
try:
comp_elem = self.page.find_element_by_xpath(driver, comp_elem_xpath)
if comp_elem.get_attribute('checked') is None:
logger.warn("..The permission '%s' was NOT checked before. Continue without change"%company_label)
else:
time.sleep(1)
comp_elem.click()
logger.info("====Revoked the company permission '%s/%s'"%(group_label, company_label))
except (NoSuchElementException, ElementNotVisibleException):
group_elem = self.page.find_element_by_xpath(driver, group_elem_xpath)
group_elem.click()
comp_elem = self.page.find_element_by_xpath(driver, comp_elem_xpath)
if comp_elem.get_attribute('checked') is None:
logger.warn("..The permission '%s' was NOT checked before. Continue without change"%company_label)
else:
time.sleep(1)
comp_elem.click()
logger.info("====Revoked the company permission '%s/%s'"%(group_label, company_label))
示例3: _find_euh_dropdown
def _find_euh_dropdown(self,label_name, widget_name=None, index=0,first_call=True):
'''find the dropdown by label, and then ensure we have an element with tag = select'''
dropdown_div = self.get_euh_element_by_label(label_name, widget_name=widget_name,index=index)[0]
#this can take a long time do to the implict wait functionality
#TODO: this should use the quick check function from wait.py
wait = self.get_selenium_implicit_wait()
try:
self.set_browser_implicit_wait(0)
if self._element_or_children_contains_class_name(DC.Dropdown, dropdown_div):
#get underlying select
retval = (dropdown_div.find_element_by_tag_name("select"), DC.Dropdown)
elif self._element_or_children_contains_class_name(DC.AutocompleteDropDown, dropdown_div):
retval = (dropdown_div.find_element_by_tag_name("input"), DC.AutocompleteDropDown)
else:
logger.warn("element %s with widget_name = %s and index = %s does not appear to be a dropdown" %
(label_name, widget_name, index))
retval = (dropdown_div, None)
except StaleElementReferenceException as e:
#we got the element too soon try one more time
#TODO: these need to be refactored into a retry find type of structure / reusable function
if first_call:
self._find_euh_dropdown(label_name, widget_name,index,first_call=False)
raise e
finally:
self.set_browser_implicit_wait(wait)
return retval
示例4: check_on_permission
def check_on_permission(self, db_name, driver, group_label, single_label, type):
"""
If you just know the presentation label and want to select it.
"""
db_conn = Call_Oracle()
db_conn.login(db_name)
group_perm_id = db_conn.get_permission_id_from_label(group_label, "group", type)
single_perm_id = db_conn.get_permission_id_from_label(single_label, "single", type)
db_conn.close_connection()
group_elem_xpath = self.get_xpath(group_perm_id, "group")
single_elem_xpath = self.get_xpath(single_perm_id, "single")
try:
comp_elem = self.page.find_element_by_xpath(driver, single_elem_xpath)
if comp_elem.get_attribute("checked") is None:
time.sleep(1)
comp_elem.click()
logger.info("====Assigned %s permission: '%s/%s'" % (type, group_label, single_label))
else:
logger.warn("..The permission '%s' was already assigned. Continue without change" % single_label)
except (NoSuchElementException, ElementNotVisibleException):
group_elem = self.page.find_element_by_xpath(driver, group_elem_xpath)
group_elem.click()
comp_elem = self.page.find_element_by_xpath(driver, single_elem_xpath)
if comp_elem.get_attribute("checked") is None:
time.sleep(1)
comp_elem.click()
logger.info("====Assigned %s permission: '%s/%s'" % (type, group_label, single_label))
else:
logger.warn("..The permission '%s' was already assigned. Continue without change" % single_label)
示例5: HAdoopReport
def HAdoopReport():
var = robo.get_variable_value("${shellPrompt}")
ssh.set_client_configuration(prompt=var)
ssh.write("hdfs dfsadmin -report")
output = ssh.read_until_prompt()
#logger.info(output.splitlines())
for line in output.splitlines():
#match = re.search('Safemode.*',line)
#logger.warn(line.find("Safe mode is ON"))
if line.find("Safe mode is ON") == -1:
safemode = "True"
#logger.warn("Safemode is OFF")
else:
safemode = "False"
logger.warn("Safemode is ON")
if line.find("Datanodes available") != -1:
match = re.search('.*:\s(\d.)(?:.*,\s(\d.))',line)
#logger.warn("datanode number %s"%match.group(2))
logger.info(match.group(2),also_console = True)
if match.group(2) != 0:
Datanodes_up = "True"
elif line.find("java.net.ConnectException:") != -1:
logger.warn("Yarn is not UP , and throwing following exception",line)
Datanodes_up = "False"
#logger.warn("Inside Function safemode is %s"%safemode)
#logger.warn("Inside Function datanodes is %s"%Datanodes_up)
if safemode == "True" and Datanodes_up == "True":
return True
else:
return False
示例6: check_off_permission
def check_off_permission(self, db_name, driver, group_label, single_label, type):
db_conn = Call_Oracle()
db_conn.login(db_name)
group_perm_id = db_conn.get_permission_id_from_label(group_label, "group", type)
single_perm_id = db_conn.get_permission_id_from_label(single_label, "single", type)
db_conn.close_connection()
group_elem_xpath = self.page.get_xpath(group_perm_id, "group")
single_elem_xpath = self.page.get_xpath(single_perm_id, "single")
try:
comp_elem = self.page.find_element_by_xpath(driver, single_elem_xpath)
if comp_elem.get_attribute("checked") is None:
logger.warn("..The permission '%s' was NOT checked before. Continue without change" % single_label)
else:
time.sleep(1)
comp_elem.click()
logger.info("====Revoked %s permission '%s/%s'" % (type, group_label, single_label))
except (NoSuchElementException, ElementNotVisibleException):
group_elem = self.page.find_element_by_xpath(driver, group_elem_xpath)
group_elem.click()
comp_elem = self.page.find_element_by_xpath(driver, single_elem_xpath)
if comp_elem.get_attribute("checked") is None:
logger.warn("..The permission '%s' was NOT checked before. Continue without change" % single_label)
else:
time.sleep(1)
comp_elem.click()
logger.info("====Revoked the %s permission '%s/%s'" % (type, group_label, single_label))
示例7: get_blns
def get_blns(self):
if platform.system() == 'Windows':
logger.warn('Rading Big List of Naughty Strings does not work in Windows OS')
return []
cur_dir = os.path.dirname(os.path.abspath(__file__))
with open(os.path.join(cur_dir, 'blns.json'), 'r') as blns:
return json.load(blns)
示例8: get
def get(
self,
alias,
uri,
params=None,
headers=None,
allow_redirects=None,
timeout=None):
""" **Deprecated- See Get Request now**
Send a GET request on the session object found using the
given `alias`
`alias` that will be used to identify the Session object in the cache
`uri` to send the GET request to
`headers` a dictionary of headers to use with the request
`timeout` connection timeout
"""
logger.warn("Deprecation Warning: Use Get Request in the future")
session = self._cache.switch(alias)
redir = True if allow_redirects is None else allow_redirects
response = self._get_request(
session, uri, params, headers, redir, timeout)
return response
示例9: head
def head(
self,
alias,
uri,
headers=None,
allow_redirects=None,
timeout=None):
""" **Deprecated- See Head Request now**
Send a HEAD request on the session object found using the
given `alias`
``alias`` that will be used to identify the Session object in the cache
``uri`` to send the HEAD request to
``allow_redirects`` Boolean. Set to True if POST/PUT/DELETE redirect following is allowed.
``headers`` a dictionary of headers to use with the request
"""
logger.warn("Deprecation Warning: Use Head Request in the future")
session = self._cache.switch(alias)
redir = False if allow_redirects is None else allow_redirects
response = self._head_request(session, uri, headers, redir, timeout)
return response
示例10: select_user
def select_user(self, user_id, error=None):
"""
Assumes current browser is on the user selection page
:param user_id:
:return:
"""
xpath_candidates = ("xpath=//select[@name='dnqualifier']",)
for xpath in xpath_candidates:
logger.debug("Try xpath %s " % xpath)
logger.warn("Try xpath %s " % xpath)
ele = self._element_find(xpath, True, False)
if ele is not None:
ele = self._element_find("xpath=//option[@value='%s']" % user_id, True, False)
if ele is not None:
self.select_from_list(xpath, user_id)
else:
logger.warn("xpath=//option[contains(@value,'%s')]" % user_id, True)
ele = self._element_find("xpath=//option[contains(@value,'%s')]" % user_id, True, False)
if ele is not None:
full_value = ele.get_attribute("value")
self.select_from_list(xpath, full_value)
else:
raise RuntimeError("Not able to find user selection by value %s " % user_id)
return
raise AssertionError("Could not find user selection")
示例11: get_logcat_from_device
def get_logcat_from_device(self,path):
log = AndroidAppiumLibrary.driver.get_log("logcat")
with open(path, 'w+') as logfile:
logfile.write("\n".join(str(x) for x in log))
open(path+'_retrofit','w').writelines([ line.replace("u'", "'").replace(", 'level': 'ALL'", "") for line in open(path) if 'Retrofit' in line])
logger.warn('<a href="{0}" style="width:1000px; height:20px">Retrofit log</a>'.format(path+'_retrofit')+'<br><div style="width:1000px;height:450px;line-height:1.5em;overflow:scroll; padding:5px;border:1px solid black; background:#FFFFE0;">{0}</div>'.format(open(path+'_retrofit').read()), html=True)
logger.warn('<a href="{0}" style="width:1000px; height:20px">Full logcat</a>'.format(path), html=True)
示例12: cliPrompt
def cliPrompt(self,cluster="yes"):
logger.info("Switching to cli Prompt",also_console=True)
ssh.set_client_configuration(prompt="#")
ssh.write("cli -m config",loglevel="DEBUG")
output = ssh.read_until_prompt(loglevel="DEBUG")
logger.info("Showing Prompt %s"%output,also_console=True)
if output.find("% Unrecognized command") != -1:
logger.warn("You are logging from Root user", html=True)
self.SwitchToReflex()
ssh.set_client_configuration(prompt="#")
ssh.write("cli -m config",loglevel="DEBUG")
output = ssh.read_until_prompt(loglevel="DEBUG")
if cluster == "no":
m1 = re.search("^(?P<cliPrompt>\S+\s\(\S+\)\s*\#)\s*",output.strip(),re.MULTILINE)
else:
for lines in output.splitlines():
m1 = re.search("^(?P<cliPrompt>\S+\s\[\S+:\s\S+\]\s\(\S+\)\s*\#)\s*",lines.strip(),re.MULTILINE)
#logger.console(lines, newline=True, stream='stdout')
#m1 = re.search("^(?P<cliPrompt>.*\$\s.*config\S+\s\(\S+\)\s*\#)\s*",output.strip(),re.MULTILINE)
#logger.console(m1)
if m1:
cliPrompt = m1.group("cliPrompt")
logger.console(cliPrompt)
else:
logger.warn("Not able to grep cliPrompt")
ssh.set_client_configuration(prompt=cliPrompt)
示例13: patch
def patch(self, alias, uri, data={}, headers=None, files={}, allow_redirects=None, timeout=None):
""" **Deprecated- See Patch Request now**
Send a PATCH request on the session object found using the
given `alias`
``alias`` that will be used to identify the Session object in the cache
``uri`` to send the PATCH request to
``data`` a dictionary of key-value pairs that will be urlencoded
and sent as PATCH data
or binary data that is sent as the raw body content
``headers`` a dictionary of headers to use with the request
``files`` a dictionary of file names containing file data to PATCH to the server
``allow_redirects`` Boolean. Set to True if POST/PUT/DELETE redirect following is allowed.
``timeout`` connection timeout
"""
logger.warn("Deprecation Warning: Use Patch Request in the future")
session = self._cache.switch(alias)
data = self._utf8_urlencode(data)
redir = True if allow_redirects is None else allow_redirects
response = self._body_request("patch", session, uri, data, None, files, headers, redir, timeout)
return response
示例14: delete
def delete(
self,
alias,
uri,
data=(),
headers=None,
allow_redirects=None,
timeout=None):
""" * * * Deprecated- See Delete Request now * * *
Send a DELETE request on the session object found using the
given `alias`
`alias` that will be used to identify the Session object in the cache
`uri` to send the DELETE request to
`headers` a dictionary of headers to use with the request
`timeout` connection timeout
"""
logger.warn("Deprecation Warning: Use Delete Request in the future")
session = self._cache.switch(alias)
data = self._utf8_urlencode(data)
redir = True if allow_redirects is None else allow_redirects
response = self._delete_request(
session, uri, data, None, headers, redir, timeout)
return response
示例15: verify_resource_id_has_attributes_in_DB
def verify_resource_id_has_attributes_in_DB(self, resource_id, label, order='', label_tag='', company_typ_cd=''):
if company_typ_cd!='':
statement = "Select * from Presentation where PRSNTTN_LABEL='%s' and PRSNTTN_ORDER in ('%s')" \
"and PRSNTTN_LABEL_TAG in ('%s') and PRSNTTN_ID in " \
"(select PRSNTTN_ID from RESOURC where RSRC_ID='%s' and CMPNY_TYP_CD ='%s')"%(label, order, label_tag, resource_id, company_typ_cd)
elif order!='' and label_tag!='':
statement = "Select * from Presentation where PRSNTTN_LABEL='%s' and PRSNTTN_ORDER in ('%s')" \
"and PRSNTTN_LABEL_TAG in ('%s') and PRSNTTN_ID in " \
"(select PRSNTTN_ID from RESOURC where RSRC_ID='%s')"%(label, order, label_tag, resource_id)
else:
statement = "Select * from Presentation where PRSNTTN_LABEL='%s' and PRSNTTN_ID in " \
"(select PRSNTTN_ID from RESOURC where RSRC_ID='%s')"%(label, resource_id)
logger.debug("fun: verify_resource_id_has_attributes_in_DB")
logger.debug(statement)
try:
self.conn.check_if_exists_in_database(statement)
msg = "==Verified Resource '%s' has attributes in DB Succeed! \nRSRC_ID %s has Label-->'%s' + Order-->'%s' + Tag-->'%s' and Company_Type_CD-->'%s'\n %s"%(resource_id, resource_id, label, order, label_tag, company_typ_cd, statement)
logger.info(msg)
except AssertionError, e:
query = "select PRSNTTN_LABEL, PRSNTTN_ORDER, PRSNTTN_LABEL_TAG from Presentation where PRSNTTN_ID in "\
"(select PRSNTTN_ID from RESOURC where RSRC_ID='%s')"%(resource_id)
result = self.conn.query(query)
admin = self.conn.query("SELECT CMPNY_TYP_CD FROM RESOURC WHERE RSRC_ID='%s'"%resource_id)
msg = "!!!Expected:['%s', '%s', '%s', '%s'] --> Actual: [%s, %s]"%(label, order, label_tag, company_typ_cd, result[0], admin[0][0])
logger.warn(e.message)
raise AssertionError(msg)