本文整理汇总了Python中exceptions.AttributeError方法的典型用法代码示例。如果您正苦于以下问题:Python exceptions.AttributeError方法的具体用法?Python exceptions.AttributeError怎么用?Python exceptions.AttributeError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类exceptions
的用法示例。
在下文中一共展示了exceptions.AttributeError方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_symbol
# 需要导入模块: import exceptions [as 别名]
# 或者: from exceptions import AttributeError [as 别名]
def make_symbol(ldlib, name, symbol, restype, argtypes):
""" Helper for library symbols generation
:param ldlib: loaded library reference
:param name: function call to use
:param symbol: library symbol to attach function to
:param restype: library symbol return type
:param argtypes: list of library symbol parameters
:return: None
"""
try:
ldlib[name] = ldlib.lib[symbol]
ldlib[name].restype = restype
ldlib[name].argtypes = argtypes
except AttributeError:
print ldlib.name, name, "import(%d): Symbol not found" % sys.exc_info()[-1].tb_lineno
except TypeError:
pass
except Exception as ex:
print name, "import(%d):" % sys.exc_info()[-1].tb_lineno, ex, type(ex)
示例2: privmsg
# 需要导入模块: import exceptions [as 别名]
# 或者: from exceptions import AttributeError [as 别名]
def privmsg(self, user, channel, message):
user_name = user.split("!")[0]
user_ip = user.split("@")[1]
msg = message.split()
try:
host = re.match(r"\w+!~(\w+)@", user).group(1)
except exceptions.AttributeError:
host = ""
temp_time = time.time()
# pm privilages
if (channel == self.nickname) and user_ip != admin_ip:
return
# print(channel, user, message)
if (temp_time - self.__last_response > 5) or user.split("@")[1] == admin_ip:
# admin commands
if user_ip == admin_ip:
self.admin_cmds(channel, message)
# ignore list
if host in self.__ignore:
return
# match spoutWisdom
elif re.search("Lonnie," and "law", message.lower()):
self.spoutWisdom(channel, temp_time)
elif re.search("Lonnie," and "help", message.lower()):
self.helpText(channel, temp_time)
elif re.search("Business", message.lower()):
self.genBusiness(channel, temp_time)
else:
return
示例3: get_driver_obj
# 需要导入模块: import exceptions [as 别名]
# 或者: from exceptions import AttributeError [as 别名]
def get_driver_obj(lib):
try:
driver_obj = lib._current_browser()
except AttributeError:
driver_obj = lib.driver
return driver_obj
示例4: _sldriver
# 需要导入模块: import exceptions [as 别名]
# 或者: from exceptions import AttributeError [as 别名]
def _sldriver(self):
try:
return self._s2l._current_browser()
except AttributeError:
return self._s2l.driver
示例5: return_all_possible_state_combinations
# 需要导入模块: import exceptions [as 别名]
# 或者: from exceptions import AttributeError [as 别名]
def return_all_possible_state_combinations(self):
"""Return all possible state combinations for the qtc_type defined for this class instance.
:return: All possible state combinations.
:rtype:
* String representation as a list of possible tuples, or,
* Integer representation as a list of lists of possible tuples
"""
ret_str = []
ret_int = []
try:
if self.qtc_type == "":
raise AttributeError()
elif self.qtc_type == 'b':
for i in xrange(1, 4):
for j in xrange(1, 4):
ret_int.append([i-2, j-2])
ret_str.append(str(i-2) + "," + str(j-2))
elif self.qtc_type is 'c':
for i in xrange(1, 4):
for j in xrange(1, 4):
for k in xrange(1, 4):
for l in xrange(1, 4):
ret_int.append([i-2, j-2, k-2, l-2])
ret_str.append(str(i-2) + "," + str(j-2) + "," + str(k-2) + "," + str(l-2))
elif self.qtc_type is 'bc':
for i in xrange(1, 4):
for j in xrange(1, 4):
ret_int.append([i-2, j-2, np.NaN, np.NaN])
ret_str.append(str(i-2) + "," + str(j-2))
for i in xrange(1, 4):
for j in xrange(1, 4):
for k in xrange(1, 4):
for l in xrange(1, 4):
ret_int.append([i-2, j-2, k-2, l-2])
ret_str.append(str(i-2) + "," + str(j-2) + "," + str(k-2) + "," + str(l-2))
except AttributeError:
raise QTCException("Please define a qtc type using self.qtc_type.")
return None, None
return [s.replace('-1','-').replace('1','+') for s in ret_str], ret_int
示例6: process_attachments
# 需要导入模块: import exceptions [as 别名]
# 或者: from exceptions import AttributeError [as 别名]
def process_attachments(self, mail_message, post):
attachments = []
try:
attachments = mail_message.attachments
except exceptions.AttributeError:
pass #No attachments, then the attribute doesn't even exist :/
if attachments:
logging.info('Received %s attachment(s)' % len(attachments))
for attachment in attachments:
original_filename = attachment.filename
encoded_payload = attachment.payload
content_id = attachment.content_id
if content_id:
content_id = content_id.replace('<', '').replace('>', '') # Don't want these around the id, messes with our tag handling
logging.info('Processing attachment: %s' % original_filename)
if re.search('\\.(jpe?g|png|bmp|gif)$', original_filename.lower()):
if post.images is None:
post.images = []
bytes = encoded_payload.payload
if encoded_payload.encoding:
bytes = bytes.decode(encoded_payload.encoding)
post.has_images = True
user_image = UserImage()
img_name = UserImage.create_image_name(original_filename, post.date, post.images)
user_image.import_image(img_name, original_filename, bytes, post.date, content_id)
post.images.append(img_name)
user_image.is_inline = False
if content_id:
placeholder = '$IMG:' + content_id
if placeholder in post.text:
user_image.is_inline = True
#Ok, lets put in a filename instead of the content_id
post.text = post.text.replace(placeholder, '$IMG:' + img_name)
user_image.put()
else:
logging.warning('Received unsupported attachment, %s' % original_filename)